MicroPython
v1.27.0Features
-
Implements Python 3.4 syntax including exceptions, ‘with’, and ‘yield from’ statements.
-
Supports ‘async’ and ‘await’ keywords from Python 3.5 for asynchronous programming.
-
Includes a core Python compiler and runtime that can execute scripts directly on-device.
-
Provides a cross-compiler (mpy-cross) to turn scripts into precompiled bytecode (.mpy) for faster execution.
-
Supports freezing Python scripts into the firmware executable to significantly reduce memory usage.
-
Offers hardware-specific modules for low-level control of GPIO, Timers, ADC, DAC, and PWM.
-
Includes built-in support for communication protocols including SPI, I2C, UART, CAN, and I2S.
-
Provides networking capabilities through dedicated socket, ssl, and network modules.
-
Supports multithreading on select hardware ports via the _thread module.
-
Includes a comprehensive asyncio implementation for cooperative multitasking.
-
Features an interactive REPL (Read-Eval-Print Loop) for real-time programming and debugging.
-
Supports on-device filesystems for script storage and data logging.
-
Provides specialized modules for Bluetooth (BLE) and USB Device functionality.
-
Allows extending the language with custom modules implemented in C via the extmod system.
-
Includes advanced hardware support for Pulse Counters and Quadrature Encoders on specific architectures.
-
Targets devices with as little as 256kiB flash and 16kiB RAM.
Architecture
MicroPython is designed with a highly modular architecture that separates the core Python language implementation from platform-specific hardware logic. The system is centered around the py/ directory, which contains the core compiler, runtime, and virtual machine (VM). This core is written in highly portable C and is responsible for parsing Python source code, generating bytecode, and managing the object model and garbage collection.
To support diverse hardware, MicroPython utilizes a Ports system. Each port (found in the ports/ directory) contains the glue code necessary to interface the core VM with a specific microcontroller’s Hardware Abstraction Layer (HAL) or an operating system. Additionally, the extmod/ directory provides optional C-based modules that implement non-core functionality, such as filesystem support, networking stacks, and specialized hardware protocols, ensuring that the core remains lean while allowing for feature-rich builds.
Core Components
- py/: The core Python implementation, including the compiler, runtime, and core library.
- mpy-cross/: A cross-compiler tool used to pre-compile Python scripts into bytecode for embedded execution.
- ports/: Platform-specific code for various architectures (e.g., STM32, ESP32, RP2).
- extmod/: Non-core modules implemented in C for performance and hardware access.
- lib/: Submodules for external dependencies and vendor-provided HALs.
Use Cases
This library is ideal for:
- IoT Development: Rapidly creating connected devices using high-level networking and security modules like
socket,ssl, andmqtt. - Rapid Prototyping: Using the interactive REPL to test hardware peripherals and logic in real-time without the need for a full compile-flash-reboot cycle.
- Education: Teaching Python programming and electronics simultaneously on affordable, physical hardware.
- Industrial Automation: Implementing complex control logic, sensor data processing, and communication protocols (CAN, Modbus) on robust microcontroller platforms.
- Embedded Scripting: Adding a user-accessible scripting interface to existing C/C++ projects by embedding the MicroPython engine.
- Low-Power Monitoring: Utilizing deep-sleep modes and hardware interrupts to create battery-operated sensor nodes.
Getting Started
To begin developing with MicroPython, the first step is typically to build the cross-compiler by running make within the mpy-cross/ directory. Following this, you can navigate to the specific port directory corresponding to your hardware (e.g., ports/stm32/) and run make submodules followed by make to generate the firmware image. Once flashed, the device provides a Read-Eval-Print Loop (REPL) over a serial connection, allowing for immediate Python command execution.
Comprehensive documentation, including API references for hardware-specific modules like machine and network, is available at the official MicroPython documentation site. For community support and project discussions, developers are encouraged to use the GitHub Discussions and the official Discord server.
Related Projects (97)
MicroPython SmartHome Node (pysmartnode)
A modular framework for deploying smart home nodes using MicroPython and MQTT. It provides standardized base classes for sensors and switches, supports Home Assistant MQTT discovery, and targets ESP32, ESP8266, and Unix platforms using asynchronous I/O.
MicroPython ST7789 LCD Driver
A high-performance MicroPython driver for ST7789 and compatible LCD displays, featuring support for hardware scrolling, custom fonts, and bitmap drawing. It is optimized for ESP32 and RP2040 microcontrollers and supports a wide range of display resolutions and color configurations.
Mocket
Mocket is a socket mocking framework for Python that monkey-patches the socket and ssl modules to intercept network traffic. It provides built-in support for HTTP, HTTPS, and Redis, and is compatible with asyncio, gevent, and MicroPython's urequests. It is primarily used as a testing utility to simulate network responses and record real socket traffic for playback.
ooFatFs - Object Oriented FatFs
An object-oriented modification of ChaN's FatFs Generic FAT File System Module. It enables the creation of multiple independent FAT filesystems by ensuring all functions take a pointer to the filesystem state as their first argument, facilitating integration with diverse drivers and filesystem types.
Picotui
Picotui is a minimalist Text User Interface (TUI) widget library for Python 3 and Pycopy. It provides a comprehensive set of widgets including dropdowns, menus, and dialogs without relying on the curses library. Designed with a 'Keep It Simple, Stupid' (KISS) philosophy, it is particularly well-suited for resource-constrained environments and minimalist Python implementations.
picoweb
A minimalist, asynchronous web micro-framework designed for the Pycopy Python implementation. It features a small memory footprint of approximately 36K heap and provides a Flask-like API for developing web applications on resource-constrained embedded systems and bare-metal platforms.
Pycopy Standard Library (pycopy-lib)
A modular standard library for the Pycopy project, providing CPython-compatible modules and optimized 'micro' versions for resource-constrained embedded systems. It supports both the Pycopy Unix port and bare-metal targets like the ESP8266, allowing for a flexible, lightweight Python environment.
Raspberry Pi Pico Web Server Control
A MicroPython-based web server framework for Raspberry Pi Pico, ESP8266, and ESP32 microcontrollers. It provides a browser-based interface to execute Python functions remotely, serve dynamic content, and manage files, with specific optimizations for memory-constrained devices.
μReflow Oven with MicroPython & LVGL
A PID-controlled reflow oven controller built for the ESP32 using MicroPython and the LVGL graphics library. It features a touch-screen interface for selecting solder profiles, real-time temperature monitoring via thermocouple amplifiers, and remote configuration via FTP.
SAMA5D27 Resource Sharing
A comprehensive resource repository for the Microchip SAMA5D27 Cortex-A5 MPU, providing extensive documentation and guides for Linux development, bare-metal programming, and various RTOS ports. It features in-depth tutorials for NuttX, RT-Thread, and ThreadX, including driver integration for LVGL, EtherCAT, and TensorFlow Lite.
Senko - OTA Updater for MicroPython
A lightweight Over The Air (OTA) update solution for MicroPython projects targeting ESP8266 and ESP32 microcontrollers. It synchronizes local files with remote GitHub repositories by comparing SHA1 hashes to ensure devices are running the latest code.
The MicroPython Board (pyboard)
The official hardware design repository for the MicroPython board (pyboard), a development platform based on the STM32F405RGT6 microcontroller. It provides the schematics, PCB layouts, and pinout diagrams for the reference hardware specifically optimized to run the MicroPython programming language.
TinyWeb
A lightweight, asynchronous HTTP server specifically designed for MicroPython environments on microcontrollers like the ESP8266 and ESP32. It leverages the uasyncio library to provide a non-blocking, single-threaded server with an API inspired by Flask, making it ideal for building modern web interfaces and RESTful services on IoT devices with limited RAM.
Trezor Firmware
The official firmware for Trezor hardware wallets, supporting both the Trezor Model T and Trezor One. It features a modular architecture including a MicroPython-based core for modern devices and a legacy C implementation, backed by custom cryptographic and storage libraries.
Tulip Creative Computer
A portable, self-contained computer powered by the ESP32-S3 and MicroPython, designed for music synthesis, graphics, and coding. It features a dedicated 120-voice synthesizer engine, multi-layer GPU support, and integrated LVGL for user interface elements. The system boots directly into a Python prompt, providing a distraction-free environment for creative programming.
uble: Lightweight Bluetooth Low Energy Driver for MicroPython
A pure Python Bluetooth Low Energy (BLE) driver designed for MicroPython environments. It enables parsing and building of HCI packets, specifically supporting the STMicroelectronics SPBTLE-RF module and BlueNRG-MS stack on platforms like the PyBoard.
wasp-os
Wasp-os is a MicroPython-based firmware for nRF52-powered smartwatches, including the Pine64 PineTime. It provides a complete wearable operating system with heart rate monitoring, step counting, and a variety of applications, all accessible via an interactive Python REPL for real-time development.
yaota8266 OTA Bootloader
An in-place over-the-air (OTA) update solution for the ESP8266 WiFi SoC designed for large firmwares on small flash devices. It features a dual-stage bootloader architecture with RSA-signed UDP updates, eliminating the need for redundant flash partitions.
EEZ Bench Box 3 (BB3) Modular Power Supply Platform
An open-source modular Test and Measurement platform centered around an STM32F769 ARM Cortex-M7 MCU. It provides a complete hardware and software framework for modular power supplies and data acquisition, supporting visual programming via EEZ Flow, SCPI commands, and MicroPython scripting.
MicroPython for Bare Metal Raspberry Pi
A bare-metal port of MicroPython for the Raspberry Pi Zero, Zero W, and Raspberry Pi 2. It enables running Python code directly on the hardware without an underlying operating system. The project includes drivers for USB host support and SD card access, allowing for a standalone Python environment on classic Raspberry Pi boards.
MicroPython for Monocle
A custom MicroPython firmware deployment specifically designed for the Monocle AR glasses. It integrates the Nordic nRF52832 SoC with support for Bluetooth LE, FPGA-driven displays, and camera modules using the LittleFS file system and Nordic SoftDevice.
MicroPython port for RT-Thread
A specialized port of MicroPython to the RT-Thread operating system, primarily targeting STM32F4 microcontrollers. It provides a seamless integration between the RT-Thread shell and the MicroPython REPL, allowing developers to control hardware and inspect RTOS internals using Python scripts.
MicroPython Rotary Encoder Driver
A robust, interrupt-driven MicroPython driver for reading rotary encoders on various development boards including ESP32, ESP8266, Pyboard, and Raspberry Pi Pico. It utilizes a state machine approach for effective debouncing and accurate tracking of encoder transitions.
MicroPython Samples and Drivers
A comprehensive collection of drivers, tutorials, and code samples for MicroPython targeting platforms like Pyboard, ESP32, ESP8266, and RP2040. It features advanced implementations for asynchronous programming, hardware interfacing, and data serialization.
MicroPython-STM-Lib
A collection of Python modules and drivers for MicroPython, specifically optimized for STM32F4-based hardware like the pyboard and STM32F4DISCOVERY. It provides essential utilities for rotary encoders, LCDs, MIDI communication, SPI flash memory, and networking, with support extending to ESP8266 and ESP32 ports.
MicroPython Stubs
A collection of over 3,000 stub files for MicroPython that provide type hinting, auto-completion, and static type checking for embedded development. It supports numerous ports and boards, including ESP32 and Raspberry Pi Pico, and integrates with major IDEs to streamline the MicroPython coding workflow.
MicroPython Stubber
A specialized toolset for generating PEP 484 type hint stubs for MicroPython firmware, enabling advanced IntelliSense and static analysis in modern IDEs. It supports a wide range of ports including ESP32, RP2040, and STM32, and facilitates the creation of stubs for custom firmware builds.
MicroPython Waveshare e-Paper Drivers
A collection of MicroPython drivers for various Waveshare e-Paper displays, supporting a wide range of screen sizes and color configurations. The library provides an interface for controlling these displays using SPI or UART on MicroPython-compatible hardware, including support for partial and full refreshes.
MicroPython-Wrap
A header-only C++ library that provides seamless interoperability between C++ and MicroPython. It automates the conversion of function arguments and return values between native types and the MicroPython object model, significantly reducing the boilerplate required to extend MicroPython with custom C++ modules.
micrOS
A MicroPython-based application execution platform and operating system designed for DIY projects and IoT devices. It provides a robust framework for managing asynchronous tasks, hardware interrupts, and cron-based scheduling on ESP32 and Raspberry Pi Pico W microcontrollers. With built-in shell and web servers, micrOS enables seamless remote management and device-to-device communication via WiFi and ESP-NOW.
MQBoard - MicroPython MQTT Micro-Framework
A micro-framework for managing MicroPython boards remotely via MQTT and asyncio. It provides a robust MQTT client, remote REPL access, OTA updates, and remote logging over a single encrypted connection, specifically optimized for ESP32 microcontrollers.
Mu - A Simple Python Code Editor
A cross-platform Python IDE specifically designed for beginner programmers and educators. It provides specialized modes for embedded development, including support for MicroPython, CircuitPython, and the BBC micro:bit, featuring integrated serial REPL and device flashing capabilities.
ulab: NumPy-like Array Manipulation for MicroPython
ulab is a high-performance, C-implemented numerical library for MicroPython and CircuitPython that provides a NumPy-like interface for array manipulation. It supports multi-dimensional ndarrays and advanced mathematical routines from NumPy and SciPy, optimized for resource-constrained embedded systems like STM32, ESP32, and RP2040.
Asynchronous Programming in MicroPython
A comprehensive resource for asynchronous programming in MicroPython using the asyncio library. It provides documentation, tutorials, synchronization primitives, and hardware drivers optimized for high performance on bare-metal microcontrollers.
Blynk Python Library
A Python and MicroPython library designed to connect IoT hardware to the Blynk Cloud. It provides an API for exchanging sensor data and controlling hardware peripherals like relays and motors from iOS and Android devices, specifically targeting Raspberry Pi and ESP-based microcontrollers.
LVGL MicroPython Bindings
Automatically generated MicroPython bindings for the LVGL graphics library, enabling high-level GUI development on microcontrollers. It features seamless integration with MicroPython's garbage collector, support for various display and touch drivers, and an automated API generation system for maintaining parity with the C library.
MaixPy Scripts
A comprehensive collection of MicroPython scripts for the MaixPy platform, targeting Sipeed hardware based on the Kendryte K210 RISC-V SoC. It includes examples for machine vision, AI acceleration, hardware peripheral control, and multimedia processing.
Microdot
Microdot is a minimalistic Python web framework inspired by Flask, specifically designed for resource-constrained environments like microcontrollers. It supports both CPython and MicroPython, offering a lightweight and extensible solution for building web applications and APIs on embedded hardware.
MicroMLP
A lightweight multilayer perceptron neural network library specifically designed for MicroPython environments on ESP32 and Pycom modules. It provides a single-file implementation of artificial neural networks with support for multiple activation functions, supervised learning, and Q-Learning for reinforcement learning tasks.
MicroPico Visual Studio Code Extension
A comprehensive development extension for Visual Studio Code tailored for MicroPython projects on Raspberry Pi Pico, ESP32, and Teensy 4.0. It provides an integrated REPL, automatic code completion via stubs, and streamlined file management for embedded microcontrollers.
MicroPython Camera Driver for ESP32
A specialized driver that adds OV2640 camera support to MicroPython for the ESP32 family. It enables high-resolution image capture by leveraging PSRAM and provides a Pythonic interface for controlling camera parameters like frame size, quality, and special effects.
micropython-esp32-ulp
An assembler toolchain for the ESP32 Ultra Low-Power (ULP) Co-Processor, implemented in MicroPython. It allows developers to write, assemble, and load ULP-FSM machine code directly on ESP32 microcontrollers without needing external cross-compilers. Supports the full instruction sets for ESP32, ESP32-S2, and ESP32-S3 variants.
MicroPython Examples for 01Studio Development Boards
A comprehensive collection of MicroPython examples and drivers tailored for 01Studio hardware. It supports a diverse range of platforms including ESP32, STM32, K210, and nRF52840, covering peripherals, wireless connectivity, and AI applications.
MicroPython Font Handling Utility
A comprehensive toolset for converting industry-standard font files into Python source code optimized for MicroPython. It enables high-performance text rendering on resource-constrained microcontrollers by utilizing frozen bytecode to minimize RAM consumption. The project includes a PC-based conversion utility and MicroPython classes for rendering text to various display hardware.
MicroPython for ESP32 with psRAM Support (LoBo Port)
A specialized MicroPython port for ESP32 microcontrollers with extensive support for external psRAM (SPIRAM) up to 16MB. Built as an ESP-IDF component, it features dual-core support, integrated hardware drivers, and advanced networking modules including MQTT, FTP, and GSM/PPPoS.
MicroPython for Kendryte K210 (LoBo Port)
A comprehensive MicroPython port for the Kendryte K210 64-bit RISC-V SoC, built upon the Kendryte FreeRTOS SDK. It features dual-core support, advanced multi-threading, and extensive peripheral drivers for displays, networking, and file systems.
MicroPython for Pandora IoT Board
A specialized MicroPython port for the RT-Thread Pandora IoT Board, powered by an STM32L475 microcontroller. It leverages the RT-Thread RTOS to provide a high-level Python development environment for IoT applications, featuring extensive hardware peripheral support and integrated networking.
MicroPython for Sparrow One Board
A MicroPython implementation for the Sparrow One IoT development board, built on the RT-Thread RTOS. It provides high-level Python APIs to control hardware peripherals including cameras, LCDs, WiFi, and audio components for rapid IoT application development.
MicroPython MAX7219 8x8 LED Matrix Library
A MicroPython driver for the MAX7219 8x8 LED matrix, supporting SPI communication and cascading multiple displays. It integrates with the native framebuf module to provide easy drawing of text, shapes, and animations on ESP32, ESP8266, and PyBoard platforms.
MicroPython MPU-9250 I2C Driver
A comprehensive MicroPython driver for the MPU-9250 9-axis motion tracking device, combining support for the MPU-6500 accelerometer/gyroscope and the AK8963 magnetometer. It provides high-level APIs for motion sensing, temperature readings, and magnetometer calibration over I2C.
MicroPython MPU9x50 IMU Driver
A comprehensive MicroPython library for InvenSense MPU9150, MPU9250, and MPU6050 sensors. It features a robust 3D vector class, sensor calibration tools, and support for vehicle-relative coordinate mapping, specifically optimized for the Pyboard and other MicroPython-compatible hardware.
MicroPython Sensor Fusion
A MicroPython implementation of the Madgwick sensor fusion algorithm for calculating orientation from IMU data. It provides both synchronous and asynchronous (uasyncio) interfaces for 6DOF and 9DOF sensors. Designed for high performance on microcontrollers like the Pyboard, it enables real-time tracking of heading, pitch, and roll.
HydraBus
HydraBus is an open-source multi-tool hardware platform designed for hardware hacking, debugging, and protocol analysis. It supports various firmware configurations including HydraFW, a MicroPython port, and the Black Magic Probe for JTAG/SWD debugging. The platform targets STM32 microcontrollers and provides a versatile interface for interacting with various hardware protocols.
Jupyter MicroPython Kernel
A Jupyter notebook kernel for interacting with MicroPython-based microcontrollers like the ESP8266 and ESP32. It supports serial REPL and WebREPL connections, enabling interactive coding, file transfers, and firmware flashing directly from a notebook environment.
MicroPython Plugin for PyCharm and IntelliJ
A specialized IDE plugin for PyCharm and IntelliJ IDEA that provides a complete development environment for MicroPython devices. It includes features for code completion, syntax checking, direct firmware flashing, and an integrated REPL for hardware like the ESP8266, PyBoard, and Raspberry Pi Pico.
SHA2017 Badge Firmware
The official firmware for the SHA2017 hacker camp badge, built on the Espressif ESP-IDF framework and FreeRTOS. It provides a robust platform featuring a MicroPython runtime, uGFX graphics support for E-ink displays, and integrated WiFi connectivity for the ESP32-based hardware.
Awesome CircuitPython
A curated collection of resources for CircuitPython, an Adafruit-supported fork of MicroPython designed for education and prototyping on microcontrollers. It provides a comprehensive directory of libraries, hardware support, tutorials, and community tools for the Python-on-hardware ecosystem.
Awesome Zephyr RTOS
A curated collection of high-quality resources, libraries, tools, and learning materials for the Zephyr RTOS ecosystem. It serves as a comprehensive directory for developers looking for official documentation, community-supported libraries, and hardware platforms compatible with Zephyr.
Blinker IoT Documentation
The official documentation repository for the Blinker IoT platform, providing comprehensive guides for connecting embedded devices to the cloud. It supports a wide range of hardware including ESP32, ESP8266, and Arduino, with SDKs for FreeRTOS, Python, and Node.js.
Broccoli
Broccoli is a distributed task queue framework designed for ESP32 clusters, enabling parallel task execution across multiple MicroPython-based nodes. Inspired by Celery, it provides a scalable way to manage workloads in embedded environments using a cluster of low-cost microcontrollers.
esp32-cam-micropython
A specialized MicroPython port for the ESP32-CAM module that integrates camera support directly into the firmware. It features a custom C-based camera module, support for LittleFS to optimize RAM usage, and includes various asynchronous web server examples for streaming video and capturing images.
ESP32 MPY-Jama
ESP32 MPY-Jama is a cross-platform desktop IDE and management tool designed for Espressif ESP32 microcontrollers running MicroPython. It provides a graphical interface for file management, real-time system monitoring, network configuration, and firmware flashing. The project simplifies IoT development by offering built-in 'Jama Funcs' for rapid testing of peripherals like sensors, LEDs, and displays.
LVGL Blog
The official blog repository for the LVGL (Light and Versatile Graphics Library) project, featuring technical articles, release notes, and hardware reviews. It serves as a community hub for sharing experiences, porting guides, and GUI development tips using LVGL on various embedded platforms.
MCUDev Black STM32F407VET6 MicroPython Support
This repository provides the board definition files required to run MicroPython on the MCUDev Black STM32F407VET6 development board. It includes hardware-specific configurations for the STM32F407VET6 MCU, onboard SPI Flash, SD card slot, and various peripheral headers.
MicroPython Encoder Menu
A lightweight, asynchronous menu system for MicroPython designed for rotary encoders and OLED displays. It provides a flexible framework for creating submenus, handling user input, and managing non-blocking tasks on platforms like the Raspberry Pi Pico and ESP32.
PyEspCar - MicroPython-ESP32 WIFI Car
PyEspCar is an open-source robotics platform based on the ESP32 and MicroPython, designed for computer vision and motion control education. It features a dual-layer metal chassis, a 2-DOF gimbal for camera mounting, and supports remote debugging via WebREPL and MQTT control.