talira

MicroPython

Python for microcontrollers

open sourceMITfree

MicroPython is a lean implementation of Python 3 with a small subset of the standard library, written in C99 and optimised to run on the bare metal of microcontrollers in as little as 256k of code space and 16k of RAM. Flashed onto a board, it gives an interactive prompt (the REPL) and runs scripts from the board's own filesystem, with modules such as machine for the hardware. It has ports for ESP32, ESP8266, Raspberry Pi RP2040 and RP2350, STM32, SAMD, nRF, i.MX RT, Renesas RA, CC3200, PSoC and Alif chips, plus a Unix port that runs on a computer, and the mpremote tool manages a connected board's files and REPL over USB serial. Its official board is the pyboard.

Problems it solves

  • program a microcontroller in Python instead of C
  • try out a sensor interactively from a prompt on the board itself instead of compiling and flashing every change
  • run Python on a Raspberry Pi Pico or an ESP32
  • reuse what I know of Python to build an electronics project
  • teach kids to program hardware without making them learn embedded C
  • copy a script onto my board over USB and have it run at boot
  • manage the files on a microcontroller from my laptop's terminal
  • a small Python interpreter to embed in a device with only a few hundred kilobytes of flash
  • run Python code on a chip with 16KB of RAM

Features

  • Python 3 compiler and runtime that runs on the bare metal
  • interactive REPL with history, tab completion, auto-indent and paste mode
  • runs and imports scripts from the board's built-in filesystem
  • machine module and other hardware-specific modules
  • fits in 256k of code space and 16k of RAM
  • cross-compiler and frozen bytecode for pre-compiled scripts that use no RAM
  • native code emitter and inline assembler for Thumb and Xtensa
  • mpremote tool to manage a device's filesystem, REPL and scripts over a serial connection
  • Unix port that runs on Linux, BSD and macOS
  • multithreading via the _thread module on selected ports

Capabilities

Has a command line toolplan not known

Forks

  • CircuitPython A Python implementation for teaching coding with microcontrollers. Its own project since 2016.

Alternatives

The same job

These do what MicroPython does.

  1. CircuitPython A Python implementation for teaching coding with microcontrollers
  2. Espruino JavaScript for microcontrollers

Compare MicroPython with the top 3