The Waveshare RP2040 boards bring Raspberry Pi’s dual-core microcontroller to a compact, affordable form factor that works seamlessly with Arduino IDE. Whether you are coming from traditional Arduino boards or exploring RP2040 for the first time, this guide covers the complete setup process and starter projects that showcase the RP2040’s unique capabilities including dual cores, programmable I/O, and generous memory.
Table of Contents
- RP2040 Microcontroller Overview
- Waveshare RP2040 Board Options
- Arduino IDE Setup Step by Step
- First Project: Blink and Beyond
- Using Both Cores
- Programmable I/O Introduction
- Frequently Asked Questions
- Conclusion
RP2040 Microcontroller Overview
The RP2040, designed by Raspberry Pi, features dual ARM Cortex-M0+ cores running at up to 133 MHz, 264 KB of SRAM (significantly more than Arduino’s 2 KB), 30 GPIO pins with flexible function assignment, 2 programmable I/O (PIO) state machines for custom peripheral protocols, and USB 1.1 with host and device support. This makes it substantially more powerful than the ATmega328P used in Arduino Uno while remaining affordable and power-efficient.
Waveshare RP2040 Board Options
Waveshare offers several RP2040 boards targeting different use cases. The RP2040-Zero is the smallest option, measuring just 23.5 x 18mm with 29 GPIO pins and a built-in RGB LED. It is ideal for space-constrained projects and wearables. The RP2350-Plus offers the newer RP2350 chip with 16MB flash, pre-soldered headers, and a Pico-compatible form factor.
Arduino IDE Setup Step by Step
Setting up Waveshare RP2040 boards in Arduino IDE takes about five minutes. Open Arduino IDE (version 1.8.13 or later, or IDE 2.x). Go to File, then Preferences, and add the following URL to “Additional Board Manager URLs”: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json. Go to Tools, then Board, then Board Manager. Search for “RP2040” and install “Raspberry Pi Pico/RP2040” by Earle F Philhower III. Select your Waveshare board from Tools, Board, then Raspberry Pi RP2040 Boards. Choose the specific Waveshare board variant that matches your hardware.
To upload your first sketch, hold the BOOTSEL button on the board while plugging in the USB cable. The board appears as a USB drive. After the first successful upload, future uploads work without holding BOOTSEL, as the Arduino bootloader takes over.
First Project: Blink and Beyond
Start with the classic blink sketch, but use the RP2040-Zero’s onboard RGB LED for a more colourful experience. The WS2812 RGB LED on the RP2040-Zero can be controlled through the Adafruit NeoPixel library. Install it through the Library Manager, then cycle through colours with a simple sketch that transitions from red to green to blue.
Next, try reading an analogue sensor. The RP2040 has four ADC channels (12-bit resolution, compared to Arduino’s 10-bit). Connect a potentiometer to GP26 (ADC0) and read values from 0 to 4095. The higher resolution gives smoother, more precise readings for sensor projects.
Using Both Cores
The RP2040’s dual cores are its most unique feature compared to traditional Arduino boards. In the Arduino framework, setup() and loop() run on core 0. To use core 1, define setup1() and loop1() functions in your sketch. Both cores share the same SRAM but run independently.
A practical example: run sensor reading and data processing on core 0, while core 1 handles display updates and user interface. This prevents display rendering from blocking sensor timing, and vice versa. Use a shared variable (declared volatile) to pass data between cores.
Programmable I/O Introduction
PIO (Programmable I/O) is the RP2040’s most advanced feature, allowing you to create custom hardware-level peripherals in software. PIO state machines run independently of the CPU and can implement protocols like WS2812 LED control, custom serial protocols, and high-speed parallel interfaces without consuming CPU cycles.
In the Arduino framework, PIO is often used behind the scenes by libraries. The NeoPixel library, for example, uses PIO to generate precisely timed WS2812 signals. For advanced users, the Arduino-Pico framework provides the PIOProgram class for writing custom PIO programmes.
Frequently Asked Questions
Can I use standard Arduino libraries with RP2040?
Most Arduino libraries that do not rely on AVR-specific registers work with RP2040. Libraries for I2C sensors, SPI displays, and general-purpose functions are compatible. Libraries that use direct ATmega port manipulation (like some fast LED libraries) need RP2040-specific alternatives.
How does RP2040 compare to ESP32 for Arduino projects?
RP2040 offers better real-time performance through PIO and dual cores dedicated to your code (ESP32 shares cores with WiFi stack). ESP32 adds WiFi and Bluetooth which RP2040 lacks. Choose RP2040 for precise timing and dedicated processing. Choose ESP32 for WiFi/Bluetooth IoT projects.
Is the Waveshare RP2040-Zero compatible with Raspberry Pi Pico code?
Yes, code written for the Raspberry Pi Pico works on the RP2040-Zero with minor pin mapping adjustments. The GPIO numbering is the same, but the physical pin positions differ. Check the Waveshare RP2040-Zero pinout diagram for the correct physical pin assignments.
Conclusion
Waveshare RP2040 boards offer a powerful, affordable upgrade from traditional Arduino boards with dual cores, more memory, and the unique PIO capability. Setting them up in Arduino IDE is straightforward, and most existing Arduino code works with minimal changes. Start with the RP2040-Zero for its compact size and built-in RGB LED, then explore dual-core programming and PIO as you advance.
Browse Waveshare RP2040 and RP2350 boards at Zbotic.in to upgrade your Arduino projects with modern microcontroller power.
Add comment