FastLED 3.9.15
Loading...
Searching...
No Matches
OTA.ino File Reference

Detailed Description

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:

  1. Configure Wi-Fi credentials below
  2. Upload via USB initially
  3. Access web interface at http://my-device.local/
  4. 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:

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. ESP32-C3 compilation fails with "assembler not found"
  8. 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
  9. 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.

#include <Arduino.h>
#include <FastLED.h>
#include "fl/net/ota.h"
#include "fl/stl/sstream.h"
+ Include dependency graph for OTA.ino:

Go to the source code of this file.

Macros

#define DATA_PIN   2
 
#define NUM_LEDS   60
 
#define USE_WIFI   1
 

Functions

void loop ()
 
void setup ()
 

Variables

static const char * HOSTNAME = "my-device"
 
uint8_t hue = 0
 
CRGB leds [NUM_LEDS]
 
fl::net::OTA ota
 
static const char * OTA_PASS = "supersecret"
 
bool wifi_connected_notified = false
 
static const char * WIFI_PASS = "MyPass"
 
static const char * WIFI_SSID = "MySSID"