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

Thonny IDE running on Mac OS

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.

Thonny IDE works with multiple interpreters.

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.

A list of interpreters that ship with Thonny IDE version 3.3.4 or later.

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.

The file browser allows you to access files in the host computer and target device.

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 provides many development tools, such as the variables, heap and stack inspectors.

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.

Thonny options.

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.

Get Thonny

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.

Download Thonny from thonny.org.

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.

The Thonny GitHub repository.

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.

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

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