Skip to content

A DIY IoT-ready project supporting OTA updates, WebSocket logging, Wi-Fi setup, and local SPIFFS web hosting

Notifications You must be signed in to change notification settings

engperini/OTA-IOT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OTA-IOT (ESP32S3 + SPIFFS + OTA + WebSocket)

Firmware developed for ESP32-S3 supporting:

  • Firmware update via OTA (Over-The-Air)
  • Web interface hosted on SPIFFS
  • Real-time communication using WebSocket
  • Automatic upload of the file system before firmware upload
  • LED feedback for system status and OTA confirmation

This project serves as a base for IoT applications that require remote control, a local web interface, and OTA firmware updates.


โš™๏ธ Requirements


๐Ÿ“‚ Project Structure

OTA-IOT/
 โ”ฃ ๐Ÿ“‚ data/                โ†’ Files stored in the SPIFFS filesystem
 โ”ƒ โ”ฃ index.html            โ†’ Main dashboard: controls LED, displays logs, and system info.
 โ”ƒ โ”— wifi.html             โ†’ Wi-Fi setup page: allows users to enter SSID and password manually.
 โ”ฃ ๐Ÿ“‚ src/
 โ”ƒ โ”— main.cpp              โ†’ Main firmware source code
 โ”ฃ ๐Ÿ“„ extra_script.py       โ†’ Script to automatically upload SPIFFS before firmware
 โ”ฃ ๐Ÿ“„ platformio.ini        โ†’ PlatformIO configuration file
 โ”— ๐Ÿ“„ .gitignore

๐Ÿš€ How to Use

1๏ธโƒฃ Clone the repository

git clone https://github.com/engperini/OTA-IOT.git
cd OTA-IOT

2๏ธโƒฃ Open in VS Code

Open the project using VS Code with PlatformIO installed and wait for all dependencies to download automatically.


3๏ธโƒฃ Connect your ESP32-S3

Connect your device via USB cable โ€” the first upload must always be done via cable.
After this initial setup, all future updates can be done Over-The-Air (OTA).

Check that the device is detected as a serial port (e.g., COM7 or /dev/ttyUSB0).


4๏ธโƒฃ Build and upload

From PlatformIO's left sidebar menu, click Upload (arrow โ†’)
or use the terminal:

pio run -t upload

The extra_script.py ensures that SPIFFS is uploaded before the firmware.
Youโ€™ll see messages like:

=== Uploading SPIFFS before firmware ===
[SUCCESS] SPIFFS done!
[SUCCESS] Firmware upload complete!

First Boot (Wi-Fi not configured)

If this is your first time running the firmware, or if Wi-Fi credentials were erased, the ESP32-S3 will start in Access Point mode.

On your computer or phone, connect to the Wi-Fi network: ESP32-Setup

Open your browser and go to:

http://192.168.4.1

Youโ€™ll see the Wi-Fi setup page (wifi.html) where you can enter your network SSID and password.

After saving, the ESP32-S3 will reboot automatically and connect to your configured Wi-Fi.

5๏ธโƒฃ Access the web interface

After the upload, open the PlatformIO Serial Monitor:

pio device monitor

Youโ€™ll see something like:

Connected to WiFi!
IP Address: 192.168.1.45

Open a browser and navigate to your ESPโ€™s IP address:

http://192.168.1.45

๐Ÿ’ก The IP will vary depending on your local Wi-Fi network.


๐ŸŒ Web Interface

ESP32 Web Interface
Real-time control and OTA via browser

๐ŸŒ Features

index.html

This is the main dashboard page shown when accessing your ESPโ€™s IP address.
It provides:

  • LED control (turn ON/OFF);
  • Real-time system logs through WebSocket;
  • System information: internal temperature, Wi-Fi signal strength (RSSI), and uptime;
  • OTA firmware upload with progress bar;
  • Visual connection indicator (WebSocket status);
  • Remote reboot button.

๐ŸŒ Wifi Setup

ESP32 Wifi Setup
Initial Wifi Setup

wifi.html

This page handles Wi-Fi configuration and is useful when the device has no saved credentials.
It allows users to:

  • Scan and select nearby Wi-Fi networks;
  • Enter SSID and password manually;
  • Save and reboot the ESP32-S3 with new credentials.

This feature is ideal for Access Point (Hotspot) mode, automatically enabled if no Wi-Fi credentials and connection is detected on startup.


๐Ÿ”„ OTA Update

  1. Access your device via browser (e.g., http://192.168.1.45)
  2. Upload a new .bin file (generated during compilation)
  3. The LED will blink three times indicating success
  4. The ESP will automatically restart and run the new firmware

๐ŸŒ Esp32S3_XIAO

ESP32 Used
XIAO Sense Hardware


๐Ÿง  Automatic SPIFFS Upload (extra_script.py)

This script runs automatically before the firmware upload, ensuring your data/ files are always up to date.

Import("env")
from SCons.Script import DefaultEnvironment

def before_upload(source, target, env):
    print("=== Uploading SPIFFS before firmware ===")
    spiffs_env = DefaultEnvironment()
    spiffs_env.Replace(UPLOAD_PORT=env.get("UPLOAD_PORT"))
    spiffs_env.Replace(UPLOAD_SPEED=env.get("UPLOAD_SPEED"))
    spiffs_env.Execute("platformio run -t uploadfs")

env.AddPreAction("upload", before_upload)

โš™๏ธ platformio.ini Configuration

[env:xiao_esp32s3]
platform = espressif32
board = seeed_xiao_esp32s3
framework = arduino
monitor_speed = 115200
board_build.filesystem = spiffs
lib_deps = links2004/WebSockets@^2.7.1
extra_scripts = extra_script.py

๐Ÿ’ก Useful Tips

  • If the upload fails, disconnect and reconnect your ESP32-S3.
  • Ensure index.html and wifi.html are inside the data/ folder.
  • To manually update only the SPIFFS filesystem:
    pio run -t uploadfs
  • To open the serial monitor:
    pio device monitor

๐Ÿ“˜ Author

Developed by: engperini
License: MIT
Version: 1.1
Compatible with: ESP32-S3 (XIAO, DevKit, etc.)


โœจ A DIY IoT-ready project supporting OTA updates, WebSocket logging, Wi-Fi setup, and local SPIFFS web hosting.

โญ If you find this project useful, give it a star!
Your support helps me improve and share more IoT tools like this.

๐Ÿ”ฎ Future Improvements

Future versions of this project aim to extend its IoT capabilities beyond OTA control and monitoring.
A temperature and pressure sensor will be integrated to provide environmental data logging in real time.
Additionally, the firmware will support a low-power sleep mode that can be toggled directly from the web interface.
When enabled, the ESP32-S3 will wake up periodically, send sensor data at predefined intervals, and return to deep sleep โ€” optimizing power efficiency.
This feature will be particularly useful for remote or solar-powered deployments, where the device can operate autonomously using a 5V solar panel connected via USB, continuously charging the onboard battery while maintaining data transmission cycles.

About

A DIY IoT-ready project supporting OTA updates, WebSocket logging, Wi-Fi setup, and local SPIFFS web hosting

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published