Home

Awesome

MicroPython OTA Updater

This micropython module allows for automatic updating of your code on Microcontrollers using github releases. It allows you to update devices in the field with ease.

Note: due to a bug in the SSL library of ESP8266 devices, micropython-ota-updater cannot be used on these devices. See https://github.com/rdehuyss/micropython-ota-updater/issues/6 and https://github.com/micropython/micropython/issues/6737

History

Workflow

The workflow is as follows:

There are now two different ways to update your code:

Install new version immediately after boot

You can choose to install a new version yourself. Note that due to memory limitations, this must happen first thing after boot.

To do so, make sure you have an active internet connection and use the following code at startup:

@staticmethod
def _otaUpdate():
    ulogging.info('Checking for Updates...')
    from .ota_updater import OTAUpdater
    otaUpdater = OTAUpdater('https://github.com/rdehuyss/chicken-shed-mgr', github_src_dir='src', main_dir='app', secrets_file="secrets.py")
    otaUpdater.install_update_if_available()
    del(otaUpdater)

Do not forget to do a machine.reset() after the code above.

Let the OTAUpdater decide when to do the update

Extra features

Support for Private Repositories

This module also adds support for private repositories. To do so, use it as follows:

token='YOUR_GITHUB_TOKEN'
updater = OTAUpdater('https://github.com/sergiuszm/cae_fipy', headers={'Authorization': 'token {}'.format(token)})

Support for secrets file

MicroPython OTA updater now also supports a secret file (which is added to .gitignore). This secrets file must be installed initially (e.g. using USB) and will always be kept when downloading newer versions. In my case, it contains the WIFI credentials and other secret stuff. A secrets file can be used as follows:

WIFI_SSID='your-ssid'
WIFI_PASSWORD='your-password'

See main.py on how it is then used.

More info?

See the article on Medium.

Example