wokwi-pi-pico Reference | Wokwi Docs (2024)

Raspberry Pi Pico, an RP2040 microcontroller board with dual-core ARM Cortex-M0+ processor, 264k of internal RAM, and flexibleProgrammable I/O (PIO) feature.

wokwi-pi-pico Reference | Wokwi Docs (1)

Pin names

Pins GP0 to GP22 are digital GPIO pins. Pins GP26, GP27, and GP28 are digital GPIO pins with analog input function.

NameDescriptionAnalog input channel
GP0 … GP22Digital GPIO pins (0 to 22)
GP26Digital GPIO pin 260
GP27Digital GPIO pin 271
GP28Digital GPIO pin 282
GND.1 … GND.8Ground pins *
VSYS, VBUS, 3V3Positive power supply
TP4 †Digital GPIO pin 23
TP5 †Digital GPIO pin 25 + LED

* The physical pin numbers of the ground pins are 3, 8, 13, 18, 23, 28, 33, and 38.
† These pins do not appear in the visual diagram editor, but you can use them in your diagram.json file.

Pins 3V3_EN / RUN / ADC_VREF are not available in the simulation and are therefore omitted from the table.

Onboard LED

The Raspberry Pi Pico has an onboard LED, attached to GPIO PIN 25. The LED is lit when the pin is driven high.

You can also use the LED_BUILTIN constant to reference the LED in your Arduino code:

See Blink for a complete code example.

Simulation features

The Raspberry Pi Pico is simulated using the RP2040js Library.
This table summarizes the status of the simulation features:

PeripheralStatusNotes
Processor core✔️Only a single core is simulated
GPIO✔️
PIO✔️PIO Debugger available
USB🟡USB CDC (Serial) supported, see Serial Monitor below
UART✔️
I2C✔️Master mode only
SPI✔️Master mode only
PWM✔️
DMA✔️Only for the PIO peripheral
Timer✔️Pausing the timer not implemented yet
ARM SysTick Timer✔️
Watchdog
RTC
ADC + Temp sensor✔️Temperature sensor always reads 0
SSI🟡Just the minimum to make the bootloader happy
GDB Debugging✔️See the GDB Debugging guide

Legend:
✔️ Simulated
🟡 Partial implementation/work in progress
❌ Not implemented

Arduino core

The Arduino core provides the built-in Arduino functions, such as pinMode() and digitalRead(), as well as a set of standard Arduino libraries, such as Servo, Wire and SPI.

When compiling your code for the Raspberry Pi Pico, you can choose between two different cores:

You can learn about the key differences between these two cores in this GitHub comment.

To select a core, set the "env" attribute of the wokwi-pi-pico part. For the official Arduino core, use the value "arduino-core". For the community maintained core, set "env" to "arduino-community". e.g.:

 "parts": [
{
"type": "wokwi-pi-pico",
"id": "pico",
"attrs": {
"env": "arduino-community"
}

},

]

Serial Monitor

You can use the Serial Monitor to receive information from the code running on the Pi Pico, such as debug prints. By default, the Serial Monitor communicates withthe Pi Pico over USB.

Setting up the USB connection can take some time, and any messages printed duringthe USB setup time will be lost. Therefore, it's recommended to tell setup() to wait for the Serial Monitor connection before printing anything:

void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10); // wait for serial port to connect. Needed for native USB
}
// Now you can safely print message:
Serial.println("Hello, Serial Monitor!");
}

Serial Monitor over UART

The Serial Monitor can also communicate with the Pi Pico over the physical UART interface. To configure the UART communication between the Raspberry Pi Pico and the Serial Monitor, add the following connections to your diagram.json file:

 "connections": [
[ "$serialMonitor:RX", "pico:GP0", "", [] ],
[ "$serialMonitor:TX", "pico:GP1", "", [] ],

]

The example assumes that the Pi Pico was defined with an id of "pico", e.g.

 "parts": [
{
"type": "wokwi-pi-pico",
"id": "pico",

},

]

The use the Serial1 object in your code: initialize the port using Serial1.begin(115200), and then print messages with Serial1.println(). For example:

void setup() {
Serial1.begin(115200);
Serial1.println("Hello, world!");
}

void loop() { }

For a complete example, check out the Pi Pico Serial Monitor over UART Example.

Exporting UF2 binary

You can upload the program from the emulator directly into a physical Raspberry Pi Pico board. The steps are:

  1. Press "F1" in the Wokwi code editor and select "Download UF2 Binary".The download should start within a few seconds.
  2. Start your Pi Pico in bootloader mode. You can do this by pressing the boot loader button whileplugging the Pi Pico into the USB port of your computer.
  3. You should see a new drive appear on your computer (named "RPI-RP2"). Copy the UF2 file you downloaded into that drive.

MicroPython Support

The Raspberry Pi Pico supports MicroPython, and you can use it for running MicroPython projects in Wokwi. For more information, check out the MicroPython Guide.

Simulator examples

  • Pi Pico and LCD1602
  • Pi Pico Traffic Light
  • Pi Pico C++ SDK Blink
  • Pi Pico C++ SDK 7-Segment Example
wokwi-pi-pico Reference | Wokwi Docs (2024)

FAQs

Which programming language is best for Pi Pico? ›

A Raspberry Pi Pico responds to a variety of coding languages, including C, C++, and MicroPython. MicroPython is a more lightweight and simple version of traditional Python, and it is the most common language used by Raspberry Pi Pico hobbyists.

What IDE is used for Raspberry Pi Pico? ›

A Pi Pico can definitely be programmed from the arduino IDE (it can also be C/C++ programmed using a C toolchain involving make which is quite laborious to install (on Linux anyway) and which Rasp Pi explains in various tutorial pdfs).

Is Wokwi open source? ›

Publicly available on https://github.com with an OSI approved open-source license; and.

Is Raspberry Pi Pico faster than Arduino? ›

When it comes to processing power, the Raspberry Pi Pico boasts a dual-core ARM Cortex-M0+ processor running at 133 MHz, making it a formidable contender in the microcontroller arena. On the other hand, Arduino boards vary in terms of processing capabilities, with some featuring simpler architectures than others.

Can Raspberry Pi Pico run C++? ›

Raspberry Pi Pico C/C++ SDK

Our official C SDK can be used from the command line, or from popular integrated development environments like Visual Studio Code, Eclipse, and CLion. To get started, download our C/C++ SDK and Examples, and take a look at our 'getting started' documentation to get going.

Can the Raspberry Pi Pico store Files? ›

Pi Pico enables smooth storing of sensor data on-board. As the Pico board works on flavors of Python (in my case Micro-python), a CSV file can be created precisely. Then, the data that is generated or sensed using any sensor can be appended to this CSV file concurrently.

How to program Python on Raspberry Pi Pico? ›

To program your device, follow these steps: Push and hold the BOOTSEL button while connecting your Pico with a USB cable to a computer. Release the BOOTSEL button once your Pico appears as a Mass Storage Device called RPI-RP2. Drag and drop the MicroPython UF2 file onto the RPI-RP2 volume.

Can you install Linux on a PI Pico? ›

[TL;DR] The Raspberry Pi Foundation recently released their first microntroller, the Pico. And while the Pico can't run Linux unfortunately, it can give you the pleasure of playing with an old-school UNIX-like system: FUZIX. This post quickly summarizes how to get FUZIX onto the Pico from Arch Linux.

Can you run Windows on Raspberry Pi Pico? ›

Pico setup for Windows

It is inspired by, and is roughly equivalent to, the pico-setup project for Linux systems. The installer automates the prerequisite installation on Windows, as explained in the official Getting started with Raspberry Pi Pico guide.

Can Raspberry Pi Pico run GUI? ›

A tiny GUI for Raspberry Pi Pico

The pico-widgets for Raspberry Pi Pico is a lightweight graphical user interface (GUI) which is based on Pico Touchscreen SDK https://github.com/RPiks/pico-touchscr-sdk.

Can the Raspberry Pi Pico run an OS? ›

No - the Raspberry Pi Pico doesn't run a full desktop operating system like the Raspberry Pi 4, it runs code directly without a desktop interface (similar to how an Arduino board works). To learn more, check out the Raspberry Pi Pico Getting Started page.

What language is wokwi? ›

GitHub - wokwi/avr8js: Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node. js.

Is Wokwi for VSCode free? ›

Wokwi for Visual Studio code is free for open source projects. For commercial use, you will need to purchase a license.

Is Wokwi good? ›

Bottom line is that the Wokwi Arduino simulator makes learning easier with the ample amount of good examples provided to get one started🏇.

What language is used in Raspberry Pi Pico machine? ›

MicroPython is a full implementation of the Python 3 programming language that runs directly on embedded hardware like Raspberry Pi Pico.

What coding language does Pico 8 use? ›

Pico-8 runs on an easy to understand programming language called Lua.

Can you run Python on Pico? ›

You can develop Python scripts that will be directly executed on a Raspberry Pi Pico board or an ESP32. To do this, we install MicroPython on the board and then use software (Thonny IDE, for example) to write the Python script and send it to the board.

Which programming language is best for Raspberry Pi? ›

Python. Python takes the crown as the most widely used with Raspberry Pi programming language. It is the go-to language for developing web applications, machine learning algorithms, and electronics projects. Python's simple and intuitive syntax makes it a favorite among students, developers, and Pi users.

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Ray Christiansen

Last Updated:

Views: 5723

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.