Skip to content

FAQ for the Thonny User

Dave edited this page May 31, 2023 · 6 revisions

** This is a work in progress **

Frequently Anticipated Questions for Thonny Users

Why use the MPRemote Visual Studio Code extension instead of Thonny?

Thonny is a great piece of software. I would be happily using Thonny for all my MicroPython projects, except for one thing: lack of git features.

  • VSCode integrates nicely with git, but it lacks the MicroPython-specific features that make Thonny so easy to use.
  • MPRemote offers a robust set of features to aid MicroPython development. But, it's command-line based and doesn't have the editing features that make VS Code such a nice tool.

So, the MPRemote VS Code extension was born with the idea of bringing the power of MPRemote into the ease of use of Visual Studio Code. But, there is a learning curve. This FAQ is here to address that.

How do I access MPRemote commands from VS Code?

First, access the command palette by pressing CTRL + SHIFT + P. Then start typing MPRemote. You'll be presented with a list of commands to choose from.

Most commands will also have a shortcut name shown in parentheses. These shortcut names correspond directly to the equivalent MPRemote command-line parameter. Typing a shortcut at the command palette prompt is usually enough to take you straight to the command.

How do I flash my microcontroller?

MPRemote doesn't do that, but the ESPTool Visual Studio Code Extension does, at least for ESP32 microcontrollers.

How do I save my Python code to the microcontroller?

When saving a file in Thonny, you're given the choice of writing the file to This computer or MicroPython device. You can open a new editor tab, create a file, and save it directly to the microcontroller's filesystem. You never have to save to your host computer.

The MPRemote VS Code extension works a little differently. Instead of saving directly to the MicroPython device, you always save to your development host (This Computer) and then copy the file to your microcontroller using the MPRemote: Upload file to remote filesystem (cp) command.

The reason for this is to encourage keeping the "golden copy" of any code or other files on the development host.

boot.py (or any other file) exists only on my MicroPython device. What do I do?

Use the MPRemote: Download file from remote filesystem command to copy the file onto the development host.

Where's my REPL prompt?

Thonny always opens up a REPL (Read-Eval-Print-Loop) prompt in the shell window. The VS Code extension opens the REPL prompt in VS Code's terminal window. But, the extension shares the terminal windows with the MPRemote commands. Because of this, you have to start it manually with the command MPRemote: Enter REPL prompt (repl) and exit it (CTRL + X) when you're done.

My main.py has an infinite while loop. How to I break out of it?

If you have your code wrapped in a while True: loop, the MPRemote commands will appear unresponsive. You have to break out of the loop first.

  1. Use MPRemote: Enter REPL prompt (repl) to start a REPL prompt.
  2. Notice how there is no >>> prompt displayed when the infinite loop is running.
  3. Press CTRL + C to break out of the loop and return to the >>> prompt.
  4. Exit the REPL prompt (CTRL + X) before issuing other MPRemote commands.

Why are the date and time wrong?

Thonny has a default option of setting the MicroPython device's realtime clock using the time on the developement host. With the MPRemote extension, this is a manual step. MPRemote: Set realtime clock to match host date-time (setrtc)