Libraries
Three layers: Python standard-library names that MicroPython implements, MicroPython-specific modules, and port-specific modules. Third-party drivers live under resources.
Hardware — machine
The portable hardware API. Not every class exists on every port; the device page says which ones you get.
| Class / function | Use |
|---|---|
Pin | GPIO in, out, pull, IRQ |
Signal | Pin with invert |
PWM | Duty and frequency. On all tier-1/2 MCU ports since 1.28, including STM32. |
ADC / ADCBlock | Analogue in |
DAC | Analogue out, where the chip has it |
I2C / SoftI2C | Two-wire bus |
SPI / SoftSPI | Four-wire bus |
UART | Serial |
I2S | Audio, some ports |
Timer | Periodic callbacks |
RTC | Clock and alarms |
WDT | Watchdog |
PWM / Counter / Encoder | Timing and quadrature, growing set |
CAN | Common API from 1.28; STM32 first, other ports following |
SDCard | SD over SPI or SDIO |
USBDevice | USB device, some ports |
soft_reset, reset, freq, unique_id, idle, lightsleep, deepsleep | System |
Network and radio
network—WLAN,LAN,PPPdepending on the chip.socket— BSD-like, often IPv4 only.ssl— TLS when the build includes mbedtls.bluetoothandaioble— BLE on chips that have a radio stack.espnow— ESP-specific peer radio.
Language runtime
asyncio— cooperative tasks; the usual way to wait on pins and sockets together.micropython—const,native,viper,mem_info,schedule,kbd_intr.gc,sys,os/vfs,io,struct,array,json,re,binascii,hashlib,random,select,time,errno,collections.uctypes— C-like memory overlays.framebuf— small framebuffer for monochrome displays.weakref— from 1.28 on builds that include it.
Port extras have their own names: rp2, esp32, esp, stm, pyb (legacy pyboard API), nrf, zephyr. Prefer machine when both exist.
micropython-lib
Modules that are not frozen into every firmware live in micropython-lib. Install with mip (mpremote mip install collections) when the board has a network, or copy the files. Licences vary per package — do not assume MIT.