Example project for running MicroPython on Wokwi for VS Code.
pip install mpremote
.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.