5.3. Using the Thonny editor

Thonny is a Python editor for beginners that also includes advanced IDE features for editing and debugging code. After you download Thonny and install our plugin as described below, Thonny will recognize the 3pi+ and help you interact with the MicroPython interpreter running on its control board.

Installing Thonny and connecting to the 3pi+

Install the latest version from the Thonny website. Start the program, open the Tools menu, and click “Manage plug-ins…”:

Search for “thonny-pololu”, select the corresponding plugin from PyPi, and click “Install”:

Important: Restart Thonny after installing the plugin. Next, connect your robot to your computer with a USB cable. You should be able to select an option for the 3pi+ from the interpreter menu in the lower-right corner of Thonny:

Your currently-running program on the 3pi+ will stop, and the “Shell” window will show a MicroPython prompt (“REPL”). (If it doesn’t connect or isn’t showing any output, try clicking “Stop” to get connected.)

Using Thonny to interact with the MicroPython interpreter

Next, you can try typing some commands in the Shell window:

Note: If Thonny does not show the “Pololu 3pi+ 2040 Robot” option here, something is wrong with the plugin install. You can program the board as a Pico or generic RP2040 board, but there will be more confusing options for file loading and saving.

If basic commands work, you can try using the hardware on the 3pi+:

Next, open blink.py in the Thonny editor. Assuming you are still connected and see the MicroPython prompt, you can click the green Run button at the top or press F5 to run it immediately. The LED should begin blinking. To stop the program you can press Ctrl+C. Try that now and run the code again with the Run button or F5. Make some modifications and see that the blink pattern changes.

If you save your changes, you will be able to access them from the demo menu system later. To start the demo program, press Ctrl+C (to stop the running program) then Ctrl+D (“soft” reboot).

Upgrading firmware with Thonny

Note: Loading a firmware file will delete all programs and data stored on your robot. Make sure you have anything you are working on backed up before you proceed.

You can also upgrade the MicroPython firmware with Thonny. Get the robot into bootloader mode as described in Section 5.1, and you will see an “Install MicroPython” option in the Thonny’s interpreter menu:

Select this option and then find the appropriate firmware in the list:

Thonny will automatically download and install our latest firmware version from the Internet.

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors