Skip to content

MicroPython

Uli Raich edited this page May 15, 2020 · 4 revisions

Accessing the (Micro)Python Interpreter

MicroPython implements the Python 3.4 syntax. It is Open Source and can be downloaded from its github repository. There are versions for different kinds of processors and descriptions on how to build and flash the interpreter. The ESP32 port is based on the ESP-IDF development environment provided by Espressif, the company behind the ESP processors. They also provide the xtensa-esp32-elf-gcc cross compiler and associated libraries. Going into details on how we built the interpreter would go beyond the limits of what this course can teach. Let's suppose that the interpreter in already installed in the ESP32 flash and ready to run.

Details about MicroPython is found in its documentation, which has a chapter dedicated to ESP32 https://docs.micropython.org/en/latest/esp32/quickref.html. For convenience a MicroPython firmware binary as well as the scripts needed to erase the ESP32 flash and to program it with the firmware included in the repository.

Accessing the interpreter though the serial line

n order to connect to the ESP32 we need a serial terminal emulator like minicom, gtkterm or seyon. Later on we will use thonny as an editor to write our Python scripts and save them on the PC but also to connect to the ESP32 through thonny's command window.

Here I give you an example how to configure minicom for use with MicroPython on the ESP32. First you must start minicom as root with the option "-s":

minicom -s

minicom configuration

Then you can save these settings as default when starting minicom.

save minicom configuration

Finally you can start minicom normally without any options and you will see that MicroPython says "hello" with its characteristic prompt: ">>>".

In the screen dump below I typed the command

help()

You see only the first part of MicroPython's answer.

save minicom help

Now you can interact with MicroPython through its Read, Evaluate, Print Loop (REPL). Here a simple example:

first MicroPython session

Clone this wiki locally