Site icon Renzo Mischianti

Raspberry Pi Pico, W, and other rp2040 boards: pinout, specs, and Arduino IDE configuration – 1

Spread the love

Raspberry Pi Pico, W, and other rp2040 boards: pinout specs Arduino IDE configuration

It’s time to explore the new series of microcontrollers based on the rp2040 chip from the Raspberry Pi Foundation. As usual, we are going to use the generic Arduino IDE and C language.

Introduction

Raspberry Pi Foundation designed a new chip named RP2040. The chip features a dual-core Arm Cortex-M0+ processor with 264kB internal RAM and support for up to 16MB of off-chip flash. A wide range of flexible I/O options includes I2C, SPI, and – uniquely – Programmable I/O (PIO).

After some time and about two million devices sold, Raspberry Pi also released the W version with WiFi to offer an IoT solution.

Here my selection of rp2040 boards Official Pi Pico - Official Pi Pico W - Waveshare rp2040-zero - WeAct Studio rp2040

rp2040 boards specs

rp2040 structure block diagram

rp2040 identifies the chip type, so we expect this to be the first chip of a long series. In the code, you can read the number of cores, the processor variant, ram, etc. look at the diagram.

rp2040 code identification

Infineon’s AIROC CYW43439

Only for the Raspberry Pi Pico W we can check the WiFi coprocessor specifications.

WiFi

Bluetooth (Not active now)

Raspberry Pi Pico

The firstborn is the Pico board which has a good quantity of pins and a suitable form factor for breadboard.

Raspberry Pi Pico rp2040 pinout low resolution

Raspberry Pi Pico: high-resolution pinout and specs

PINs

Power Pins

GPIO Pins

I2C Pins

SPI Pins

ADC Pins

Raspberry Pi Pico W

The W version has the same specs as Pico but with an Infineon’s AIROC CYW43439 coprocessor to get a Wifi connection.

Raspberry Pi Pico W pinout

Raspberry Pi Pico W: high-resolution pinout and specs

WeAct Studio rp2040 Pico

WeAct Studio RP2040 pinout

WeAct Studio rp2040: high-resolution pinout and specs

WeAct Studio is a factory that builds a very good quality board, and I already publish the STM32F4 Black pill (WeAct STM32F411CEU6 Black-Pill WeAct STM32F401CCU6) variants, here they propose a Raspberry Pi Pico clone with a selectable Flash size.

WeAct Studio RP2040 Pico

In addition to the Raspberry Pi Pico, here we have:

Waveshare rp2040-zero

Another alternative with a reduced size factor is proposed by Waveshare.

Waveshare rp2040-zero pinout

Waveshare rp2040-zero: high-resolution pinout and specs

Arduino IDE configuration

First of all, you must add this URL

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

to your Additional Boards Manager URLs in File --> Preferences.

Raspberry Pi Pico w rp2040 board URL manager on Arduino IDE

Now you can go to:
Tools --> Boards ... --> Boards manager
and search “Pico”.

Raspberry Pi Pico w rp2040 board manager Arduino IDE

Now you can select your rp2040 board

Arduino IDE select Raspberry Pi Pico rp2040 boards

Arduino IDE board manager alternative

Raspberry Pi Pico W

Arduino offer also an alternative to the rp2040 URL manager already see, you can go to:
Tools --> Boards ... --> Boards manager
and search “mbed rp2040”.

Arduino mbed rp2040 board manager Arduino IDE

But I discourage that approach. You can have trouble.

Upload mode

A little note about upload mode on Raspberry Pi Pico like devices. For the official boards, you can follow two approaches, for me very tedious.

To enter upload mode, you can:

Reset button on Raspberry Pi Pico rp2040

Or like so:

Reset button on Raspberry Pi Pico rp2040 on run reset

The other boards has a built-in reset button, and you must simply do these steps:

  1. Push the BOOTSEL button;
  2. Push and release the Reset button;
  3. Release the BOOTSEL button.

First sketch

Blink sketch for Pi Pico, W, and WeAct rp2040

You can use a standard blink sketch for Raspberry Pi Pico, W, and WeAct Studio rp2040.

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

For the official boards, you can select the board from the list.

Raspberry Pi Pico

For the WeAct Studio rp2040, if you have only 2Mb of flash, you can select Raspberry Pi Pico board, else you can select a Generic rp2040 board and then the correct flash size.

Arduino IDE select Generic rp2040 board and correct flash size.

RGB LED on Waveshare rp2040-zero

There is a different situation for Waveshare rp2040-zero that have an RGB led built-in.

Now we are going to manage the addressable RGB led (Addressable RGB LED (WS2812), driven by GPIO16) installed on the board.

You need to install Adafruit_NeoPixel.h library from the libraries manager.

Here is the simple sketch:

/*
 *  Here a simple sketch to test the upload on Waveshare rp2040-zero.
 *  The addressable RGB LED (WS2812), driven by GPIO16 need
 *  Adafruit NeoPixel library
 *  by Mischianti Renzo <https://mischianti.org>
 *
 *  https://mischianti.org/
 *
 */

#include <Adafruit_NeoPixel.h>
#define PIN 16
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

enum {NONE, RED, GREEN, BLUE};
int ledColor = NONE;

void setup()
{
  pixels.begin();
}

void loop()
{
  switch (ledColor) {
    case NONE:
      pixels.setPixelColor(0, pixels.Color(0, 0, 0));
      pixels.show();
      break;
    case RED:
      pixels.setPixelColor(0, pixels.Color(20, 0, 0));
      pixels.show();
      break;
    case GREEN:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.show();
      break;
    case BLUE:
      pixels.setPixelColor(0, pixels.Color(0, 0, 20));
      pixels.show();
      break;
    default:
      break;
  }

  ledColor++;
  if (ledColor == 4) {
    ledColor = NONE;
  }

  delay(1000);
}

And here is the result.

Waveshare rp2040-zero

Network test with Raspberry Pi Pico W

I’d like to show the basic scan network sketch for the Raspberry Pi Pico W.

// Simple WiFi network scanner application
// Released to the public domain in 2022 by Earle F. Philhower, III
#include <WiFi.h>

void setup() {
  Serial.begin(115200);
}

const char *macToString(uint8_t mac[6]) {
  static char s[20];
  sprintf(s, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  return s;
}

const char *encToString(uint8_t enc) {
  switch (enc) {
    case ENC_TYPE_NONE: return "NONE";
    case ENC_TYPE_TKIP: return "WPA";
    case ENC_TYPE_CCMP: return "WPA2";
    case ENC_TYPE_AUTO: return "AUTO";
  }
  return "UNKN";
}

void loop() {
  delay(5000);
  Serial.printf("Beginning scan at %d\n", millis());
  auto cnt = WiFi.scanNetworks();
  if (!cnt) {
    Serial.printf("No networks found\n");
  } else {
    Serial.printf("Found %d networks\n\n", cnt);
    Serial.printf("%32s %5s %17s %2s %4s\n", "SSID", "ENC", "BSSID        ", "CH", "RSSI");
    for (auto i = 0; i < cnt; i++) {
      uint8_t bssid[6];
      WiFi.BSSID(i, bssid);
      Serial.printf("%32s %5s %17s %2d %4d\n", WiFi.SSID(i), encToString(WiFi.encryptionType(i)), macToString(bssid), WiFi.channel(i), WiFi.RSSI(i));
    }
  }
  Serial.printf("\n--- Sleeping ---\n\n\n");
  delay(5000);
}

And the result is:

Beginning scan at 16543
Found 7 networks

                            SSID   ENC     BSSID         CH RSSI
                reef-casa-centro  WPA2 00:E0:20:74:B4:99  6  -76
                 reef-casa-sotto  AUTO 04:95:E6:81:67:51 11  -82
                    TIM-18355607  WPA2 20:B0:01:18:15:97 11  -82
                 reef-casa-sopra  WPA2 4C:ED:FB:1C:8C:10  1  -44
                   Vodafone-WiFi  NONE 92:16:05:19:3F:D2  2  -92
                  reef-casa-orto  AUTO C8:3A:35:C3:8F:F1  8  -49
                reef-casa-centro  WPA2 F0:B0:14:79:6D:70  6  -62

--- Sleeping ---

Thanks

  1. Raspberry Pi Pico and rp2040 boards: pinout, specs, and Arduino IDE configuration
  2. Raspberry Pi Pico and rp2040 boards: integrated LittleFS filesystem
  3. Raspberry Pi Pico and rp2040 board: ethernet w5500 with plain (HTTP) and SSL (HTTPS) requests
  4. Raspberry Pi Pico and rp2040 boards: WiFiNINA with ESP32 WiFi Co-Processor
  5. Raspberry Pi Pico and rp2040 boards: how to use SD card
  6. Dallas ds18b20
  7. Connecting the EByte E70 to Raspberry Pi Pico (rp2040) devices and a simple sketch example

Spread the love
Exit mobile version