MICROPYTHON WITH THE ESP32 GUIDE SERIES

How To Set The MicroPython Interpreter

Thonny IDE can work with multiple Python interpreters. Not at the same time, of course, but Thonny does give you the ability to select which interpreter you want to use next, also which device that interpreter is installed on.

In this lesson I will show you how you can switch between interpreters quickly. 

The interpreter selector

The interpreter selector is in the Thonny options window.

Let's start.

Go to Tools and then Options, you'll see that under the interpreter tab, expand that drop-down menu, and you'll see that Thonny comes equipped with a variety of interpreters. There's an interpreter that ships with Thonny itself. It runs as part of the Thonny environment, but you can also choose to use the Python instance installed on your computer.

Of course, you can run MicroPython on various devices, including BBC micro:bit, Raspberry Pi Pico, and the ESP32.

I have already selected the ESP32 since we installed the MicroPython firmware on my brand new device, and we tested it.

The MicroPython prompt confirms your selected interpreter.

So, we've got the MicroPython prompt; this is information about the Python interpreter we are using. So, if I do a simple calculation in Python, like:

>>> 1 + 1
2
>>>

... you will see that MicroPython on the ESP32 is working, and communicating with Thonny IDE.

Switch to a different interpreter

From here, I want to switch to the Thonny built-in environment.

You can do that via the Thonny options; click the Interpeter tab, and select "The same interpreter which runs Thonny" option from the list.

Switching to the Thonny IDE build-in Python interpreter.

You'll get a new prompt where you can type in the same simple calculation as before. The result, of course, is the same.

Just switched to default Python.

As you can see, the name of this environment they're working on right now is Python 3.7.9, which is the default Python for Thonny IDE, not MicroPython.

MicroPython for the Raspbery Pi Pico

But how about something else? How about we try MicroPython on the new Raspberry Pi Pico?

The Raspberry Pi Pico

In the photo above you can see a Raspberry Pi Pico microcontroller that runs MicroPython. On the breadboard I have added an LED here, which is just showing me when power is connected.

Let's see if we can program this board with MicroPython on Thonny IDE.

Thonny IDE supports the Raspberry Pi Pico "out of the box".

We'll go to Tools, Options, select the Raspberry Pi Pico. There's support for the Pico.

MicroPython on Raspberry Pi Pico.

After selecting the interpreter for MicroPython on a Raspberry Pi Pico, the REPL prompt becomes available so we can start our interaction with it.

I've have created several lectures in this course where I demonstrate how to use MicroPython on the Raspberry Pi Pico in depth. I didd the same with the BBC Micro:bit.

Learn MicroPython for the ESP32

With this video course, you will learn how to use the
MicroPython programming language with the ESP32 micro-controller.


MicroPython is the perfect language for anyone looking for the easiest (yet still powerful) way to program a micro-controller.

[publication_date]

We publish fresh content each week. Read how-to's on Arduino, ESP32, KiCad, Node-RED, drones and more. Listen to interviews. Learn about new tech with our comprehensive reviews. Get discount offers for our courses and books. Interact with our community. One email per week, no spam; unsubscribe at any time

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}