Repo of the Day
kevinmcaleer/ota
Published: Feb 5, 2024
Open repository ↗Over The Air Updates for Micropython projects
Summary
The kevinmcaleer/ota repository is a MicroPython library that adds Over-the-Air (OTA) update support by polling a GitHub repository for a newer version.json value and pulling down a single named file when the remote version is higher than the local one. When an update is applied, the local file is overwritten and the MicroPython board is restarted. It is written in Python and is meant to run on MicroPython-compatible hardware rather than on a general-purpose computer.
What it is useful for
This library is useful for engineers deploying MicroPython firmware to devices that may be physically hard to reach after installation, such as sensors, controllers, or hobby boards tucked into enclosures around a home, lab, or workspace. It lets you iterate on device code by pushing changes to a GitHub branch and letting the device pick them up on the next boot, without having to plug in a USB cable each time. It also works as a check-and-update call invoked from inside your own application whenever it makes sense in your run loop, rather than only at startup.
How engineers can use it
The README documents a specific setup flow. Copy ota.py onto your MicroPython device and create a WIFI_CONFIG.py containing SSID and PASSWORD strings. In your main program import OTAUpdater and the credentials, set firmware_url to a raw.githubusercontent.com URL for the GitHub user, repository, and branch you want to monitor, construct the updater with that URL plus a target file name, and call download_and_install_update_if_available():
ota_updater = OTAUpdater(SSID, PASSWORD, firmware_url, "test.py")
ota_updater.download_and_install_update_if_available()
On the GitHub side, add a version.json file with a version integer, for example {"version": 3}. The library creates a local version.json with a value of 0 if one does not exist, so a freshly flashed device will always pick up the first published version.
The README does not document supported boards, behavior on failed downloads, code signing or integrity verification, or a license. The example only updates one file passed to the constructor ("test.py" in the snippet), so updating multiple files is not covered in the documented usage. Review the source of ota.py and the README before relying on it for production devices.