Skip to main content

CircuitPython on Wokwi

You can simulate CircuitPython on Wokwi using the Raspberry Pi Pico board. To start a new simulation project, open the Raspberry Pi Pico CircuitPython project template.

Project structure

CircuitPython projects must include a code.py file. The code in this file will execute when you start the simulation.

Wokwi copies all the project files into the Pico's flash file system. This means your project can include additional Python modules and you can import them from code.py or from the interactive REPL. Your project can also include custom data inside text files.

You can get a list of all the files in the flash filesystem by running:

import os
print(os.listdir('/'))

Using libraries

You can use any library from the Adafruit CircuitPython Bundle. Create a "requirements.txt" file in your project, and write the names of the libraries that you use, one per line. Lines that start with "#" are comments.

For example, if you want to install both adafruit_display_text and adafruit_dht, create a "requirements.txt" file with the following content:

# requirements.txt example
adafruit_display_text
adafruit_dht

When you start the simulation, Wokwi downloads all the libraries and their dependencies. It copies them into the "lib" folder in the flash filesystem. You can call os.listdir('/lib') to get a list of all the libraries installed. For a complete code example, see CircuitPython Library List.

CircuitPython REPL

When the code in code.py terminates (or you interrupt it with Ctrl+C), you'll get into the CircuitPython REPL. The REPL is an interactive prompt where you can type python commands and see the results immediately. To paste code into the REPL type Ctrl+E and enter paste mode.

Project examples