Thonny IDE MicroPython on ESP32 For Windows 10 users.

Thonny IDE MicroPython on ESP32

For Windows 10 users… Install, Setup, and yes blink the onboard LED on your ESP32 Development Board.

Now I know this must get boring but the first thing you must do is download the Thonny IDE installer.

TECH PREP Series

Link to thonny.org

Select the Windows Download.

When the download finishes, run it accepting all the defaults to install Thonny IDE.

What follows is a quick photo sequence of these actions.

Step1
Step 2
Step 3
Step 4
Step 5
Step 6

All the above is really pretty straightforward, and you really shouldn’t have any trouble getting Thonny IDE Installed.

Now we can get into the really interesting stuff like actually writing code.

Open Thonny IDE

Above pic shows what it should look like. The first thing I like to do if I’m going to be using Thonny IDE with ESP32 / ESP8266 devices is to connect the IDE Interpreter to our connected device…

Select Tools —Options

Then MicroPython on a generic device…

We have to select the COM port to which our device is connected. Ensure that your device has already been flashed with MicroPython firmware.

Click OK.

And we should see the connection in the shell section.

By the way, you can type MicroPython commands at the >>> prompt and the interpreter will process them.

Anyhow, we are now ready to make something happen, you should have you esp32 (in this case) flashed with the MicroPython firmware connected to a com port; lets say COM3. When you open Thonny IDE the screen will look like this.

Now we can type in some code to make the on board LED flash WOW! Bet that’s not been done before. Every walk starts with tying your shoe laces. (bit deep, yeah?)

The code..

from machine import Pin
from time import sleep
led = Pin(2, Pin.OUT)

while True:
    led.value(not led.value())
    sleep(4)

What it should look like in the IDE..

Click Run the current script, And the LED should blink…. ohhhh pretty

File> save to save the file; use .py extension ie esp32blinkpin2.py

So, to upload the script to your device so that it runs every time the power is applied…

This, as it says, uploads your script to the device as main.py which is the script run on startup.

Now, whenever you power up your ESP32, the LED will start blinking, until you create another script and make it do something else. Really quite wonderful right?

This process also works the same for ESP8266 devices, after flashing the appropriate firmware. Although lately, I seem to be using the features of ESP32 more.

There is lot’s more to tell but for now, we have come to the end, hope you have enjoyed.

Cheer’s

Al

Leave a Reply

Your email address will not be published. Required fields are marked *