Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

What is MicroPython?

By Nikhil Agnihotri March 30, 2022

MicroPython implements the Python 3 programming language for microcontrollers and microcomputers. It is a firmware solution designed to implement high-level language features of Python into low-level hardware platforms. The firmware is optimized to run in constrained environments while allowing a small subset of Python 3 standard libraries into embedded programming.

MicroPython firmware can run in a footprint of 256 Kilobytes and  16 Kilobytes of RAM. MicroPython can offer several high-level programming features like arbitrary precision integers, object-oriented programming, generators, closures, exception handling, and list comprehension, even with such limited code space and memory. Usually, such features are not available in typical microcontroller programming. All these features are available with access to low-level hardware via the machine module of the MicroPython firmware.

Plus, MicroPython compiler and runtime code includes an interactive prompt called REPL (Read-Eval-Print-Loop) that allows executing commands from a desktop computer directly on an embedded platform. The commands using REPL are executed via UART, where the target microcontroller board is connected to the host PC over USB. This is useful in quick and real-time testing and debugging of embedded systems.

One of the notable high-level language features allowed in MicroPython is multithreading. Typically, bare metals are void of multithreading capabilities. The multithreading feature of MicroPython firmware allows speeding up embedded applications by handling many embedded tasks simultaneously from a single microcontroller and lets you think out of the typical programming loops.

MicroPython is open source
MicroPython is available for general use under MIT License. Many of its modules and libraries are also available under MIT license or similar open source license. MicroPython is free to use for both educational and commercial purposes. Anybody can use and modify the firmware. It is an open-source project with source code available on Github. Being an open-source project, MicroPython is open for community contributions. If you are looking for a firmware version targeting a specific hardware platform, microcontroller, port, or feature, check out the official MicroPython download link.

MicroPython vs. Python
MicroPython is largely an implementation of Python 3.4 with some select Python 3.5 and above features. Many standard CPython libraries have been rewritten in C99 to run within constraint environments of bare metals (microcontrollers and microcomputers without any operating system) as part of MicroPython. These micro-fied standard Python libraries form the core of MicroPython firmware. Not all standard Python libraries have been rewritten to form MicroPython; MicroPython is a subset of standard Python. It includes the re-implementation of only those Python libraries that may be useful in programming embedded systems or programmatically enhancing embedded applications.

MicroPython may differ in syntax and behavior with equivalent operators, functions, and modules of standard Python at many places. A lot of these conflicts are listed at the following link. Except for a few conflicts listed in the link mentioned above, most of the MicroPython syntax and programming is compliant with standard Python documentation.

A microcontroller board, RTOS, or operating system supported by MicroPython is called a MicroPython Port. It is important to know that many features of core MicroPython may be unavailable for a particular port, i.e., it may not be supported in a given microcontroller, RTOS, or operating system. Plus, a particular port may have additional modules and functionalities of MicroPython. For example, the MicroPython version for ESP32 and ESP8266 has additional libraries and functions available to handle network connections and supports WebREPL (REPL over web sockets).

Supported Boards and MicroPython ports
MicroPython is available for several common platforms, including x86, x86-64, ARM-Thumb, and Xtensa. It is remarkably fast, with code execution possible at speeds up to 168 MHz. The official microcontroller board supported by MicroPython is pyboard. The pyboard has the following salient features.

-> STM32F405RG microcontroller
-> 168 MHz Cortex M4 CPU with hardware floating point
-> 1024KiB flash ROM
-> 192KiB RAM
-> Micro SD card slot
-> Micro-USB port
-> On-board 3-axis accelerometer and RTC
-> 29 GPIO; 3x 12-bit ADC available on 16 pins 4 with analog ground shielding and 2x 12-bit DAC available on pins X5and X6.

Not just the pyboard, MicroPython can be used on many other microcontroller boards of STMicroelectronics. Some of the microcontrollers of STMicroelectronics having full-support of MicroPython firmware are listed below.

-> Espruino Pico (STM32F401CD)
-> BLACK STM32F407VET6 (STM32F407VE)
-> BLACK STM32F407ZET6 (STM32F407ZE)
-> BLACK STM32F407ZGT6 (STM32F407ZG)
-> FEZ Cerb40 II (STM32F405RG)
-> G30HDR Module (STM32F401RE)
-> FEZ Lemur (STM32F401RE)
-> Netduino Plus 2 (STM32F405RG)
-> OpenMV (STM32F765)
-> HY-STM32F4xxCore144 Core/Dev Board (STM32F407ZGT6)
-> HydraBus V1.0 (STM32F405RG)
-> Olimex STM32-405STK (STM32F405RG)
-> Olimex STM32-E407 (STM32F407ZG)
-> NUCLEO F401RE (STM32F401RE)
-> STM Discovery STM32F401 (STM32F401VC)
-> STM Discovery STM32F407 (STM32F407VG)
-> STM Discovery STM32F429 (STM32F429ZI)
-> STM Discovery STM32F746G (STM32F746NG)
-> STM32F407VET6 Mini (STM32F407VE)

Apart from the above-listed microcontrollers of STMicroelectronics, MicroPython supports the following notable embedded platforms.

-> ESP32
-> ESP8266
-> Micro:Bit
-> WiPy and CC3200
-> Pyboard D-Series
-> Teensy 3.X
-> Adafruit Circuit Playground Express
-> Arduino Due
-> Cypress FreeSOC
-> Raspberry Pi Pico

MicroPython Boards and Ports

Examples of MicroPython Boards and Ports

Zephyr is one of the real-time operating systems supported by  MicroPython. MicroPython can run as a thread in other RTOS like pyRTOS and FreeRTOS.

MicroPython libraries
The core MicroPython includes implementation of several standard Python 3.4 libraries, which consists of an array, binascii, builtins, cmath, collections, errno, gc, hashlib, heapq, io, json, math, os, random, re, select, socket, ssl, struct, sys, time, uasyncio, zlib, and _thread. Other libraries included in MicroPython are hardware-specific. These are called micro-libraries, including Bluetooth, btree, cryptolib, framebuf, machine, micropython, neopixel, network, and uctypes.

Port-specific libraries
Different microcontroller boards and RTOS offer additional features and core microcontroller operations. MicroPython includes libraries specific to particular microcontroller boards and real-time operating systems to exploit their exclusive features. For example, the port-specific version of MicroPython for pyboard includes libraries like pyb, stm, and lcd160cr. The port-specific version of MicroPython for WiPy includes wipy library and additional classes like ADCChannel, TimerChannel, TimerWiPy, and ADCWiPy. The port-specific version of MicroPython for ESP8266 and ESP32 boards includes esp and esp32 packages. The rp2 package is additionally included in the MicroPython version for Raspberry Pi Pico. An additional module, zephyr, comes packaged in the MicroPython version for Zephyr RTOS.

Additional Python libraries from micropython-lib
The core MicroPython modules are called umodules in the MicroPython terminology. Apart from the select standard Python libraries rewritten to form core MicroPython, many other standard Python libraries have been rewritten in MicroPython projects. These libraries can be accessed as a separate distribution in the form of micropython-lib. Most of these libraries/modules use FFI for OS-specific functionalities. That is why micropython-lib can be generally used only on hosts with POSIX-compatible operating systems like Linux, FreeBSD, Solaris, MacOS, etc. It has limited support for Windows. Unlike standard MicroPython modules, micropython-lib modules need to be installed either using upip or copying unzipped packages manually.

Extending MicroPython libraries
It is also possible to extend the implementation of built-in MicroPython libraries. Any user-defined module named module.py overwrites the standard MicroPython umodule within a package. The package can still use the built-in functionalities by importing the u-module directly. Most of the libraries in micropython-lib have been written in the same manner.

Conclusion
MicroPython can be the next revolution in the microcontroller world after the Arduino. First of all, MicroPython has accomplished the major task of introducing Python to microcontrollers and MCU-based embedded systems. Python is the one-stop for developing networked and AI-backed applications. The use of multithreading in embedded applications will be another important milestone set by the MicroPython initiative.

You may also like:

  • Raspberry Pi 4
    RPi Python Programming 01: Introduction to Raspberry Pi 4

  • How to use Raspberry Pi camera module with Python
  • Object-Oriented Python
    RPi Python Programming 10: Object-oriented Python

  • RPi Python Programming 08: Python lists and byte arrays
  • Python basics
    RPi Python Programming 07: Python basics (part 2)

  • How to Make First Python Program with Beaglebone Black (Part…

Filed Under: Python, Tutorials
Tagged With: MicroPython, MicroPython Boards, MicroPython Firmware, MicroPython libraries, MicroPython Ports, micropython-lib, What is MicroPython
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Thermal modelling of repetitive power pulse
  • Redundant XORs
  • No Output Voltage from Voltage Doubler Circuit in Ansys Nexxim (Harmonic Balance Simulation)
  • Discrete IrDA receiver circuit
  • ISL8117 buck converter blowing up

RSS Electro-Tech-Online.com Discussions

  • Simple LED Analog Clock Idea
  • Can I make two inputs from one??
  • Behlke swich
  • using a RTC in SF basic
  • Help with finding unique wire lug(s)

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe