MICROPYTHON WITH THE ESP32 GUIDE SERIES
Getting Started With The Thonny IDE
In this lesson, I will discuss the Thonny IDE, an open-source integrated development environment that we'll be using to program the ESP32 using MicroPython.
In this lesson I will show you around Thonny in my already set up instance, and show you the location where you can download the installation utility so that you can install it on your own computer.
To get the most out of this lesson, I recommend that you watch the video (see above).
Thonny IDE walkaround
In the screenshot above you can see Thonny IDE running on Mac OS. I've done a little bit of configuration to customize the font types, and sizes, and things like that.
But, essentially, what you see here is Thonny as it looks like as soon as you install it.
Thonny is a competent and configurable integrated development environment. It would look like this at its most basic view, where you get the upper part of the window where you can see one or more tabs. You can have multiple tabs with your various Python programs or components for the program. And then, down below, you've got the Shell that you can use to interact with the Python interpreter.
In this case, as you can see, I'm running MicroPython on my ESP32, which is connected. Don't worry about this for now. I will show you first how to install the necessary interpreter on your ESP32 in the following lesson. And then, show you how to make the connections and interact with MicroPython on the ESP32.
For now, all I want to show you is that the Shell allows me real-time interaction with the Python interpreter running on the ESP32. But apart from that, it's got many more capabilities.
For example, if I go into Tools and Options, I can change the interpreter from MicroPython to one of the other available interpreters. For example, this one here is Python that ships with Thonny. Or you can go for Python that is running on a virtual environment or with Python running somewhere else. You may also access interpreters via a network, via SSH.
You can see here that the Thonny (version 3.3.4- latest at the time of recording) instance that I'm running ships with the capability of running MicroPython on BBC Micro:bit, Raspberry Pi Pico, ESP32, and the ESP8266; this is also a circuit Python environment. So, it's already fully featured just out of the box.
But you can install a lot more Python targets, as you can see, via plugins.
Thonny and Python interpreters
Another thing that I want to show you is that Thonny is used, not just for MicroPython on a microcontroller device, but for general Python development. And it gives you a lot of tools here, as you can see, to help you with that.
For example, you can turn on the files view, which gives you access to all files in a particular location on your local file system. In this case, it's on My Computer. It also gives you a view of the files that exist on the target device file system like these, so these files are stored on the ESP32 itself.
There's also a series of other types of tools, such as the ability to inspect the heap memory contents or, let's, say the stack, which is useful when you are jumping from one function into another, keep track of which function you are in. I'm going to give you a little demonstration of this a little later in another section. You can check out the variables that have been set up and so on.
Thonny IDE, important features
Let's have a look at some of the most important features of Thonny. First of all, you've got the configuration window. You can access it from Preferences, but you can access the exact same thing by going to Tools and Options. And that allows you to customize the look and feel of Thonny, which forms you're using, et cetera, how the debugger works, which terminal to use or Shell, and so on. So, you can customize the way that your Thonny editor works this way.
This also, if we go into Tools and Plugins, there's a whole variety of plugins that you can install; some of them, as I said earlier, in version 3.3.4, comes built into Thonny itself. The ESP tool package allows the Thonny IDE to interact with the ESP32 and, for example, flash new firmware on it.
But there are others you can search on PyPI, which is the Python repository for packages, and see what else is available. I'm going to show you how to use that later. There's also a package manager like this, which also allows you to search in PyPI for Python packages that contain libraries or code that is shareable and that you can use. Again, I'm going to show you a little later how to install a PyPI package.
To get Thonny, go to the Thonny website. You can have a quick look at this to get a rundown of the most important features.
I highly recommend that you watch this video here. It's a demonstration of some of Thonny's most exciting features, especially the debugging features produced by one of the Thonny developers. So, do check it out.
To download Thonny, click on your operating system - in my case, I'm working on a Mac - download the file, double click on it, and install it. There's nothing special about it. It's straightforward.
Thonny Github repository
Another web resource I want to show you is the GitHub repository. So, you can see, as I said, the source code of the Thonny project. Now, here you will find additional releases. So, click on the Releases link, and it will take you to a page where you can access not just the latest release, 3.3.4, in my case. 3.3.5 is just being worked on at the moment. It's not available via the download button here. You can see this is still 3.3.4. The bleeding edge version is 3.3.5.
But I found on the Mac in particular; if you are using macOS Big Sur, which is macOS 11, then version 3.3.4 does not work correctly. You may need to go to an older version; let's say, 3.3.3 did work for me. So, in case you need an older version, this is where you can get it from.
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