PyMCU Libraries#
Architectural Shift: MicroPython Compatibility
PyMCU’s standard library is being restructured. The official user-facing API will soon be aligned with the MicroPython / CircuitPython machine and board modules.
The modules documented below (pymcu.hal.* and pymcu.drivers.*) are considered internal foundations (HAL). While they work perfectly, they are designed to be wrapped by the upcoming compatibility layers. Users are strongly encouraged to use the machine module (when available) for better portability across different hardware.
The PyMCU internal library provides hardware abstraction layer (HAL) modules and device drivers. All modules compile to tight native machine code — there is no Python runtime on the device.
Internal HAL modules#
Module |
Import path |
Description |
|---|---|---|
|
Digital I/O, pin interrupts |
|
|
Serial communication |
|
|
Analog-to-digital conversion |
|
|
Hardware timers |
|
|
Pulse-width modulation |
|
|
SPI bus (hardware + soft) |
|
|
I2C bus (hardware + soft) |
|
|
Non-volatile byte storage |
|
|
Watchdog timer |
|
|
Sleep modes |
|
|
Busy-wait delays |
Device drivers#
Driver |
Import path |
Description |
|---|---|---|
|
Temperature and humidity sensor |
Design principles#
All HAL classes are @inline — they have zero SRAM cost. Instantiating a Pin or UART
compiles to register writes; no struct is allocated on the MCU. See Type System
for details on the Zero-Cost Abstraction model.