PROVIDER - a compact Python 3 runtime for microcontrollers
MicroPython
MicroPython was crowdfunded in 2013 to bring Python 3 syntax and a REPL into microcontrollers with around 256KB of RAM, covering more than 10 families including ESP32 and RP2040; it turns hardware debugging interactive, at the cost of speed, memory limits and port differences.
Detailed Notes
Pros 5 items
Cons 4 items
Service Overview
MicroPython was started in 2013 by Damien George through a crowdfunding campaign to put full Python 3 syntax on microcontrollers. It is not an interpreter running on Linux but a small runtime written for bare metal: it carries its own garbage collector, frozen bytecode and hardware abstraction layer and boots on chips with tens to hundreds of kilobytes of RAM.
For the languages and frameworks category it changes how hardware work feels: opening a serial REPL lets you probe pins and read sensors line by line instead of compiling and flashing after every edit.
Key Strengths
- Interactive loop: verify pin behaviour in the REPL and cut the debug cycle from minutes to seconds
- Real Python syntax: functions, classes, exceptions, generators and slicing all work, so Python skills transfer directly
- Consistent hardware layer:
machine.Pin,machine.I2Candmachine.PWMbehave similarly across more than 10 MCU families - Simple firmware model: a single .uf2 or .bin file dropped onto a drive or flashed with one command
- Escape hatch to C: performance-critical parts can be written as C modules and frozen into the firmware
Product Ecosystem
Ports and boards
Official ports for ESP32 series, RP2040 (Pico), STM32, nRF52, MIMXRT and ESP8266; the pyboard is the reference board.
Tooling
mpremote, esptool, the Thonny IDE and rshell handle flashing, file sync and REPL access.
Libraries
Built-in machine, network and bluetooth modules, with community libraries copied onto the device as .py files.
Limitations
- Performance and memory are constrained: interpretation plus GC pauses force hard real-time loops into C
- Peripheral coverage is partial: niche sensors, CAN and USB Host often require a custom firmware build
- Port behaviour varies between chips and release versions
- Debugging is limited to prints and the REPL, with no breakpoints or profilers
Use Cases
- IoT prototypes and teaching (★★★★★): wire, script and connect to Wi-Fi in one sitting
- Sensor logging with upload (★★★★): network and JSON handling are far easier than in C
- Hardware bring-up (★★★★): REPL probing of pins and timing
- Hard real-time and production firmware (★★): use C, C++ or Rust on bare metal
Pricing
| Item | Price | Notes |
|---|---|---|
| MicroPython firmware | $0 | Open source under MIT, free to flash and redistribute |
| Development boards | Per model | ESP32 and Pico boards span a wide range |
| Commercial support | Contract | Some vendors offer custom firmware and support |
Software costs nothing; budget hardware and learning time, and check boot time and memory before volume production.
FAQ
- How does it relate to CircuitPython? CircuitPython is Adafruit's fork focused on education and plug-and-play behaviour; MicroPython stays closer to a general embedded runtime.
- Can you use the standard library? Only the trimmed ports:
os,time,jsonandsockethave subsets, whilenumpyandrequestsare unavailable and need replacements. - How much slower is it? Typically an order of magnitude versus C at the same clock, though I/O-bound and networked workloads narrow the gap; move hot paths into C modules. Compare Arduino and ESP-IDF under languages and frameworks.
Code Examples
Blink from the REPL
from machine import Pin
import time
led = Pin(25, Pin.OUT) # onboard LED on RP2040 Pico
for i in range(5):
led.toggle()
time.sleep_ms(300)
Paste it into the REPL and it runs immediately with no compilation step.
Read an I2C sensor and publish JSON
from machine import Pin, I2C
import time, json
i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400_000)
print("devices:", [hex(a) for a in i2c.scan()])
def read_temp(addr=0x48):
raw = i2c.readfrom_mem(addr, 0x00, 2)
value = ((raw[0] << 8) | raw[1]) >> 4
return value * 0.0625
while True:
print(json.dumps({"temp_c": read_temp()}))
time.sleep(2)
Scan for addresses first, then read registers; this order isolates wiring problems fastest.
Community & Resources
- MicroPython: firmware downloads, board support and docs
- MicroPython docs: library reference, port differences and porting guide
- GitHub MicroPython topic: sample projects and community libraries
- GitHub ESP32 topic: firmware and project references for common chips
- CircuitPython: education-oriented fork and board list
- Adafruit Learn: hardware tutorials that can be followed directly