|
| 1 | +# Manual WiFi Configuration |
| 2 | + |
| 3 | +This guide explains how to manually configure WiFi credentials by editing the source code before compilation. This method is only recommended for advanced users or special deployment scenarios. |
| 4 | + |
| 5 | +**⚠️ NOTE**: For normal use, it's recommended to use the automatic WiFi setup via Access Point mode (see main [README](README.md)). |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +- Arduino IDE or PlatformIO installed |
| 10 | +- ESP32-P4 board support configured |
| 11 | +- Source code downloaded |
| 12 | + |
| 13 | +## Configuration Steps |
| 14 | + |
| 15 | +### 1. Edit Default WiFi Credentials |
| 16 | + |
| 17 | +Open [`config_storage.cpp`](config_storage.cpp) and locate the `setDefaults()` function: |
| 18 | + |
| 19 | +```cpp |
| 20 | +void ConfigStorage::setDefaults() { |
| 21 | + // Set hardcoded defaults from original config.cpp |
| 22 | + // WiFi credentials are intentionally empty - device will start captive portal on first boot |
| 23 | + config.wifiProvisioned = false; |
| 24 | + config.wifiSSID = ""; // ← Edit this line |
| 25 | + config.wifiPassword = ""; // ← Edit this line |
| 26 | + |
| 27 | + config.mqttServer = "192.168.1.250"; |
| 28 | + config.mqttPort = 1883; |
| 29 | + config.mqttUser = ""; |
| 30 | + config.mqttPassword = ""; |
| 31 | + config.mqttClientID = "ESP32_Allsky_Display"; |
| 32 | + // ... rest of configuration |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +**Replace the empty strings with your WiFi credentials:** |
| 37 | + |
| 38 | +```cpp |
| 39 | +config.wifiSSID = "YOUR_WIFI_SSID"; // Your network name |
| 40 | +config.wifiPassword = "YOUR_WIFI_PASSWORD"; // Your network password |
| 41 | +``` |
| 42 | + |
| 43 | +### 2. Configure MQTT Settings (Optional) |
| 44 | + |
| 45 | +While in the same function, you can also pre-configure MQTT settings: |
| 46 | + |
| 47 | +```cpp |
| 48 | +config.mqttServer = "192.168.1.250"; // MQTT broker IP or hostname |
| 49 | +config.mqttPort = 1883; // MQTT port (usually 1883) |
| 50 | +config.mqttUser = ""; // MQTT username (if required) |
| 51 | +config.mqttPassword = ""; // MQTT password (if required) |
| 52 | +config.mqttClientID = "ESP32_Allsky_Display"; // Unique client ID |
| 53 | +``` |
| 54 | + |
| 55 | +### 3. Configure Default Image Sources (Optional) |
| 56 | + |
| 57 | +Open [`config.cpp`](config.cpp) and locate the `DEFAULT_IMAGE_SOURCES` array: |
| 58 | + |
| 59 | +```cpp |
| 60 | +const char* DEFAULT_IMAGE_SOURCES[] = { |
| 61 | + "https://i.imgur.com/EsstNmc.jpeg", // Default source 1 |
| 62 | + "https://i.imgur.com/EtW1eaT.jpeg", // Default source 2 |
| 63 | + "https://i.imgur.com/k23xBF5.jpeg", // Default source 3 |
| 64 | + "https://i.imgur.com/BysRDbf.jpeg", // Default source 4 |
| 65 | + "http://allskypi5.lan/current/resized/image.jpg" // Default source 5 |
| 66 | + // Add more image URLs here as needed (up to MAX_IMAGE_SOURCES = 10) |
| 67 | +}; |
| 68 | +``` |
| 69 | + |
| 70 | +**Replace these with your own image URLs:** |
| 71 | + |
| 72 | +```cpp |
| 73 | +const char* DEFAULT_IMAGE_SOURCES[] = { |
| 74 | + "http://your-allsky-server.com/resized/image.jpg", |
| 75 | + "http://your-camera2.com/image.jpg", |
| 76 | + // Add up to 10 total sources |
| 77 | +}; |
| 78 | +``` |
| 79 | + |
| 80 | +### 4. Compile and Upload |
| 81 | + |
| 82 | +1. **Arduino IDE**: Click the Upload button (→) in the toolbar |
| 83 | +2. **PlatformIO**: Run `pio run --target upload` |
| 84 | + |
| 85 | +### 5. Monitor Serial Output |
| 86 | + |
| 87 | +Open the Serial Monitor (115200 baud) to see: |
| 88 | +- WiFi connection status |
| 89 | +- Assigned IP address |
| 90 | +- Configuration loading status |
| 91 | +- System information |
| 92 | + |
| 93 | +### 6. Access Web Interface |
| 94 | + |
| 95 | +Once connected, the device will display its IP address in the serial output. Access the web interface at: |
| 96 | + |
| 97 | +``` |
| 98 | +http://[device-ip]:8080/ |
| 99 | +``` |
| 100 | + |
| 101 | +From here you can modify all settings without recompiling. |
| 102 | + |
| 103 | +## Important Notes |
| 104 | + |
| 105 | +### First Boot Behavior |
| 106 | + |
| 107 | +- If `config.wifiSSID` is empty, the device will start in Access Point mode |
| 108 | +- If `config.wifiSSID` is set, the device will attempt to connect to that network |
| 109 | +- After successful configuration via web interface, these hardcoded values are overridden by stored settings |
| 110 | + |
| 111 | +### Resetting to Manual Configuration |
| 112 | + |
| 113 | +To reset the device back to using your hardcoded credentials: |
| 114 | + |
| 115 | +1. Use the Factory Reset button in the web interface, OR |
| 116 | +2. Use the reset function in the web API, OR |
| 117 | +3. Erase flash memory using `esptool.py erase_flash` |
| 118 | + |
| 119 | +After reset, the device will use the credentials you set in `config_storage.cpp`. |
| 120 | + |
| 121 | +### Security Considerations |
| 122 | + |
| 123 | +**⚠️ WARNING**: Storing WiFi credentials in source code is not recommended for: |
| 124 | +- Shared code repositories (credentials will be visible in version control) |
| 125 | +- Multi-device deployments with different networks |
| 126 | +- Production environments |
| 127 | + |
| 128 | +For these scenarios, use the Access Point mode (default behavior) to configure each device individually. |
| 129 | + |
| 130 | +## Troubleshooting |
| 131 | + |
| 132 | +### Device Won't Connect to WiFi |
| 133 | + |
| 134 | +1. Verify SSID and password are correct (case-sensitive) |
| 135 | +2. Check that WiFi network is 2.4GHz (ESP32-P4 may not support 5GHz on all models) |
| 136 | +3. Ensure network is in range and operational |
| 137 | +4. Monitor serial output for connection errors |
| 138 | + |
| 139 | +### Can't Find IP Address |
| 140 | + |
| 141 | +1. Check your router's DHCP client list |
| 142 | +2. Look for device named "ESP32_Allsky_Display" or similar |
| 143 | +3. Serial monitor will display the IP address on successful connection |
| 144 | +4. Try accessing via mDNS: `http://allskyesp32.lan:8080/` (if supported by your network) |
| 145 | + |
| 146 | +### Need to Reconfigure WiFi |
| 147 | + |
| 148 | +If you need to change WiFi settings after deployment: |
| 149 | + |
| 150 | +**Option 1**: Use the web interface (Network settings page) |
| 151 | + |
| 152 | +**Option 2**: Factory reset and trigger Access Point mode: |
| 153 | +1. Access web interface |
| 154 | +2. Go to System settings |
| 155 | +3. Click "Factory Reset" |
| 156 | +4. Device will restart in AP mode for reconfiguration |
| 157 | + |
| 158 | +## Alternative: Access Point Mode (Recommended) |
| 159 | + |
| 160 | +Instead of manual configuration, consider using the automatic Access Point mode: |
| 161 | + |
| 162 | +1. Leave `config.wifiSSID` empty in `config_storage.cpp` |
| 163 | +2. Compile and upload firmware |
| 164 | +3. Device creates WiFi network: **AllSky-Display-Setup** |
| 165 | +4. Connect your phone/computer to this network |
| 166 | +5. Captive portal opens automatically |
| 167 | +6. Select your WiFi network and enter password |
| 168 | +7. Device connects and saves credentials |
| 169 | + |
| 170 | +See main [README](README.md) for detailed instructions on Access Point mode. |
0 commit comments