MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a subset of its standard library and is optimized to run on microcontrollers and in constrained environments. It is designed to make programming digital electronics and IoT devices as simple and accessible as possible.
MicroPython allows developers to swiftly construct IoT applications using its straightforward syntax and interactive development environment, making it perfect for educational use, DIY projects, and rapid prototyping. Additionally, it maintains a level of reliability that suits professional settings.
Moreover, since MicroPython application code is very compact, it provides an excellent solution
for OTA updates over bandwidth-constrained networks like Cellular
, LoRaWAN
or Satellite
.
This example was verified to work with MicroPython v1.22.2
on:
ESP32
,ESP32-C3
,ESP32-S3
ESP8266
¹Raspberry Pi Pico W
(RP2040)Linux
(SBCs likeRaspberry Pi
,Orange Pi
, etc)
¹ insecure TCP connection only
- Create Blynk template based on the provided blueprint. Click the
Use Blueprint
button inMQTT Air Cooler/Heater Demo
. - In the left panel, select
Devices
- Click
New Device
button - Select
From Template -> MQTT Demo
, and clickCreate
Note
Please note the device credentials that appear in the upper right corner. You'll need them in the next step.
https://micropython.org/download
Set your WiFi and Blynk device credentials.
Make sure your board is connected via USB. It should not be opened by any serial monitor. Run these commands on your development machine:
# Install mpremote utility
pip3 install --upgrade mpremote
# Install libraries
mpremote cp -r ./lib :
# Copy the example files to the device
mpremote cp *.py *.der :
Reset you board and open MicroPython REPL:
mpremote repl
The device should get connected in a few seconds:
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/
Connecting to WiFi_SSID... OK: 192.168.1.123
Connecting to MQTT broker...
Connected to Blynk.Cloud [secure]
This will also work on Linux-based PCs or SBCs like Raspberry Pi:
micropython main.py
- Blynk MQTT API documentation
asyncio
documentationasyncio
tutorialmpremote
documentation- Alternative MQTT libraries like mqtt_as
- Blynk Troubleshooting guide
- Blynk Documentation