Example project for running MicroPython on Wokwi for VS Code.
- Install the Wokwi for VS Code extension.
- Install the mpremote tool, e.g.
pip install mpremote
.
-
Clone this project and open it in VS Code.
-
From the command palette, select "Wokwi: Start Simulator". You may need to activate your license first.
-
Select one of the directories to simulate, e.g. "esp32".
-
While the simulator is running, open a command prompt, and type:
python -m mpremote connect port:rfc2217://localhost:4000 run main.py
This will connect to the simulator and run the
main.py
file on the board. Note: keep the simulator tab visible while running the command, otherwise the simulator will pause and the command will timeout.
You can also use the mpremote
tool to upload files to the simulator, install libraries, and open a REPL session. For example, the following command will connect to the simulator, upload the main.py
file, install the ssd1306
library, and then open a REPL session:
python -m mpremote connect port:rfc2217://localhost:4000 fs cp main.py :main.py + mip install ssd1306 + repl
See the mpremote documentation for more details.
On Unix based systems (e.g. Mac or Linux), you can create a shortcut for connecting to the simulator by running the following command:
mkdir -p ~/.config/mpremote
echo 'config={"wokwi": "connect port:rfc2217://localhost:4000"}' > ~/.config/mpremote/config.py
After running this command, you can connect to the simulator by running mpremote wokwi
.
Licensed under the MIT license. See LICENSE for details.