{"id":13801993,"url":"https://github.com/rdehuyss/micropython-ota-updater","last_synced_at":"2025-05-13T12:32:09.643Z","repository":{"id":34622710,"uuid":"141485362","full_name":"rdehuyss/micropython-ota-updater","owner":"rdehuyss","description":"OTA Updater for MicroPython","archived":false,"fork":false,"pushed_at":"2022-03-09T04:29:43.000Z","size":38,"stargazers_count":373,"open_issues_count":9,"forks_count":86,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-08T03:53:12.190Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdehuyss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-18T20:15:13.000Z","updated_at":"2025-03-21T08:57:42.000Z","dependencies_parsed_at":"2022-09-05T21:01:31.549Z","dependency_job_id":null,"html_url":"https://github.com/rdehuyss/micropython-ota-updater","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdehuyss%2Fmicropython-ota-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdehuyss%2Fmicropython-ota-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdehuyss%2Fmicropython-ota-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdehuyss%2Fmicropython-ota-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdehuyss","download_url":"https://codeload.github.com/rdehuyss/micropython-ota-updater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253942524,"owners_count":21988072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:32.490Z","updated_at":"2025-05-13T12:32:09.389Z","avatar_url":"https://github.com/rdehuyss.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# MicroPython OTA Updater\n\nThis 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. \n\n\u003e 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\n\n## History\n- 2018/07/19 - First public release\n- 2020/12/23 - Major rewrite adding support for M5Stack and low memory devices (I now can upgrade big projects with it on devices like M5Stack Core 1 which are very memory constraint) and it now also supports secrets files (which are kept during upgrades)\n\n\n## Workflow\nThe workflow is as follows:\n* You have a github repo where you host your micropython project\n* In this project, you include all your source code in a certain folder (e.g. `app`)\n* You also include the ota_updater.py (https://github.com/rdehuyss/micropython-ota-updater)\n* You control your releases with GitHub releases (if you want to deploy a new version, create a new GitHub release)\n\nThere are now two different ways to update your code:\n\n### Install new version immediately after boot\nYou can choose to install a new version yourself. Note that due to memory limitations, this must happen first thing after boot.\n\nTo do so, make sure you have an active internet connection and use the following code at startup:\n```python\n@staticmethod\ndef _otaUpdate():\n    ulogging.info('Checking for Updates...')\n    from .ota_updater import OTAUpdater\n    otaUpdater = OTAUpdater('https://github.com/rdehuyss/chicken-shed-mgr', github_src_dir='src', main_dir='app', secrets_file=\"secrets.py\")\n    otaUpdater.install_update_if_available()\n    del(otaUpdater)\n```\n\n\u003e Do not forget to do a machine.reset() after the code above.\n\n\n### Let the OTAUpdater decide when to do the update\n* whenever you feel fit, you ask the OTAUpdater (on my project this is after a hardware interrupt which starts up the WLAN) to check for a new version using `ota_updater.check_for_update_to_install_during_next_reboot()`\n* if a new version is present, the OTAUpdater generate a `next` folder and within that folder a file called `.version_on_reboot`. After that, you do a `machine.reset()` to kill the WIFI connection.\n* You use the following code in your `main.py`:\n   ```python\n    from ota_update.main.ota_updater import OTAUpdater\n\n\n    def download_and_install_update_if_available():\n        o = OTAUpdater('url-to-your-github-project')\n        o.install_update_if_available_after_boot('wifi-ssid', 'wifi-password')\n\n\n    def start():\n        # your custom code goes here. Something like this: ...\n        # from main.x import YourProject\n        # project = YourProject()\n        # ...\n\n\n    def boot():\n        download_and_install_update_if_available()\n        start()\n\n\n    boot()\n   ```\n* the  OTAUpdater will check if there is a file called `next/.version_on_reboot`.\n  * If so, it will initialize the WIFI connection, download the latest code, move it to the `app` folder. You then need to do a `machine.reset()`. On reboot, the latest code will be in the `app` folder and you will be running the latest version.\n  * If not, it will NOT initialize the WIFI connection and just start the existing code in the `app` folder\n\n## Extra features\n### Support for Private Repositories\nThis module also adds support for private repositories. To do so, use it as follows:\n\n```python\ntoken='YOUR_GITHUB_TOKEN'\nupdater = OTAUpdater('https://github.com/sergiuszm/cae_fipy', headers={'Authorization': 'token {}'.format(token)})\n```\n\n### Support for secrets file\nMicroPython 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:\n\n```python\nWIFI_SSID='your-ssid'\nWIFI_PASSWORD='your-password'\n```\nSee [main.py](https://github.com/rdehuyss/micropython-ota-updater/blob/master/main.py) on how it is then used.\n\n\n## More info?\nSee the [article on Medium](https://medium.com/@ronald.dehuysser/micropython-ota-updates-and-github-a-match-made-in-heaven-45fde670d4eb).\n\n## Example\n- [Showerloop](https://github.com/rdehuyss/showerloop/blob/master/main.py) uses the micropython-ota-updater to get the latest release.\n- [Chicken Shed Mgr](https://github.com/rdehuyss/chicken-shed-mgr/blob/main/src/main.py) uses the micropython-ota-updater to get the latest release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdehuyss%2Fmicropython-ota-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdehuyss%2Fmicropython-ota-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdehuyss%2Fmicropython-ota-updater/lists"}