Minimal OTA (Over-The-Air) update example for ESP32 @filter: (platform is esp32)
This example demonstrates the FastLED OTA functionality for ESP32 devices. It provides both Arduino IDE OTA and web-based firmware updates.
PLATFORMIO REQUIREMENTS: Add these lines to your platformio.ini:
[env:esp32] platform = espressif32 board = esp32dev framework = arduino lib_deps = fastled/FastLED upload_protocol = esptool ; or 'espota' for OTA uploads upload_port = <device>.local ; replace <device> with your hostname for OTA uploads monitor_speed = 115200
FEATURES:
- One-line setup for Wi-Fi (async mode)
- Arduino IDE OTA support (port 3232)
- Web-based OTA at http://<hostname>.local/
- mDNS hostname registration
- Progress/error callbacks
- Low overhead: ~73µs per poll() when idle
- Non-blocking Wi-Fi connection with visual feedback
USAGE:
- Configure Wi-Fi credentials below
- Upload via USB initially
- Access web interface at http://my-device.local/
- Or use Arduino IDE OTA (Tools > Port > <hostname>)
SECURITY:
- Web UI uses Basic Auth (username: "admin", password: OTA_PASS)
- Arduino IDE OTA uses MD5 hashed password
- Use only on trusted networks or configure HTTPS
TROUBLESHOOTING:
- Cannot find device at <hostname>.local
- Check that device is on same network as your computer
- Some routers block mDNS/Bonjour - try device IP address instead
- Windows: Install Bonjour service (comes with iTunes or Apple apps)
- Linux: Install avahi-daemon for mDNS support
- Alternative: Check serial monitor for IP address and use that
- Arduino IDE cannot see OTA port
- Wait ~30 seconds after device boots for mDNS registration
- Verify firewall allows UDP port 3232 and mDNS port 5353
- Check Arduino IDE > Tools > Port menu - device may show as network port
- Try restarting Arduino IDE to refresh port list
- Web interface shows "401 Unauthorized"
- Username is "admin", password is value of OTA_PASS
- Browser may cache credentials - try private/incognito window
- Clear browser auth cache or try different browser
- OTA upload fails or times out
- Verify firmware file is valid .bin for ESP32
- Check that device has enough free flash space
- Ensure stable power supply (USB power may brownout during flash)
- Try smaller firmware or disable debug symbols to reduce size
- Check serial monitor for error messages during upload
- Wi-Fi connection fails
- Verify SSID and password are correct (case-sensitive)
- Check Wi-Fi band: ESP32 only supports 2.4GHz (not 5GHz)
- Some ESP32 boards have external antenna - verify antenna connected
- Move device closer to router to test signal strength
- Check serial monitor for Wi-Fi error codes
- Device reboots during OTA update
- Power supply issue - use quality USB cable and power source
- Add capacitor (100-1000µF) between VIN/3.3V and GND
- Reduce LED count or brightness during OTA to lower current draw
- ESP32-C3 compilation fails with "assembler not found"
- Performance: LED animations stutter or slow
- poll() overhead is <0.5% at 60 FPS (~73µs per call)
- If stuttering occurs, reduce FastLED.show() call frequency
- Web server runs in separate task (zero main loop impact)
- Consider moving LED code to separate FreeRTOS task for isolation
- Network setup guidance
- ESP32 variants (ESP32, S3, S2, C3, C6): All support Wi-Fi
- Ethernet users: Initialize ETH manually, then call ota.begin()
- Example: ETH.begin(/* PHY config */); while(!ETH.linkUp()) delay(100); ota.begin(...);
Definition in file OTA.ino.