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

GPIO / Pin

pymcu.hal.gpio

Digital I/O, pin interrupts

UART

pymcu.hal.uart

Serial communication

ADC

pymcu.hal.adc

Analog-to-digital conversion

Timer

pymcu.hal.timer

Hardware timers

PWM

pymcu.hal.pwm

Pulse-width modulation

SPI

pymcu.hal.spi

SPI bus (hardware + soft)

I2C

pymcu.hal.i2c

I2C bus (hardware + soft)

EEPROM

pymcu.hal.eeprom

Non-volatile byte storage

Watchdog

pymcu.hal.watchdog

Watchdog timer

Power / Sleep

pymcu.hal.power

Sleep modes

Time / Delays

pymcu.time

Busy-wait delays

Device drivers#

Driver

Import path

Description

DHT11

pymcu.drivers.dht11

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.