RP2040 Thing Plus Hookup Guide a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t1527

Contents

Introduction

Introducing the SparkFun Thing Plus - RP2040, featuring the RP2040 microcontroller (MCU) on a Feather (Thing Plus) form-factor. Additionally, this development platform also provides an SD card slot, 16MB (128Mbit) flash memory, a JST single cell battery connector (with a charging circuit and attached fuel gauge sensor), a WS2812 RGB LED, JTAG (PTH) pins, and our signature Qwiic connector.

SparkFun Thing Plus - RP2040

SparkFun Thing Plus - RP2040

DEV-17745
$19.50
4

The Raspberry Pi RP2040 (the first MCU from the Raspberry Pi Foundation) is a low cost, dual-core Arm® Cortex® M0+ microcontroller with 264kB of SRAM, running at 133MHz. It includes USB host functionality, a timer with 4 alarms, a real time counter (RTC), six dedicated IO pins for Quad-SPI flash (supporting execute in place), and thirty multifunction GPIO (*18 of which are broken out on the board), with the following capabilities:

Required Materials

To get started, users will need a few items. Now some users may have a few of these items, feel free to modify your cart accordingly.

SparkFun Thing Plus - RP2040

SparkFun Thing Plus - RP2040

DEV-17745
$19.50
4
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
4

Click the buttons above to toggle the additional materials based on the tasks you
wish to perform. Feel free to modify the items in your cart to fit your needs.


Li-Po Battery

For mobile applications, users will want to pick up a single-cell LiPo battery from our catalog. Below, are a few available options:

Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

PRT-13851
$5.50
11
Lithium Ion Battery - 2Ah

Lithium Ion Battery - 2Ah

PRT-13855
$13.95
9
Lithium Ion Battery - 110mAh

Lithium Ion Battery - 110mAh

PRT-13853
$5.50
4

Lithium Ion Battery - 1Ah

PRT-13813
8 Retired

Jumper Modification

To modify the jumpers, users will need soldering equipment and/or a knife.

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$9.95
8
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$7.95
4
Hobby Knife

Hobby Knife

TOL-09200
$3.50
2

Weller WLC100 Soldering Station

TOL-14228
2 Retired

Qwiic Example

If you would like to follow along with the examples below to interact with the physical world, you will also need the following items:

Qwiic Cable - 100mm

Qwiic Cable - 100mm

PRT-14427
$1.50
SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

SparkFun Qwiic 12 Bit ADC - 4 Channel (ADS1015)

DEV-15334
$11.50
1

Magnetic Screwdriver Set (20 Piece)

TOL-15003
1 Retired

Headers & Accessories

Headers are great for development purposes, letting users swap parts with just a set of jumper wires. If you would like to add headers to your board, check out some of the options for the Thing Plus or Feather form factor boards:

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.75
20
Feather Stackable Header Kit

Feather Stackable Header Kit

PRT-15187
$1.75
Female Header - 12-Pin

Female Header - 12-Pin

PRT-14321
$0.75
Header - 8-pin Female (PTH, 0.1")

Header - 8-pin Female (PTH, 0.1")

PRT-11895
$0.75

SparkFun Beginner Tool Kit

TOL-14681
Retired

Below is a sample selection of our other headers and soldering tools in our catalog. For a full selection of our available Headers or Soldering Tools, click on the associated link.

Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

PRT-16763
$2.25
Raspberry Pi GPIO Tall Header - 2x20

Raspberry Pi GPIO Tall Header - 2x20

PRT-14017
$2.75
Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.75
20
Arduino Stackable Header Kit - R3

Arduino Stackable Header Kit - R3

PRT-11417
$1.75
12
PINECIL Soldering Iron Kit

PINECIL Soldering Iron Kit

KIT-24063
$69.95
1
Insulated Silicone Soldering Mat

Insulated Silicone Soldering Mat

TOL-14672
$10.95
9
PINECIL - Smart Mini Portable Soldering Iron

PINECIL - Smart Mini Portable Soldering Iron

TOL-23913
$35.99
Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$16.50
16

JTAG Functionality

Users interested in JTAG applications (i.e. programming and debugging the RP2040) will need an Arm® Programmer and need to solder on a JTAG header. We recommend these programmers from our catalog:

Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.75

J-Link EDU Mini Programmer

PGM-15345
1 Retired

J-Link EDU Base Programmer

PGM-15346
2 Retired

J-Link BASE Compact Programmer

PGM-15347
Retired

Suggested Reading

Here are a few tutorials that may help users familiarize themselves with various aspects of the board.

How to Solder: Through-Hole Soldering

This tutorial covers everything you need to know about through-hole soldering.

Serial Communication

Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!

Serial Peripheral Interface (SPI)

SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.

Battery Technologies

The basics behind the batteries used in portable electronic devices: LiPo, NiMH, coin cells, and alkaline.

Pulse Width Modulation

An introduction to the concept of Pulse Width Modulation.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Analog vs. Digital

This tutorial covers the concept of analog and digital signals, as they relate to electronics.

Qwiic Connect System

One of the new, convenient features of the board is that it takes advantage of the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials. Click on the banner above to learn more about Qwiic products.

UF2 Bootloader

The SparkFun Thing Plus - RP2040 is easy to program, thanks the UF2 bootloader. With the UF2 bootloader, the RP2040 Thing Plus shows up on your computer as a USB storage device without having to install drivers for Windows 10, Mac, and Linux!

USB storage device
Board being recognized as a USB device. (Click to enlarge)

What is UF2?

UF2 stands for USB Flashing Format, which was developed by Microsoft for PXT (now known as MakeCode) for flashing microcontrollers over the Mass Storage Class (MSC), just like a removable flash drive. The file format is unique, so unfortunately, you cannot simply drag and drop any compiled binary or hex file onto the board. Instead, the format of the file must have specific information to tell the processor where the data goes, in addition to the data itself. For more information about UF2, you can read more from the MakeCode blog, as well as the UF2 file format specifiation.

BOOTSEL Mode

Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Enter BOOTSEL Mode
Hold down BOOT button to enter BOOTSEL mode.

Note: As another option, with the USB-C cable already connected to the board and the computer, users can hold down the BOOT button and toggle the RESET button to enter BOOTSEL mode. However, this method does require a little bit of finger dexterity.

Hardware Overview

Board Dimensions

The SparkFun RP2040 Thing Plus has a feather form factor and the board dimensions are illustrated in the drawing below.

Board Dimensions
Board dimensions (PDF) for the SparkFun RP2040 Thing Plus, in inches. (Click to enlarge)

Power

The SparkFun RP2040 Thing Plus only requires 3.3V to power the board. However, the simplest method to power the board is through the USB-C connector.

Power Connections
SparkFun RP2040 Thing Plus power connections. (Click to enlarge)

The power pins that are available on the board, are detailed below:

Power Pins
SparkFun RP2040 Thing Plus power pins. (Click to enlarge)

Current Consumption

The Thing Plus - RP2040 consumes about 24mA on average, without any code running. The table below, summarizes the approximate current draw of the SparkFun RP2040 Thing Plus, through the USB-C connector, for various operational conditions.

Operation 1st Boot BOOTSEL Mode Idle Idle MicroPython
Battery Charging GPIO 25
LED ON
WS2812 LED
White (max)
.uf2 Boot REPL Open
Current Draw (mA) 11 (Idle)
20 (Peak)
11-14 -- -- 25 40-42 22-24 23-24

Note: The RP2040 microcontroller has two low power states:

The real-time clock (RTC) can wake the RP2040 chip up from both of these modes. However, to wake the chip from dormant mode, the RTC must be configured to use an external reference clock, supplied by a GPIO pin.

Power Status LED

The red, POWER LED will light up once 3.3V is supplied to the board; however, for most users, it will light up when 5V is supplied through the USB connection or when a LiPo battery is connected to the JST connector.

Power LED
SparkFun RP2040 Thing Plus POWER status LED indicator. (Click to enlarge)

Charging Circuit

The charging circuit utilizes the MCP73831 linear charge management controller and is powered directly from the USB-C connector or USB. The controller is configured for a 500mA charge rate and battery charging is indicated by the yellow, CHG LED. If the charge controller is shutdown or charging is complete, the CHG LED will turn off. For more information, pleas refer to the MCP73831 datasheet.

Charging Circuit
Charging circuit for the battery connector. (Click to enlarge)

Power Control

The power source to the AP2112 LDO voltage regulator is controlled by a P-channel MOSFET. In addition, the 3.3V regulated output from the AP2112 is controlled by the enable (EN) pin, broken out on the board.

3V3 Power Circuit
Circuit for 3.3V power control. (Click to enlarge)

The P-channel MOSFET operation is based on the voltages at the MOSFET's gate and source pins. Depending on the power sources connected to the board, the MOSFET will act as a switch and control power from the battery to the AP2112 voltage regulator; detailed in the following table.

Power Source MOSFET Power Control Description
Gate Source VGS
(VGate - VSource)
MOSFET
Operation
USB Only VUSB = 5V VUSB - Vf VUSB - (VUSB - Vf)
VGS = Vf
MOSFET Off
RGS = ∞
Switch Open
Power to the AP2112 is supplied by the USC-C connection.
Power from the USB-C connection is passed through the Schottky diode. Due to the voltage drop from the Schottky diode, the gate threshold voltage for the MOSFET is positive and equivalent to the diode's forward voltage (Vf).Therefore, the MOSFET behaves as an open switch.
Battery Only VUSB = 0V Dep. Mode:
VSource = 0

Charged Cap.:
VBatt = 3 - 4.2V
Dep. Mode:
VGS = 0

Charged Cap.:
VUSB - VBatt = -VBatt
-3V > VGS > -4.2V
MOSFET On
RGS = Low
Switch Closed
Power to the AP2112 is supplied from the battery connection.
As a depletion type P-channel MOSFET, the mosfet acts as a normally closed switch when the gate threshold voltage is zero. Therefore, power from the battery is able to charge the capacitor and create a negative gate threshold voltage. The MOSFET remains behaving as a closed switch and power to the AP2112 is provided from the battery.
USB & Battery VUSB = 5V VUSB - Vf VGS = Vf MOSFET Off
RGS = ∞
Switch Open
Power to the AP2112 is supplied by the USC-C connection.
Power from the USB-C connection is passed through the Schottky diode. Due to the voltage drop from the Schottky diode, the gate threshold voltage for the MOSFET is positive and equivalent to the diode's forward voltage (Vf).Therefore, the MOSFET behaves as an open switch.

The enable pin of the AP2112 LDO also provides an additional amount of control for power to the board. By default, the chip enable pin (EN) is pulled high, to enable the 3.3V output, supply voltage. To disable and shutdown the output voltage from the AP2112, the chip enable pin (EN) needs to be pulled low (i.e. shorted to ground (GND)). For more information, pleas refer to the AP2112 datasheet.

Enable Pin
Enable pin on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Protection

A BAT20J Schottky diode, in the power circuit, provides reverse current protection to the USB-C (VUSB) connector, from the battery (VBAT) or the board.

RP2040 Microcontroller

The Raspberry Pi RP2040 is a low-cost, high-performance microcontroller with flexible digital interfaces. It features:

RP2040 MCU
RP2040 on the SparkFun RP2040 Thing Plus. (Click to enlarge)

The processor implements the ARMv6-M Thumb instruction set and provides programmable (multifunction) IO (PIO), which is unique to the RP2040. For more information, pleas refer to the RP2040 datasheet.

JTAG Pins

Note: Currently there isn't support for the RP2040, using J-Link ARM programmers. The current recommended debug hardware is a second RP2040 microcontroller.

For users interested in debugging their code, the SWD pins are broken out on JTAG PTH pins. On the RP2040, the debug pins are:

JTAG PTH pins
JTAG pins on the SparkFun RP2040 Thing Plus. (Click to enlarge)

An individual debug access port (DAP) to each core is attached to a shared multidrop SWD bus. Each DAP will only respond to debug commands if correctly addressed by a SWD TARGETSEL command. In the event that the RP2040 locks up, a Rescue debug port is available to reset the microcontroller. The default address of each debug port is listed below:

Rescue Debug Port Reset: The RP2040 can be reset through a Rescue Debug Port, allowing users to recover the Thing Plus - RP2040 from a locked up state. A Rescue Debug Port reset configures the PSM_RESTART_FLAG of the CHIP_RESET register and resets the RP2040. On startup, the CHIP_RESET register is read by the bootcode and when set, it causes the RP2040 to enter a safe state.

USB Functionality

The RP2040 contains a USB 2.0 controller that can operate as either:

USB Mass Storage Interface
The Bootrom provides a standard USB bootloader that emulates a writeable drive available for loading firmware to the RP2040 using UF2 files. Once a UF2 file is loaded onto the drive, it is written to the flash or RAM and the device automatically reboots.

RPI-RP2 Drive
The RP2040 appears as a standard 128MB flash drive named RPI-RP2 formatted as a single partition with FAT16. There are only ever two actual files visible on the drive specified.

Note: Any type of files may be written to the USB drive from the host computer, however in general these are not stored, and only appear to be so because of caching on the host side. When a .uf2 file is written to the device however, the special contents are recognized and data is written to specified locations in RAM or Flash. On the completed download of an entire valid .uf2 file, the RP2040 automatically reboots to run the newly downloaded code.

Flash Memory

RP2040 has embedded ROM and SRAM, and access to external flash via a QSPI interface. On the SparkFun RP2040 Thing Plus, an additional 16MB (128Mbit) of 133MHz memory is provided by a W25Q128JVPIM chip. The flash memory is required for the RP2040 to store program code, which it can boot and run from through its dedicated QSPI pins:

Flash Memory
W25Q128JVPIM flash memory on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Note: The RP2040 is able to access up to a 16MB memory window starting at 0x10000000.

Indicator LEDs

There are 4 indication LEDs on the SparkFun RP2040 Thing Plus for:

Power LED

The red, PWR LED will light up once 3.3V is supplied to the board. For most users, it will light up when 5V is supplied through the USB connection and/or when a LiPo battery is attached to the JST connector.

Power LED
SparkFun RP2040 Thing Plus PWR status LED indicator. (Click to enlarge)

Battery Charging LED

The yellow, CHG LED will light while a battery is being charged through the charging circuit. The LED will be off when no battery is present (*or dimmed), when the charge management controller is in standby (after the battery charging has been completed), or when the charge management controller is shutdown (thermal shutdown or when the input voltage is lower than the battery voltage). The LED will be on when the charge management controller is in the process of charging the battery. For more information, please refer to the MCP73831 datasheet.

Charge LED
The battery charging (CHG) LED indicator on the SparkFun RP2040 Thing Plus. (Click to enlarge)
Charge Cycle State STAT1
Shutdown
  • Thermal Shutdown
  • VDD < VBAT
Off (High Z)
No Battery Present* Dimmed (High Z)
Charge Complete – Standby Off (H)
Preconditioning On (L)
Constant-Current Fast Charge On (L)
Constant Voltage On (L)

*The charge LED may appear dimmed due a trickle charge from the MAX17048 fuel gauge. Normally, the LED should be OFF.

Status LED

The blue, 25 LED is typically used as a test or status LED to make sure that a board is working or for basic debugging. This indicator is connected to GPIO 25.

Status LED
The status/test (25) LED indicator on the SparkFun RP2040 Thing Plus. (Click to enlarge)

WS2812 RGB LED

The WS2812 RGB LED is controlled with a 24-bit (GRB) data signal. This indicator is connected to GPIO 08 and the digital output pin from the LED is broken out as the WS2812 pin on the board. For more information, please refer to the WS2812C datasheet.

RGB LED
WS2812 LED indicator on the SparkFun RP2040 Thing Plus. (Click to enlarge)

µSD Slot

Note: To comply with the latest OSHW design practices, on the RP2040 Thing Plus we have replaced the MOSI/MISO nomenclature with SDO/SDI; the terms Master and Slave are now referred to as Controller and Peripheral. The MOSI signal on a controller has been replaced with the title SDO. Please refer to this announcement on the decision to deprecate the MOSI/MISO terminology and transition to the SDO/SDI naming convention.

The SparkFun RP2040 Thing Plus includes an µSD card slot. This is great for data logging applications or storing files. The µSD card slot is connected to the following dedicated GPIO:

SD card slot
µSD card slot on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Buttons

The Thing Plus -RP2040 has two buttons on the board for uploading and running code.

Reset Button

The RESET button is connected to the reset pin and is used to reset the microcontroller without needing to unplug the board.

Reset Button
RESET button on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Boot Button

The BOOT button is used to force the board into BOOTSEL mode, by holding down the BOOT button while connecting the board to a computer through its USB-C connector. Users can then, upload firmware files to the emulated RPI-RP2 USB mass storage device.

Boot Button
BOOT button on the SparkFun RP2040 Thing Plus. (Click to enlarge)

BOOTSEL Mode: Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Holding down BOOT button on SparkFun Thing Plus - RP2040
Hold down BOOT button to enter BOOTSEL mode on The SparkFun Thing Plus - RP2040. (Click to enlarge)

Primary I2C Bus

A (battery) fuel gauge and a Qwiic connector are attached to the primary I2C bus I2C1. The primary I2C bus for this board utilizes the GPIO connections, detailed in the table below:

Connection VDD GND SCL SDA
Pin Number 3.3V GND Pin 9
Pin 35
Pin 8
GPIO 3.3V GND GPIO 07
GPIO 23
GPIO 06

I2C bus
I2C bus components on the SparkFun RP2040 Thing Plus. (Click to enlarge)

Note: The clock line of the I2C bus is tied between pins 9 and 35 (GPIO 07 and GPIO 23). This allows GPIO 16 - GPIO 23 to be aligned on the board's edge, for a consecutive, eight pin bus; useful for things like HDMI.

Shared GPIO pin
Shared pin for GPIO 07 and GPIO 23 on the SparkFun RP2040 Thing Plus. (Click to enlarge)

*Since the two GPIO pins are tied together, they cannot operate simultaneously.

Battery Fuel Gauge

The MAX17048 fuel gauge measures the approximate charge or discharge rate, state of charge (SOC) (based on ModelGauge algorithm), and voltage of a connected battery. Additionally, there is a configurable alert pin functionality for low SOC, 1% SOC, reset, overvoltage, or undervoltage. For more information, pleas refer to the MAX17048 datasheet.

MAX17048 Fuel Gauge
The MAX17048 fuel gauge on the SparkFun RP2040 Thing Plus. (Click to enlarge)
I2C Address 0x36 (7-bit)
0x6C (write)/0x6D (read)
Voltage Measurement Range: 2.5 - 5 V
Precision: ±7.5 mV/Cell
Resolution 1.25 mV/Cell
Current Consumption Sleep: .5 - 2 µA
Hibernate: 3 - 5 µA
Active: 23 - 40 µA
Alert Indicators: Low SOC
1% Change in SOC
Battery Undervoltage/Overvoltage
VRESET Alert
Alert Pin GPIO 24

Qwiic Connector

A Qwiic connector is provided for users to seamlessly integrate with SparkFun's Qwiic Ecosystem.

Qwiic Connector
Qwiic connector on the SparkFun RP2040 Thing Plus. (Click to enlarge)

What is Qwiic?

The Qwiic system is intended a quick, hassle-free cabling/connector system for I2C devices. Qwiic is actually a play on words between "quick" and I2C or "iic".

Features of the Qwiic System

Keep your soldering iron at bay.

Cables plug easily between boards making quick work of setting up a new prototype. We currently offer three different lengths of Qwiic cables as well as a breadboard friendly cable to connect any Qwiic enabled board to anything else. Initially you may need to solder headers onto the shield to connect your platform to the Qwiic system but once that’s done it’s plug and go!

Qwiic Cable and Board

Qwiic cables connected to Spectral Sensor Breakout

Minimize your mistakes.

How many times have you swapped the SDA and SCL wires on your breadboard hoping the sensor will start working? The Qwiic connector is polarized so you know you’ll have it wired correctly, every time, from the start.

The PCB connector is part number SM04B-SRSS (Datasheet) or equivalent. The mating connector used on cables is part number SHR04V-S-B or equivalent. This is a common and low cost connector.

JST Connector

1mm pitch, 4-pin JST connector

Expand with ease.

It’s time to leverage the power of the I2C bus! Most Qwiic boards will have two or more connectors on them allowing multiple devices to be connected.

I2C Jumper

Cutting the I2C jumper will remove the 4.7kΩ pull-up resistors from the I2C bus. If you have many devices on your I2C bus you may want to remove these jumpers.

I2C jumper
I2C pull-up resistor jumper. (Click to enlarge)

Software Overview

The Raspberry Pi foundation provides excellent documentation for the RP2040 on their website. This includes information for users to program the RP204 with MicroPython and C/C++ through the Pico SDK. Arduino, has also announced the release of their Mbed RP2040 Arduino core. The instructions below, are meant to help users setup and utilize the following programming environments on Windows 10 computers:

For utilizing the Pico SDK (C/C++) and MicroPython on Mac OSX and Linux based computers, users can follow the instructions provided by the Raspberry Pi Foundation documentation:

Arduino IDE

Note: For first-time users, who have never programmed before and are looking to use the Arduino IDE, we recommend beginning with the SparkFun Inventor's Kit (SIK), which includes a simpler board like the Arduino Uno or SparkFun RedBoard and is designed to help users get started programming with the Arduino IDE.

Most users will be familiar with the Arduino IDE and it's use. As a point of reference for professional developers who aren't aware, the Arduino IDE is an open-source development environment, written in Java, that makes it easy to write code and upload it to a supported board. For more details, feel free to check out the Arduino website.

To get started with the Arduino IDE, check out the following tutorials:

Installing an Arduino Library

How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Installing Board Definitions in the Arduino IDE

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Installing the RP2040 Board Definition

Install the latest Arduino Mbed OS RP2040 board definitions in the Arduino IDE. Users unfamiliar with the board definition installation process can reference our tutorial below.

Installing Board Definitions in the Arduino IDE

September 9, 2020

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Installation Instructions:

  1. Search for RP2040 in the Boards Manager.

    board manager
    Arduino Mbed OS RP2040 listed in the Boards Manager. (Click to enlarge)

  2. To complete the installation process, selected the Arduino Mbed OS RP2040 core and click on the INSTALL button that appears in the lower, right-hand corner. The board definition and upload tools will be installed automatically; users will notice that this may take a while.

    Note: Users may need to disable their anti-virus software when installing the Arduino Mbed OS RP2040 board definition. We ran into issues, where the installation of the upload tools for the Arduino core were blocked by the anti-virus software. Arduino is already aware of the issue, they are working to get their files white-listed. For more information, users can reference this GitHub issue.

  3. Programming Tip:

    The board may not show up on a COM port, if users who have already programmed their board through a different method. A simple solution is to:

    1. Download the picoprobe.uf2 file from the Raspberry Pi foundation's Pico board documentation page
    2. Copy the picoprobe.uf2 firmware file to the board (while it is in BOOTSEL mode)
    3. If the board isn't automatically listed on a COM port users should reset (or unplug and re-plug in the board to the computer)

    Note: If users have the Arduino IDE's Tools drop down menu open looking for a new COM port to be added, the Arduino IDE doesn't automatically repopulate and update the listed COM ports. To update the available COM ports list, users should close and then re-open the Tools drop down menu and navigate to the available COM ports.

Note: Users trying to access the SD card slot will need to modify the pins_arduino.h file to reconfigure the SPI bus pins. However, this will make the SPI bus inaccessible through the breakout pins (when utilizing the SPI library).

Note: GitHub user earlephilhower has ported an unofficial Arduino core for the RP2040, which is based on the Pico SDK. This is useful for customers who want the functionality of the Pico SDK in the Arduino IDE. Installation instructions are available in the GitHub repository.

Pico SDK

In order to program the RP2040 with C/C++, users will use the Pico SDK (software development kit) provided by the Raspberry Pi Foundation. Additionally, the Raspberry Pi Foundation has written a user manual, which includes software documentation and examples to accompany the Pico SDK. The foundation has also provided online documentation that can be used as a reference manual.

Click to download the Pico (C/C++) SDK from GitHub (zip)

Click to open the Getting Started with Raspberry Pi Pico guide (pdf)

Click to open the Raspberry Pi Pico C/C++ SDK User Manual (pdf)

Getting Started: For novice programmers, we recommend starting off with the Getting Started with Raspberry Pi Pico guide, from the Raspberry Pi Foundation. While the guide is intended for their RP2040 microcontroller board, it contains useful information for getting started with the Pico SDK, building and uploading a program, debugging, and adapting the SDK to a third-party IDE.

Installation: The Raspberry Pi Foundation also provides an installation script to download and setup the Pico SDK on a Raspberry Pi (SBC) single board computer, which can be downloaded from their GitHub repository.

Click to download the Raspberry Pi installation script from GitHub (zip)

Basic Operation: Users programming with the Pico SDK will be creating a project, compiling, and building their code to a .uf2 file, which the SDK generates. The .uf2 firmware file is then copied to the board, when it is in BOOTSEL mode to upload the program.

As documented in the user manual, the Pico C/C++ SDK can be used with various integrated development environments (IDEs). In order to utilize the SDK, users will also need to install a few dependencies. The Raspberry Pi Foundation also provides examples for the basic functionality of the RP2040 in their pico-examples GitHub repository.

Click to download the C/C++ example code files from GitHub (zip)

Pico SDK on Windows 10

Note: The information for below has been compiled based on the information from the following resources:

On Windows 10 computers, the simplest way to get started with the Pico SDK is to use the installation script from the pico-setup-windows GitHub repository.

Users will need to download and use the installation executable files from the releases section:

Installation Instructions:

  1. Use the setup script from the pico-setup-windows GitHub repo
  2. Run the downloaded executable
  3. Utilize the default configurations
  4. Un-select the Clone and build Pico repo completion option before clicking Finish button
  5. Configure the computer system's PATH variables for the installed dependencies:

    User Variables:

    Variable Value
    PICO_SDK_PATH C:\<path to installed Pico folder>\pico-sdk
    Note: Users will need to modify this variable if the Pico folder is moved.
    Path C:\Users\<username>\AppData\Local\Programs\Microsoft VS Code\bin

    System Variables:

    Variable Value
    Path C:\Program Files\CMake\bin
    Path C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major\bin
    Note: The release value 10 2020-q4-major will likely change over time.
    Path C:\Program Files\Git\cmd
    Path C:\Program Files (x86)\GnuWin32\bin
    Path C:\Users\<username>\AppData\Local\Programs\Microsoft VS Code\bin
    Path C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\Hostx86\x86
    Note: The version/release values 2019 and 14.28.29910 will likely change over time.
    Path C:\Program Files\<PythonXx>\
    Note: The version/release value for the Python program will likely change over time.
    Note: The file path may also vary. For the Python 3.6, our file path was:
    C:\Users\<username>\AppData\Local\Programs\Python\Python36-32\
    Path C:\Program Files\<PythonXx>\Scripts\
    Note: The version/release value for the Python program will likely change over time.
    Note: The file path may also vary. For the Python 3.6, our file path was:
    C:\Users\<username>\AppData\Local\Programs\Python\Python36-32\Scripts\

    For more information on configuring the PATH variable, check out the tutorial below:

    Configuring the PATH System Variable

    March 23, 2021

    A simple guide for configuring the PATH variable on Win 10, Mac OSX, and Linux systems.

Build Instructions:

Executing the pico-setup.cmd script will download all the relevant RP2040 GitHub repositories, update all the submodules, and build the examples for the Pico SDK. (Users will need to modify the pico-setup.cmd script to build the examples for the RP2040 Thing Plus and not the Raspberry Pi Pico board.)

  1. Navigate to the installation location of the Pico folder
  2. Modify the pico-setup.cmd script on line 62, replace cmake -G "NMake Makefiles" .. with:
  3. Execute pico-setup.cmd
  4. Users will find the builds for the example code in the pico-examples\build folder. In each of the built example folders, users will find the .uf2 file associated with the individual example.
  5. Once the board is in BOOTSEL mode, user can copy the .uf2 file over to program their board.

MicroPython

The Raspberry Pi Foundation has provided support for the RP2040 microcontroller with MicroPython. Additionally, the Raspberry Pi Foundation has written a user manual, which includes documentation and some basic MicroPython examples.

Click to download MicroPython from GitHub

Click to open the Raspberry Pi Pico Python SDK User Manual

Getting Started: For novice programmers, we recommend starting off with the Get Started with MicroPython on Raspberry Pi Pico book, writtten by the Raspberry Pi Foundation. While the book is intended for their Raspberry Pi Pico board, it contains useful information for getting started with MircoPython, utilizing the REPL (Read–Eval–Print Loop), and several projects.

Note: Users will only need to download MicroPython, if they want to rebuild the .uf2 file or inlude a Python package in their custom build. For more information on MicroPython check out their online documentation and the README.md for the RP2040 port.

Basic Operation: Before users can begin programming with MicroPython, they will need to copy the .uf2 firmware file to the board (while it is in BOOTSEL mode). The latest MicroPython firmware can be downloaded from the RP2040 documentation on the Raspberry Pi Foundation website.

Go to the RP2040 documentation hosted by the Raspberry Pi Foundation

Note: Since this tutorial was written, MicroPython has built and released new firmware specifically for the RP2040 Thing Plus. The latest *.uf2 firmware file can be download from the MicroPython website.

Once copied, the RP2040 should automatically reset. Then users can utilize the REPL (Read–Eval–Print Loop) to interface with the microcontroller directly or use rshell to upload and save their code to the flash memory of the RP2040.

As documented in the user manual, the MicroPython can be used with various integrated development environments (IDEs). In order to utilize the SDK, users will also need to install a few dependencies. The Raspberry Pi Foundation also provides MicroPython examples to accompany the book (noted above), which can be downloaded from their GitHub repository.

Click to download the MicroPython example code files from GitHub (zip)

Read–Eval–Print Loop (REPL)

Note: The RP2040 Thing Plus must be running MicroPython to access and utilize the REPL.

Users can access the REPL with their favorite serial terminal to instantly program the RP2040 microcontroller. After the MicroPython firmware is copied to the board, it will reset and show up on the computer's serial (or COM) port. Make sure to configure the serial terminal emulator for a baudrate of 115200 bps.

Programming with REPL
Programming the RP2040 through the REPL. (Click to enlarge)

Remote MicroPython Shell on Windows 10

Note: The RP2040 Thing Plus must be running MicroPython to utilize rshell and upload your program.

Installation Instructions:

  1. Install prerequisites
  2. Install Remote MicroPython Shell (rshell)

Programming Instructions:
Below is an example of how to upload a program to the board using rshell on Windows 10.

  1. Change the working directory to the location of the program file
  2. Open rshell
  3. In the remote shell, connect to the COM port for the RP2040 Thing Plus
  4. In the remote shell, copy your program file to the RP2040 Thing Plus
  5. Once the user presses the RESET button, the board will disconnect from rshell and the RP2040 microcontroller will execute the boot.py and main.py files stored in its flash.

Uploading with rshell
Uploading a program to the RP2040 using rshell. (Click to enlarge)

Hardware Assembly

USB Programming

The USB connection is utilized for programming and serial communication. Users only need to plug their RP2040 Thing Plus into a computer using a USB-C cable.

The SparkFun Thing Plus - RP2040 attached to a computer. (Click to enlarge)

BOOTSEL Mode

Users can enter BOOTSEL mode by holding down the BOOT button, when the USB connection is made to a computer. The board will remain in this mode until it power cycles (happens automatically after uploading a .uf2 firmware file) or the RESET button is pressed. The board will appear as a USB mass storage device under the name RPI-RP2.

Holding down BOOT button on SparkFun Thing Plus - RP2040
Hold down BOOT button to enter BOOTSEL mode on The SparkFun Thing Plus - RP2040. (Click to enlarge)

Battery

For remote applications, the RP2040 Thing Plus can be powered through its 2-pin JST battery connector. Additionally, users may be interested in utilizing a solar panel and USB-C cable to recharge their battery.

Battery connected to the SparkFun Thing Plus - RP2040
The SparkFun Thing Plus - RP2040 with a battery attached. (Click to enlarge)
Solar Panel Charger - 10W

Solar Panel Charger - 10W

PRT-16835
$18.95 $14.21
1
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
4

Note: DO NOT remove batteries by pulling on their wires. Instead, it is recommended that pair of dikes (i.e. diagonal wire cutters), pliers, or tweezers be used to pull on the JST connector housing, to avoid damaging the battery wiring.

Disconnect battery w/ dikes
Using a pair of dikes to disconnect a battery. (Click to enlarge)

Headers

The pins for the RP2040 Thing Plus are broken out to 0.1"-spaced pins on the outer edges of the board. When selecting headers, be sure you are aware of the functionality you need. If you have never soldered before or need a quick refresher, check out our How to Solder: Through-Hole Soldering guide.

Soldering headers
Soldering headers to the RP2040 Thing Plus.

The Feather Stackable Header Kit is a great option as it allows users to stack shields (w/ Feather footprint) or it can be placed on the a breadboard; while, the pins are still accessible from the female/male headers.

Qwiic Devices

The Qwiic system allows users to effortlessly prototype with a Qwiic compatible I2C device without soldering. Users can attach any Qwiic compatible sensor or board, with just a Qwiic cable. (*The example below, is for demonstration purposes and is not pertinent to the board functionality or this tutorial.)

Qwiic devices connected to SparkFun Thing Plus - RP2040
The Qwiic GPS receiver and distance sensor connected to the SparkFun Thing Plus - RP2040.

MicroPython Examples

Note: The information contained in this section will be expanded upon as more resources become available.

Below, are some MicroPython examples that can be copied and pasted into the REPL.

LED Control

This example turns on the GPIO 25 status LED. Try changing the led.value() value to 0.

language:python
from machine import Pin
led = Pin(25, Pin.OUT)
led.value(1)

# Include blank carriage returns

WS2812 Control

This example controls the WS2812 RGB LED on the board. Try changing the r, g, and b values (range is 0 - 255).

language:python
# Example using PIO to drive a WS2812 LED
// Copy and paste directly into REPL from TeraTerm
// Make sure baudrate is set to 115200 bps

import array, time
from machine import Pin
import rp2

# Configure the number of WS2812 LEDs.
NUM_LEDS = 1


@rp2.asm_pio(sideset_init=rp2.PIO.OUT_LOW, out_shiftdir=rp2.PIO.SHIFT_LEFT, autopull=True, pull_thresh=24)
def ws2812():
T1 = 2
T2 = 5
T3 = 3
wrap_target()
label("bitloop")
out(x, 1)               .side(0)    [T3 - 1]
jmp(not_x, "do_zero")   .side(1)    [T1 - 1]
jmp("bitloop")          .side(1)    [T2 - 1]
label("do_zero")
nop()                   .side(0)    [T2 - 1]
wrap()






# Create the StateMachine with the ws2812 program, outputting on Pin(08).
sm = rp2.StateMachine(0, ws2812, freq=8_000_000, sideset_base=Pin(08))

# Start the StateMachine, it will wait for data on its FIFO.
sm.active(1)

# Display a pattern on the LEDs via an array of LED RGB values.
ar = array.array("I", [0 for _ in range(NUM_LEDS)])

# Cycle colours.
for i in range(4 * NUM_LEDS):
for j in range(NUM_LEDS):
r = 255
b = 255
g = 255
ar[j] = g << 16 | r << 8 | b
sm.put(ar, 8)




# Include blank carriage returns

OLED Displays

This example displays a bitmap and text on two OLED screens. For this example, users will need the Micro OLED Breakout (Qwiic), the Qwiic OLED Display, and a Qwiic cable kit. Users will need to upload a modified version of the MicroPython firmware, which includes the SSD1306 display driver.

OLED demo
An example of the Thing Plus - RP2040 running with two OLED displays. (Click to enlarge)

language:python
# Display Image & text on I2C driven ssd1306 OLED display 
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf

WIDTH_1  = 64                                             # oled display width
HEIGHT_1 = 48                                             # oled display height
WIDTH_2  = 128                                            # oled display width
HEIGHT_2 = 32                                             # oled display height

i2c = I2C(1)                                            # Init I2C using I2C0 defaults, SCL=Pin(GP9), SDA=Pin(GP8), freq=400000
print("I2C Address      : "+hex(i2c.scan()[0]).upper()) # Display device address
print("I2C Configuration: "+str(i2c))                   # Display I2C config


oled1 = SSD1306_I2C(WIDTH_1, HEIGHT_1,  i2c, addr=0x3D)      # Init oled_1 display

# SparkFun logo as 32x48 bytearray
buffer[:] = [\
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0x0F, 0x07, 0x07, 0x06, 0x06, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x07, 0x0F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, \
0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xFD, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x01, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, \
0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, \
0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]


# Load the SparkFUn logo into the framebuffer (the image is 32x48)
fb = framebuf.FrameBuffer(buffer, 64, 48, framebuf.MONO_VLSB)

# Clear the oled display in case it has junk on it.
oled1.fill(0)

# Blit the image from the framebuffer to the oled display
oled1.blit(fb, 0, 0)

# Finally update the oled display so the image & text is displayed
oled1.show()

oled2 = SSD1306_I2C(WIDTH_2, HEIGHT_2,  i2c, addr=0x3C)      # Init oled_2 display

# Clear the oled display in case it has junk on it.
oled2.fill(0)

# Add some text
oled2.text("SparkFun Thing",5,5)
oled2.text("Plus - RP2040",5,15)
oled2.text("(DEV-17745)",5,25)

oled2.show()

# Include blank carriage returns

Resources and Going Further

For more on the RP2040 Development Kit, check out the links below:


learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado