MicroPython
Thonny IDE Setup
Thonny is the recommended IDE for MicroPython development. It's beginner-friendly, cross-platform, and includes everything you need: a code editor, REPL shell, and file manager for your microcontroller.
Install Thonny
Windows
- Download the installer from thonny.org
- Run the
.exeinstaller — accept defaults and install for all users - Launch Thonny from the Start Menu
Ubuntu / Linux
# Option 1: From the official Ubuntu/Debian package
sudo apt install -y thonny
# Option 2: Latest version via pip
pip install thonny
thonny &
macOS
# Via Homebrew (recommended)
brew install --cask thonny
# Or download the .dmg from thonny.org
Step 1 — Connect Your Board
Plug your ESP32 or Raspberry Pi Pico via USB.
Step 2 — Configure the Interpreter
This is the most important step — Thonny needs to know which board you're using.
- Go to Tools → Options → Interpreter (or Run → Configure interpreter)
- In the "Which kind of interpreter should Thonny use..." dropdown, select:
| Board | Select |
|---|---|
| Raspberry Pi Pico | MicroPython (Raspberry Pi Pico) |
| ESP32 | MicroPython (ESP32) |
| Generic board | MicroPython (generic) |
For Port, select:
- Windows:
COMx(e.g.,COM3) - Ubuntu:
/dev/ttyUSB0or/dev/ttyACM0 - macOS:
/dev/cu.usbserial-*or/dev/cu.SLAB_USBtoUART
- Windows:
Leave baudrate at
115200Click OK
Step 3 — Connect and Verify
Click the Stop/Restart button (red stop icon) in the toolbar. The Shell panel at the bottom should show:
For Pico:
MicroPython v1.xx.x on 2025-xx-xx; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>>
For ESP32:
MicroPython v1.xx.x on 2025-xx-xx; ESP32 module
Type "help()" for more information.
>>>
If you see this prompt, you're connected. 🎉
Step 4 — Test with REPL
Click in the Shell panel and type:
1>>> print("Hello from Analog Data!")2Hello from Analog Data!34>>> 2 + 25467>>> from machine import Pin8>>> led = Pin(2, Pin.OUT) # GPIO 2 (adjust for your board)9>>> led.on()10>>> led.off()The LED on your board should turn on and off in response.
Step 5 — Write and Run a Script
In the top editor area, write:
1from machine import Pin2import time34led = Pin(2, Pin.OUT) # Adjust GPIO number for your board56for i in range(10):7 print(f"Blink {i+1}")8 led.toggle()9 time.sleep(0.5)1011print("Done blinking!")12led.off()Press F5 (Run) or click the green Run button.
The code runs immediately on your board, and output appears in the Shell.
Step 6 — Save Code to the Board
To make your code run automatically when the board powers on:
- Go to File → Save As
- A popup asks: "Where to save to?"
- Click "Raspberry Pi Pico" or "MicroPython device"
- Save as
main.py
Now unplug and replug the board — your code runs automatically!
Step 7 — Manage Files on the Board
Go to View → Files to open the file panel.
The panel is split:
- Left side: Your computer's files
- Right side: Files on the microcontroller
You can:
- Drag files from computer to board (upload)
- Drag files from board to computer (download)
- Right-click → Delete files from the board
- Create folders on the board
Step 8 — Install MicroPython Packages
Thonny has a built-in package manager for MicroPython (similar to pip):
- Go to Tools → Manage packages...
- Search for a package (e.g.,
ssd1306for OLED displays) - Click Install
Alternatively, use mip from the REPL:
1>>> import mip2>>> mip.install("urequests") # Install HTTP requests libraryThonny Tips and Shortcuts
| Action | Shortcut |
|---|---|
| Run current script | F5 |
| Stop running | Ctrl+C (in shell) or Stop button |
| Save to board | Ctrl+Shift+S |
| Open file from board | Ctrl+O |
| Clear shell | Ctrl+L |
| Interrupt running code | Click Stop/Restart (red button) |
Troubleshooting
"Could not connect to the device" or no REPL prompt
- Make sure the board is plugged in and you selected the correct port
- Try pressing the Stop/Restart button
- Check that no other program (Arduino Serial Monitor, etc.) has the port open
- On Ubuntu: verify you're in the
dialoutgroup:groups | grep dialout
Thonny shows wrong Python version (not MicroPython)
Go to Tools → Options → Interpreter and re-select the MicroPython interpreter for your board.
"Permission denied" on port (Ubuntu)
sudo chmod 666 /dev/ttyUSB0
# Or permanently:
sudo usermod -aG dialout $USER
# Log out and back in

