|
1 | | -# Blynk-MicroPython-Edgent |
| 1 | + |
| 2 | +# Blynk.Edgent for MicroPython |
| 3 | + |
| 4 | +Blynk provides custom MicroPython builds specifically designed for IoT applications. |
| 5 | +These builds offer a standard MicroPython environment, enriched with numerous fixes, improvements, |
| 6 | +and additional features such as **secure Blynk.Cloud connection, device claiming and provisioning, OTA updates, configuration storage**, [and more](#features). |
| 7 | + |
| 8 | +## Getting Started |
| 9 | + |
| 10 | +- Sign up/Log in to your [Blynk Account](https://blynk.cloud) |
| 11 | +- Install **Blynk IoT App** for [iOS](https://apps.apple.com/us/app/blynk-iot/id1559317868) or [Android](https://play.google.com/store/apps/details?id=cloud.blynk) |
| 12 | + |
| 13 | +## 1. Install MicroPython + Blynk.Edgent |
| 14 | + |
| 15 | +<details> |
| 16 | + <summary>See instructions for <b>ESP32</b> based devices</summary></br> |
| 17 | + |
| 18 | +You can use [**ESP Launchpad**](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://blynk-fw-builds.fra1.cdn.digitaloceanspaces.com/Blynk-Edgent-MicroPython/latest/esp-quickstart.toml) to flash your device. You will need a Chrome-based browser. |
| 19 | + |
| 20 | +1. Plug your board into a USB port |
| 21 | +2. Click <kbd>Connect</kbd> in upper right corner and select your board |
| 22 | + - Recommended: click <kbd>Erase Flash</kbd> on the **DIY** tab |
| 23 | +4. Select **Application** (generic boards vs specialized builds) |
| 24 | +5. Select **Develop Kit** variant based on flash size and type |
| 25 | +6. Click the <kbd>Flash</kbd> button (if disabled, try clicking the `Connect` button again) |
| 26 | +7. Press <kbd>Reset</kbd> button on your board to run the MicroPython firmware |
| 27 | + |
| 28 | +> Alternatively, you can [flash your ESP32 device manually](https://github.com/Blynk-Technologies/Blynk-MicroPython-Edgent/releases/latest) |
| 29 | +
|
| 30 | +</details> |
| 31 | + |
| 32 | +<details> |
| 33 | + <summary>See instructions for <b>Raspberry Pi Pico W</b></summary></br> |
| 34 | + |
| 35 | +1. Hold down the <kbd>BOOTSEL</kbd> button while plugging the board into a USB port |
| 36 | +2. Copy the latest [UF2 firmware file](https://blynk-fw-builds.fra1.cdn.digitaloceanspaces.com/Blynk-Edgent-MicroPython/latest/RPI_PICO_W.uf2) to the USB mass storage device that appears |
| 37 | +3. Once programming of the new firmware is complete, the device will automatically reset and be ready for use |
| 38 | + |
| 39 | +</details> |
| 40 | + |
| 41 | +## 2. Connect your device to Blynk.Cloud |
| 42 | + |
| 43 | +1. Open **Blynk IoT App** on your smartphone |
| 44 | +2. Click **Add device** -> **Find devices nearby** |
| 45 | +3. Select your device and follow the setup instructions |
| 46 | + |
| 47 | +> [!NOTE] |
| 48 | +> If you have already created your device in Blynk, |
| 49 | +> you can [connect it manually using REPL](_extra/Cookbook.md#manual-device-connection) |
| 50 | +
|
| 51 | +## 3. Edit the default MicroPython app |
| 52 | + |
| 53 | +The [`main.py`](./main.py) is a simple `asyncio`-based script that defines the high level device operation. |
| 54 | +It could be as simple as this: |
| 55 | + |
| 56 | +```py |
| 57 | +from blynk import edgent |
| 58 | +from time import ticks_ms |
| 59 | +from asyncio import sleep_ms |
| 60 | + |
| 61 | +async def publisher_task(): |
| 62 | + while True: |
| 63 | + await sleep_ms(1000) |
| 64 | + edgent.publish("Uptime", ticks_ms()) |
| 65 | + |
| 66 | +edgent.run_asyncio_loop([ |
| 67 | + publisher_task() |
| 68 | +]) |
| 69 | +``` |
| 70 | + |
| 71 | +There are many ways to program your device. Here, we'll guide you through the two most popular options: |
| 72 | + |
| 73 | +- [ViperIDE for Web and Mobile](_extra/Workflow-ViperIDE.md) |
| 74 | +- [CLI using mpremote](_extra/Workflow-CLI.md) |
| 75 | + |
| 76 | +# Features |
| 77 | + |
| 78 | +- `blynk.inject` - BLE-assisted device claiming and provisioning |
| 79 | +- `blynk.air` - OTA updates using **Blynk.Console** and **Blynk.Apps** |
| 80 | +- `blynk.time` - Time Zone handling (including DST transitions), Sunrise/Sunset calculation |
| 81 | +- `blynk.repl` - Remote MicroPyhton REPL for Blynk Terminal |
| 82 | +- `netmgr` - Network management for `WiFi`, `Ethernet` and `Cellular` |
| 83 | +- `config` - System-wide configuration |
| 84 | +- `aiontp` - A versatile asyncio-based version of NTP client |
| 85 | +- `aioinput` - An asyncio variant of `input` function |
| 86 | +- `aioprof` - Asyncio [profiling tool](https://gitlab.com/alelec/aioprof) |
| 87 | +- `logging` - System-wide, preconfigured logging |
| 88 | +- `board` - A unified way to access the board peripherals |
| 89 | +- Factory reset function |
| 90 | +- Support for TLS certificate bundles |
| 91 | +- For `ESP32`: |
| 92 | + - `coredump` - Collect crash reports remotely |
| 93 | + - OTA updates for MicroPython system firmware |
| 94 | + |
| 95 | +# Further reading |
| 96 | + |
| 97 | +- [Cookbook](_extra/Cookbook.md) |
| 98 | +- [`asyncio` documentation](https://docs.micropython.org/en/latest/library/asyncio.html) |
| 99 | +- [`asyncio` tutorial](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/TUTORIAL.md) |
0 commit comments