MicroPython is Python 3 running on the microcontroller itself: an interpreted language (no compilation step), with dynamic typing (variable types are never declared), where blocks are delimited by indentation rather than by braces. Mastering its building blocks is what separates copying an example from writing your own program. This page is the step-by-step learning hub for the language on the embedded side: every sub-page comes with code to read and exercises to work through. The same language programs the ESP32 and other boards. This path therefore serves them all. It is the MicroPython counterpart of the C++ page in the Arduino module.

Learning path

To be followed in order: each step assumes the one before it.

  1. The REPL — the interactive shell that runs on the board: type one line and see the effect at once, the working tool behind all the rest;
  2. Variables and types — dynamic typing, int / float / str / bool, and the list / dict containers;
  3. Conditions and loops — if / elif / else, while, for … in, and the structural role of indentation;
  4. Functions — def, arguments, default values, return: factoring out and naming;
  5. [[micropython-modules-en|Modules and import]] — importing machine, time and the rest, and spreading code across several files;
  6. Reading a program you did not write — getting into unfamiliar code, and the language mechanisms that come back from one example to the next.

Once these blocks are in place, the question becomes how to drive the hardware (see GPIO, PWM, ADC) and then how to structure the code: non-blocking programming, state machines, and the firmware as a whole.

See also

  • MicroPython — the module hub
  • Getting started — flashing and running a program, the practical prerequisite for trying the examples
  • C++ — the language of the Arduino module, worth comparing (compiled, statically typed)
  • Function — the notion of a function in programming
  • Firmware — structuring embedded code (cross-cutting)