Skip to content

Implementation of OTA for remote monitoring and control of IoT device

License

Notifications You must be signed in to change notification settings

raghulrajg/OTAUpdateManager

Repository files navigation

OTAUpdateManager

Implementation of OTA for remote monitoring and control of IoT devices

arduino-library-badge

Manage PRs

PlatformIO Registry

ESP8266

ESP32 ESP32 ESP32

This works with the ESP8266 Arduino platform

https://github.com/esp8266/Arduino

This works with the ESP32 Arduino platform

https://github.com/espressif/arduino-esp32

Contents

How It Works

  • When your ESP (Espressif Systems' microcontroller) starts up, it attempts to connect to a previously saved Access Point (AP) in Station mode. If the ESP fails to connect (either because no previous network is saved or the connection attempt is unsuccessful), it switches to Access Point mode. In this mode, the ESP sets up a DNS server and a WebServer with a default IP address of 192.168.4.1.

Initial Startup in Station Mode:

  • The ESP tries to connect to a saved Access Point.
  • If the connection is unsuccessful or no network is saved, the ESP switches to Access Point mode.
  • The ESP creates its own Wi-Fi network.
  • The default IP address for this network is 192.168.4.1.
  • Any Wi-Fi enabled device (computer, phone, tablet) can connect to this network using a web browser.

User Connection:

  • Connect your device to the newly created Access Point.
  • Manually enter the network name (SSID) and password.

MQTT Connection:

  • The ESP can connect to an MQTT server to check for updates and maintain a live connection.
  • This connection allows for monitoring the live online state and managing updates.

Web Application:

  • Use the web application to check the live online state.
  • Upload new code to the ESP board through the update section.

How It Looks

ESP8266/ESP32 modules OTA update and monitoring using website. Homepage user dashboard program editor

Quick Start

Installing

You can either install through the Arduino Library Manager or checkout the latest changes or a release from github

Install through Library Manager

Using

  • Include in your sketch
#include <OTAUpdateManager.h>          
  • setup function add

  • In APN mode, the OTAUpdateManager is initialized with the following parameters:

OTAUpdateManager(User, Token, ApnOn, apName, apPassword);
  • User: The userid for authentication.

  • Token: The token for secure access.

  • ApnOn: A flag indicating that APN mode is active.

  • apName: The name of the Access Point.

  • apPassword: The password for the Access Point

  • In WiFi mode, the OTAUpdateManager is initialized with the following parameters:

OTAUpdateManager(User, Token, WiFiOn, SSID, Password);
  • User: The userid for authentication.

  • Token: The token for secure access.

  • ApnOn: A flag indicating that APN mode is active.

  • SSID: The SSID of the WiFi network.

  • Password: The password for the WiFi network.

  • if we want to use default

OTAUpdateManager(User, Token);
  • User: The userid for authentication.
  • Token: The token for secure access.

Also see examples.

Documentation

Server connection configuration

Connecting to the Web Application:

Token Configuration:

  • In the Token section, a default token is created.
  • Copy the UserID and Token from this section.

Example Code Integration:

  • Paste the UserID and Token into your example code.
  • Set your connection method to either manual WiFi or APN.

Upload Program:

  • Upload the program to the ESP.
  • The ESP will connect to the MQTT server and send packets to keep the connection alive.

OTA Update Process

Update Detection:

  • The server will notify the ESP when an update is available.
  • The ESP receives a payload to prepare for the update.

Update Execution:

  • Once the update process is initiated, the ESP will start updating.
  • The update status can be monitored on the website in the status section.