Skip to main content

Programming Microcontrollers with Thonny

Thonny is a lightweight Python IDE that makes it very easy to program boards like the ESP32

and Raspberry Pi Pico
A low-cost microcontroller board from Raspberry Pi, based on the RP2040 dual-core ARM Cortex-M0+ chip.
Raspberry Pi Pico
using MicroPython
A compact version of Python for microcontrollers like the ESP32 and Raspberry Pi Pico. It lets you script directly on embedded hardware.
.

This guide explains how to install Thonny, flash MicroPython

firmware, and upload the main.py script for the Smart Auto-Watering Pot.


1. Install Thonny

  1. Download Thonny from https://thonny.org
  2. Run the installer and follow the prompts
  3. Launch Thonny once installed

Installing Thonny


2. Connect Your Board

  1. Plug your Board into your computer using a USB cable
  2. If prompted, allow Windows/macOS to install any drivers
  3. You should see a new COM or serial port appear

3. Flash MicroPython
A compact version of Python for microcontrollers like the ESP32 and Raspberry Pi Pico. It lets you script directly on embedded hardware.
Firmware

You only need to do this once per board.

  1. In Thonny, go to: Tools → Options → Interpreter
  2. Select your board type from the list (e.g. “ESP32
    A low-cost, low-power system on a chip (SoC) with integrated Wi-Fi and dual-mode Bluetooth.
    ” or “Raspberry Pi Pico
    A low-cost microcontroller board from Raspberry Pi, based on the RP2040 dual-core ARM Cortex-M0+ chip.
    Raspberry Pi Pico
    ”)
  3. Click Install or Update MicroPython
    A compact version of Python for microcontrollers like the ESP32 and Raspberry Pi Pico. It lets you script directly on embedded hardware.
  4. Wait for the process to complete

Installing  firmware in Thonny


4. Verify the REPL
Read-Eval-Print Loop - an interactive environment that executes commands immediately and prints the result.
Connection

At the bottom of Thonny, you'll see the MicroPython

REPL
Read-Eval-Print Loop - an interactive environment that executes commands immediately and prints the result.
(interactive prompt).
Try typing:

print("Hello from <GlossaryTerm term="MicroPython" />!")

If it prints successfully, your board is ready.


5. Upload the Firmware

  1. Open the main.py file from the firmware/ folder of this project
  2. Click Run → Save As... and choose MicroPython
    A compact version of Python for microcontrollers like the ESP32 and Raspberry Pi Pico. It lets you script directly on embedded hardware.
    device
  3. Name the file main.py — this makes it run automatically on boot
  4. Click Save

6. Watch It Run

After saving, the code should start immediately.
You can monitor the serial output from the Thonny shell — it will print live moisture readings and watering events.