Recently, I discovered a useful tool that makes coding on the Raspberry Pi Pico and Pico W more accessible. Wokwi, a free online simulator available at wokwi.com, allows you to effortlessly simulate your projects without needing the physical hardware.
With this simulator, you can not only write and test your code but also simulate adding various peripherals, connecting to the Internet, and replicating a full real-life setup to some degree. This means you can experiment, debug, and perfect your projects in a virtual environment before deploying them on actual hardware, saving both time and resources in some cases. Whether you’re a beginner or an experienced developer, Wokwi provides a powerful platform to enhance your Raspberry Pi Pico and Pico W development experience.
Before we delve into the topic, we invite you to support our ongoing efforts and explore our various platforms dedicated to enhancing your IoT projects:
- Subscribe to our YouTube Channel: Stay updated with our latest tutorials and project insights by subscribing to our channel at YouTube — Shilleh.
- Support Us: Your support is invaluable. Consider buying me a coffee at Buy Me A Coffee to help us continue creating quality content.
- Hire Expert IoT Services: For personalized assistance with your IoT projects, hire me on UpWork.
ShillehTek Website (Exclusive Discounts):
https://shillehtek.com/collections/all
ShillehTekAmazon Store:
ShillehTek Amazon Store — Canada
ShillehTek Amazon Store — Japan
Step 1: Accessing Wokwi
- Visit Wokwi: Go to wokwi.com and create a free account if you haven’t already. You can even get started without an account if you like.
- Explore the Simulator: Familiarize yourself with the interface. You will see options to create new projects, view templates, and explore examples. You do not have to select the Pico, they have other controllers to chose from as well.
Step 2: Creating a Project
They offer a wide range of template projects to choose from. One of these is a simple Blink LED project using the Pico SDK for C. Setting up the Pico SDK for C can be daunting for beginners, so having access to an easily configurable environment is a significant advantage for those just starting out.
We see upon running the script that the Raspberry Pi on the right starts to blink periodically, per the code instructions.
You can then create the same functionality in MicroPython in the IDE.
1-) Copy this code in:
# MicroPython script for blinking an LED on the Raspberry Pi Pico
from machine import Pin
import time
# Check if the default LED pin is available
try:
LED_PIN = Pin(Pin.PICO_DEFAULT_LED_PIN, Pin.OUT)
except AttributeError:
# If PICO_DEFAULT_LED_PIN is not defined, use Pin 25 which is the default LED pin for the Pico
LED_PIN = Pin(25, Pin.OUT)
# Blink the LED
while True:
LED_PIN.value(1) # Turn the LED on
time.sleep(0.25) # Wait for 250 milliseconds
LED_PIN.value(0) # Turn the LED off
time.sleep(0.25) # Wait for 250 milliseconds
2-) Change the name of the file to .py extension
Now you can run and see the same outcome, easily switching between coding languages in the same IDE! This is something you cannot easily do with a real Raspberry Pi Pico.
Step 3: Using Peripherals
What’s great about this simulator is that it allows you to add a variety of common sensors and components, such as LEDs, resistors, accelerometers, and more. You can easily add these parts using the plus button, or explore other projects that have already incorporated them.
For example you can go to and select a simple project, the NeoPixel ring. And see how it works https://wokwi.com/projects/314265138001609280
You see that once you start running it changes colors. This is great for beginners who do not have a device yet or do not want to buy NeoPixels.
Finally, another interesting feature is the ability to simulate accelerometer input or physical input in general. Since an accelerometer requires movement to produce data, the simulator provides a sliding bar that allows you to manually adjust the input. While this is a useful feature, it does highlight the limitation of not being able to physically move the device through space as you would with a real prototype. You can see an example using the MPU6050 with an Arduino here. This example also imports external code, a capability you can utilize in all of your projects using the simulator. Although this example uses an Arduino, you can achieve the same functionality with the Pico or Pico W. Simply click on the MPU6050 while the code is running to adjust the acceleration values and simulate real-life changes.
https://wokwi.com/projects/305937156771152449c
Conclusion
In conclusion, the simulator offers a convenient and flexible way to work with various sensors and components, such as accelerometers, LEDs, and more. Its ability to import external code and manually simulate sensor inputs provides valuable learning and prototyping opportunities. However, it does have limitations, such as the inability to replicate physical movement accurately. Despite these drawbacks, it remains a powerful tool for beginners and experienced developers alike.
If you found this information useful, follow me on Medium and YouTube for more tutorials and insights!