Getting Started with the Raspberry Pi RP2040 Microcontroller
The Raspberry Pi RP2040 is a custom silicon microcontroller built by the Raspberry Pi Foundation. The RP2040 is used in the Raspberry Pi Pico with a retail list prices of $4. With 264K SRAM, it has around 100 times the RAM of an Arduino Uno (2K). It is ideal for projects that need more RAM such as projects that require drawing to an OLED display.
- RP2040 microcontroller chip designed by Raspberry Pi Foundation
- Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz
- 264KB of SRAM, and 2MB of on-board Flash memory
- Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus
- DMA controller
- Interpolator and integer divider peripherals
- Castellated module allows soldering direct to carrier boards
- USB 1.1 and PHY with device and host support
- Low-power sleep and dormant modes
- Drag-and-drop programming using mass storage over USB
- 26 × multi-function GPIO pins
- 3 12 bit analogue inputs
- 16 controllable PWM channels
- 2 SPI, 2 I2C, and 2 UART channels
- Accurate clock and timer on-chip
- 8 Raspberry Pi Programmable I/O (PIO) state machines
- Temperature sensor
- Accelerated floating-point libraries on-chip
- 8 × Programmable I/O (PIO) state machines for custom peripheral support
- Created using the TSMC 40LP (40 nano meter low power) manufacturing process
- USB mass-storage boot mode with UF2 support, for drag-and-drop programming
The Raspberry Pi Pico uses a USB-micro connector. You can purchase USB Micro-B to USB-A or USB-C (Mac) cables on e-bay for under $2 or for $5 at Microcenter. - image from ebay
The pinout diagram for the Raspberry Pi Pico is shown below.
It features: * 26 × multi-function GPIO pins * 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM
Raspberry Pi Pico’s 40 pins with pin 1 in the upper right corner with the USB connector at the top. The pin numbers are incremented as you go counterclockwise around the board. You go down the left side and then continue up on the right side until you get to pin 40 in the upper right corner.
When you program the Pico, you use the
machine.Pin() but you always use the GP* number, never the pin number on the board pin numbers.
The diagram above shows the top view where pins 1, 2 and 40 are printed next to the pins.
Next to each pin is the primary label of what the pin does. Pins 3, 8, 13, 18, 23, 28, 33 and 38 with the black background are all GND pins.
Pins are numbered 0-29, and 26-29 have ADC capabilities Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN
|V3||3.3 volts power||A source of 3.3 V power, the same voltage your Pico runs at internally, generated from the VSYS input. This power supply can be switched on and off using the 3V3_EN pin above it, which also switches your Pico off.|
|VSYS||~2-5 volts power||A pin directly connected to your Pico’s internal power supply, which cannot be switched off without also switching Pico off.|
|VBUS||5 volts power||A source of 5 V power taken from your Pico’s micro USB port, and used to power hardware which needs more than 3.3 V.|
|GND||0 volts ground||A ground connection, used to complete a circuit connected to a power source. Several of these pins are dotted around your Pico to make wiring easier.|
|GPxx||General-purpose input/output pin number ‘xx||The GPIO pins available for your program, labelled ‘GP0’ through to ‘GP28’.|
|GPxx_ADCx||General-purpose input/output pin number ‘xx’, with analogue input number ‘x’||A GPIO pin which ends in ‘ADC’ and a number can be used as an analogue input as well as a digital input or output – but not both at the same time.|
|ADC_VREF||Analogue-to-digital converter (ADC) voltage reference||A special input pin which sets a reference voltage for any analogue inputs.|
|AGND||Analogue-to-digital converter (ADC) 0 volts ground||A special ground connection for use with the ADC_VREF pin.|
|RUN||Enables or disables your Pico||The RUN header is used to start and stop your Pico from another microcontroller.|
Steps To Get Micropython Running on the Mac
- Download the MicroPython UF2 file.
- Push and hold the BOOTSEL button and plug your Pico into the USB port of your Raspberry Pi or other computer. Release the BOOTSEL button after your Pico is connected. It will mount as a Mass Storage Device called RPI-RP2.
- Drag and drop the MicroPython UF2 file onto the RPI-RP2 volume. Your Pico will reboot. You are now running MicroPython.
Thonny is a free lightweight Python development tool.
- Download the Thonny Application
- Download the Thonny Pico driver
- Configure Thonny to use the Pico interpreter
- Test using the help() function
- Test by running a blink application
1 2 3 4 5 6 7
Getting The Bootloader Running from the Thonny Python Shell
Although you can hold down the BOOTSEL button as you are plugging in the Pico, there is a much easier way. Just type the following into the Thonny shell:
This will make the Pico go into the Bootloader Mode and mount the file system. You can then copy the bootloader file using the drag-and-drop from your file system or use a UNIX copy command. Once the copy is finished the Pico will automaticaly restart using the new uf2 file.
Using the Onboard LED
1 2 3 4
1 2 3 4 5 6 7 8 9
Getting Started Guide
MicroPython RP2040 Reference
MicroPython RP2040 Quick Reference - this web page has details on how MicroPython was ported to the RP2040 Microcontroller.
Raspberry Pi Book PDF Download from HackSpace Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)