Repolode
micropython

micropython/micropython

A lean Python 3 implementation that runs on microcontrollers and other resource-constrained devices, with hardware access modules.

Stars
22,139
Forks
9,013
Open issues
1,540
Last commit
2 days ago

What is it?

MicroPython is an implementation of Python 3 designed to run on microcontrollers and other constrained platforms. It implements most of the Python 3 syntax and core data types such as str, bytes, list, dict and set, along with common modules like os, sys, time, re and struct. Some ports also support threading, socket and ssl networking, and asyncio.

Beyond the standard language, MicroPython provides MicroPython-specific modules for hardware access, including GPIO, timers, ADC, DAC, PWM, SPI, I2C, CAN, Bluetooth and USB. Scripts can run as source .py files or as precompiled .mpy bytecode, from an on-device filesystem or frozen into the firmware.

The repository holds the core runtime, the mpy-cross compiler and more than twenty ports covering boards such as ESP32, Raspberry Pi RP2040/RP2350, STM32, SAMD and nRF, plus Unix, Windows and WebAssembly targets. Microcontroller targets can start at around 256 KiB flash and 16 KiB RAM.

Key features

  • 01Implements most of Python 3 syntax, including async/await and common core data types.
  • 02Provides hardware modules for GPIO, PWM, ADC, SPI, I2C, CAN, Bluetooth and USB.
  • 03Runs source .py scripts or precompiled .mpy bytecode, from a filesystem or frozen into firmware.
  • 04Offers more than twenty ports for microcontrollers, Unix, Windows and WebAssembly.
  • 05Includes the mpy-cross compiler for turning scripts into bytecode.

Use cases

  • Prototyping and programming ESP32, Raspberry Pi Pico or STM32 boards in Python.
  • Writing control logic for IoT sensors and devices with limited memory.
  • Running Python scripts on embedded Linux systems as a lightweight alternative to CPython.
  • Porting Python-based firmware to a new microcontroller using the minimal port as a starting point.

Quick start

  1. 1

    Enter the mpy-cross cross-compiler directory

    cd mpy-cross
  2. 2

    Build the mpy-cross cross-compiler

    make
  3. 3

    Enter the directory of the port you want to use (replace name with the port)

  4. 4

    Initialise the submodules required by that port

    make submodules

Things to know

  • Only a subset of Python 3 functionality is implemented, so not all standard library features work.
  • Port maturity varies, and Tier 3 ports are built in CI but not regularly tested by maintainers.

Topics

FAQ

What is micropython?
A lean Python 3 implementation that runs on microcontrollers and other resource-constrained devices, with hardware access modules. MicroPython is an implementation of Python 3 designed to run on microcontrollers and other constrained platforms. It implements most of the Python 3 syntax and core data types such as str, bytes, list, dict and set, along with common modules like os, sys, time, re and struct. Some ports also support threading, socket and ssl networking, and asyncio.
Is micropython free to use? What license does it have?
micropython is open source under the Other license. Check the license terms before using it in commercial products.
Is micropython still maintained?
Actively maintained. The last commit to micropython was on Oct 19, 2026.
What can I use micropython for?
Prototyping and programming ESP32, Raspberry Pi Pico or STM32 boards in Python. Writing control logic for IoT sensors and devices with limited memory. Running Python scripts on embedded Linux systems as a lightweight alternative to CPython. Porting Python-based firmware to a new microcontroller using the minimal port as a starting point.
How do I install micropython?
Enter the mpy-cross cross-compiler directory: cd mpy-cross Build the mpy-cross cross-compiler: make Enter the directory of the port you want to use (replace name with the port) Initialise the submodules required by that port: make submodules
Where can I get micropython?
The source code and installation instructions are on GitHub: https://github.com/micropython/micropython

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects