Skip to content

marinpopa/AsyncOTAManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AsyncOTAManager πŸ“‘

An Arduino library for ESP32/ESP8266 that provides an elegant web page for OTA (Over-The-Air) firmware and filesystem updates, with authentication and auto-detection.

License: MIT Platform: ESP32/ESP8266

✨ Features

🌐 Built-in OTA web page - compressed HTML interface (gzip)

πŸ”’ Optional authentication - protects update access

πŸ” Auto-detection - recognizes update type by file extension

πŸ“ Dual support - compatible with SPIFFS and LittleFS

πŸ”„ Backward compatibility - maintains old endpoints

⚑ Performance - uses ESPAsyncWebServer for async connections

πŸ“¦ Installation

Via Arduino IDE

Sketch β†’ Include Library β†’ Manage Libraries...

Search for "AsyncOTAManager"

Click Install

Manual Installation

Download the latest version from here

Extract to the Arduino IDE libraries folder

Restart Arduino IDE

πŸš€ Quick Start

#include <WiFi.h>
#include <AsyncOTAManager.h>

AsyncWebServer server(80);
AsyncOTAManager otaManager(server);

void setup() {
  Serial.begin(115200);
  
  // Connect to WiFi
  WiFi.begin("SSID", "password");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  
  Serial.println("\nConnected! IP: " + WiFi.localIP().toString());
  
  // Configure OTA
  otaManager.setAuthentication("admin", "password123"); // Optional
  otaManager.enableAutoDetect(true); // Enabled by default
  otaManager.begin("/update");
  
  server.begin();
}

void loop() {
  // Your main code
}

πŸ”§ API

Constructor

AsyncOTAManager(AsyncWebServer &server);

Main Methods

// Start OTA service
void begin(const char *path = "/update");

// Set authentication (optional)
void setAuthentication(const char *user, const char *pass);

// Enable/disable auto-detection
void enableAutoDetect(bool enable = true);

🌐 Available Endpoints

Endpoint Method Description
/ota GET OTA web upload page (default path)
/update POST Universal upload endpoint with auto-detection
/update-fw POST Legacy firmware upload endpoint
/update-spiffs POST Legacy SPIFFS upload endpoint
/update-littlefs POST LittleFS upload endpoint

Usage Examples:

  • Access http://[ESP_IP]/ota in your browser to see the upload page
  • Send POST request to http://[ESP_IP]/update with your .bin file
  • For compatibility, you can still use /update-fw and /update-spiffs

Authentication: All endpoints support optional HTTP Basic Authentication when configured.

🧠 Auto-Detection

The library automatically detects the update type based on file extension:

File Extension Update Type
.bin, .ino.bin Firmware
.spiffs.bin SPIFFS
.littlefs.bin LittleFS

πŸ“ Complete Example

#include <AsyncOTAManager.h>

// Create server and OTA manager
AsyncWebServer server(80);
AsyncOTAManager otaManager(server);

void setup() {
  Serial.begin(115200);
  
  // WiFi
  WiFi.mode(WIFI_STA);
  WiFi.begin("NetworkSSID", "NetworkPassword");
  
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  
  Serial.print("IP: ");
  Serial.println(WiFi.localIP());
  
  // Configure OTA
  otaManager.setAuthentication("admin", "securepass");
  otaManager.begin("/update"); // Change path if desired
  
  // Other server routes...
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "Hello! Go to /update for OTA");
  });
  
  server.begin();
  Serial.println("Server started. Access http://" + WiFi.localIP().toString() + "/update");
}

void loop() {
  // Run other tasks here
  delay(1000);
}

πŸ›  Requirements

Required Libraries

ESP Async WebServer

AsyncTCP (ESP32)

ESPAsyncTCP (ESP8266)

Supported Platforms

ESP32 (tested on ESP32 DevKit, NodeMCU-32S)

ESP8266 (tested on NodeMCU, Wemos D1 Mini)

πŸ“ Project Structure


AsyncOTAManager/
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ BasicOTA/
β”‚   β”‚   └── BasicOTA.ino
β”‚   └── SecureOTA/
β”‚       └── SecureOTA.ino
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ AsyncOTAManager.h
β”‚   β”œβ”€β”€ AsyncOTAManager.cpp
β”‚   └── ota_html_gz.h (generated separately)
β”œβ”€β”€ library.properties
β”œβ”€β”€ keywords.txt
β”œβ”€β”€ README.md
└── LICENSE

🀝 Contributions

Contributions are welcome! To contribute:

Fork the repository

Create a new branch (git checkout -b feature/new)

Commit your changes (git commit -am 'Add feature X')

Push to the branch (git push origin feature/new)

Open a Pull Request

πŸ“„ License

This library is licensed under the MIT License. See the LICENSE file for details.

πŸ™ Acknowledgments

ESPAsyncWebServer for the async web server

Arduino Core for ESP32/ESP8266 support

Made with ❀️ for the Arduino community πŸš€

About

OTA Update Manager with authentication and auto-detection for ESP32/ESP8266. Provides a web interface for Over-The-Air updates with support for SPIFFS/LittleFS filesystems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors