micropython-OTAUpdateManager

Implementation of OTA for remote monitoring and controlling of IoT devices


Keywords
OTA, OTAUpdateManager, Update, Microcontroller, Micropython
License
GPL-3.0
Install
pip install micropython-OTAUpdateManager==1.0.0

Documentation

OTAUpdateManager

Implementation of OTA for remote monitoring and control of IoT devices

micropython

ESP8266

ESP32 ESP32 ESP32

Contents

How It Works

User Connection:

  • 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.

  • 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

Installing with mip

Py-file

import mip
mip.install('github:raghulrajg/MicroPython-OTAUpdateManager/OTAUpdateManager.py')

To install using mpremote

    mpremote mip install github:raghulrajg/MicroPython-OTAUpdateManager

To install directly using a WIFI capable board

    mip.install("github:raghulrajg/MicroPython-OTAUpdateManager")

Installing Library Examples

If you want to install library examples:

    mpremote mip install github:raghulrajg/MicroPython-OTAUpdateManager/examples.json

To install directly using a WIFI capable board

    mip.install("github:raghulrajg/MicroPython-OTAUpdateManager/examples.json")

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI <https://pypi.org/project/MicroPython-OTAUpdateManager/>_. To install for current user:

    pip3 install MicroPython-OTAUpdateManager

To install system-wide (this may be required in some cases):

sudo pip3 install MicroPython-OTAUpdateManager

To install in a virtual environment in your current project:

    mkdir project-name && cd project-name
    python3 -m venv .venv
    source .env/bin/activate
    pip3 install MicroPython-OTAUpdateManager

Also see examples.

Using

This library provides a OTA update 1. handling code updates during boot (OTAUpdateManager)

Put the file name is called main.py

import OTAUpdateManager

#Avoid the GPIO pin number 2 because of predefine pin
#create your User ID and Token in https://ota.serveo.net/

#server connection config
User = b"YOUR_USER_ID"
Token = b"YOUR_TOKEN"

#WiFI Network connection config
SSID = "YOUR_APN_NAME"
Password = "YOUR_APN_PASSWORD"

OTAUpdate = OTAUpdateManager.espFOTA(User, Token, SSID, Password)

def loop():
    while True:
        #Put your code here
        OTAUpdate.run()

if __name__ == '__main__':
    loop()

Here's the provided main.py file, which includes configuration details for connecting to a Wi-Fi network and checking for OTA (Over-the-Air) updates using a user ID and token. You need to fill in your actual Wi-Fi credentials, user ID, and token.

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.