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 / functionUse
PinGPIO in, out, pull, IRQ
SignalPin with invert
PWMDuty and frequency. On all tier-1/2 MCU ports since 1.28, including STM32.
ADC / ADCBlockAnalogue in
DACAnalogue out, where the chip has it
I2C / SoftI2CTwo-wire bus
SPI / SoftSPIFour-wire bus
UARTSerial
I2SAudio, some ports
TimerPeriodic callbacks
RTCClock and alarms
WDTWatchdog
PWM / Counter / EncoderTiming and quadrature, growing set
CANCommon API from 1.28; STM32 first, other ports following
SDCardSD over SPI or SDIO
USBDeviceUSB device, some ports
soft_reset, reset, freq, unique_id, idle, lightsleep, deepsleepSystem

Network and radio

Language runtime

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.