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
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.
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
... 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.
You'll get a new prompt where you can type in the same simple calculation as before. The result, of course, is the same.
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?
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.
We'll go to Tools, Options, select the Raspberry Pi Pico. There's support for the 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.
Jump to another article
1. What is MicroPython?
2. MicroPython vs Python
3. MicroPython resources
4. MicroPython compatible boards
5. Getting started with Thonny IDE
6. How to install the MicroPython firmware
7. Setup an interpreter in Thonny IDE
8. How to write and execute a MicroPython program
9. Thonny IDE with the Raspberry Pi Pico
10. Thonny IDE with the BBC Micro:bit
11. Thonny IDE advanced configuration
12. How to find MicroPython packages at PyPi
13. The MicroPython shell
14. MicroPython Programming with files
15. How to interrupt a running program
16. How to run a program at boot
17. How to debug MicroPython program