In this post I'll discuss the new offering from the Raspberry Pi Foundation, the Raspberry Pi Pico. It is an interesting product that combines two technologies of great interest: the Raspberry Pi and microcontrollers.
What is a Microcontroller?
A selection of microcontrollers
ICS is currently running a blog series on microcontrollers. Part 1 offers a good overview of what microcontrollers are and how they are reshaping product development. A microcontroller is significantly different from a general purpose computer like a desktop, laptop, or even the Raspberry Pi 4.
Some common characteristics of a microcontroller are:
- Physically small, low cost (as little as US$1), with limited on chip memory and storage.
- Generally has built-in support for interfaces like SPI, I2C, and serial i/o, but not Ethernet, WiFi, or Bluetooth.
- Low power consumption and power-saving modes, making it suitable to run on battery power.
- Lack of support for virtual memory, a GPU (graphics processing unit), and sometimes even an FPU (floating point unit).
- Usually used in headless applications where they are embedded inside products like an automobile, industrial control or medical device.
- Often runs a real-time operating system (RTOS) or no operating system at all (usually referred to as "bare metal").
Given that, it might seem that a microcontroller like the Raspberry Pi Pico has a lot less capabilities than a general purpose computer like the Raspberry Pi 4, but its real strength is when it is used in conjunction with a device like the Pi 4, with the microcontroller performing time-critical functions to offload the main computer. This is sometimes referred to as physical computing, where the microcontroller interfaces with devices such as sensors.
Doing this on the main processor is not desirable as it is typically running many tasks and not able to respond in a timely fashion. Imagine, for example, a car that needs to respond to impact sensors to deploy an airbag, monitor wheel traction to control anti-block brakes, or control engine timing. A failure to respond quickly to these events can have catastrophic consequences.
The Raspberry Pi Pico
The Raspberry Pi Pico is a small microcontroller module based on the RP2040 microcontroller chip. The name is perhaps inspired by the Arduino Nano microcontroller, or because the word starts with Pi. The Pico retails for US$4, although currently you'll be lucky to find one at that price due to high demand.
The Pico has the following key hardware features:
- RP2040 microcontroller chip with 2 MB of flash storage and 264 kB of SRAM.
- Dual-core Cortex M0+ processor running at up to 133 MHz.
- Micro-USB port for power and data and programming of the flash.
- Packaged in a 40-pin DIP style PCB with 0.1" spacing.
- Exposes 26 GPIO pins that support 3.3V digital I/O; three of which can also be analog inputs.
- 12-bit 500ksps analog to digital converter (ADC).
- Two UARTs, two I2C interfaces, two SPI interfaces, and 16 PWM channels.
- Timer with four alarms and real-time counter.
- Two Programmable IO (PIO) blocks with eight state machines supporting user-programmable high-speed IO.
- A 3-pin ARM Serial Wire Debug (SWD) port.
- Can be powered from micro-USB, external power supply or batteries (1.8 to 5.5V).
The Pico officially supports MicroPython, a software implementation of the Python programming language largely compatible with Python 3 that is optimized to run on microcontrollers. Like Python, MicroPython is an easy to use interpreted language - you can even interactively enter and run commands on the device through the serial interface. It also supports C and C++ language APIs ad other languages are being offered by third parties, including CircuitPython.
Programming the Pico's flash can be done using USB. When attached to a desktop computer it appears as a mass storage device and you can simply copy files to it.
The Thonny IDE
The recommended IDE for MicroPython is Thonny, which directly supports programming the Pi Pico from with the IDE. You can use other Python IDEs if you desire, or even just a text editor.
The Visual Studio Code IDE
The recommended C/C++ IDE is Microsoft's Visual Studio Code, which is free and also supports Python. You can use other IDEs as well if you configure them to use the appropriate cross-compiler. It is also expected that the Arduino IDE will support the Pico at some point in the future.
While the SDK has support for using both CPU cores, there is not yet any official RTOS available, although it is likely to be supported by FreeRTOS and others in the near future.
SWD Debug Port
There is a Serial Wire Debug (SWD) port that can be used for programming and debugging, although this requires some additional hardware and software to set up.
Get started with MicroPython on Raspberry Pi Pico
Right from launch day there has been extensive documentation on developing for the Raspberry Pi Pico from MicroPython, C and C++, including the book Get Started With MicroPython on Raspberry Pi Pico, which is available in printed form or as a free download. It is written in the same friendly style as The Official Raspberry Pi Beginner's Guide for the Raspberry Pi 4. There are also extensive tutorials and videos available to help you get started.
What is Surprising About the Raspberry Pi Pico?
Here are the top 10 things I found surprising about this new product from the Raspberry Pi Foundation - elements that made it stand out over similar offerings from the past:
- They were able to keep this a closely guarded secret until launch day, including working with hardware and software partners to have product available for order on the first day. Extensive documentation and software development tools were available on launch day.
- The idea of the Raspberry Pi Foundation releasing a microcontroller was not something that had been rumored or predicted.
- They designed the chip in-house rather than using an off-the-shelf device, despite never having developed a chip before (although they do have close ties to Broadcom which developed the processor on the Raspberry Pi 1 through 4).
- It features unique packaging: soldering on header pins allows it to fit a through-hole printed circuit board (PCB) or being plugged into a standard solderless prototyping breadboard. Without header pins, edge castellations allow it to be surface mounted like a component for high volume automated manufacturing.
- In addition to the Raspberry Pi Pico module, they are also offering the RP2040 microcontroller chip to manufacturers that want to build their own products.
- Rather than competing with their logical competitors in this market, they have partnered with companies like Arduino, Adafruit, and SparkFun to develop RP2040-based products and add-ons.
- The preferred language is MicroPython, which is a good fit for Raspberry Pi developers and students already familiar with Python, while also supporting the more traditional C and C++ programming languages.
- The choice of Visual Studio Code from Microsoft as a C/C++ IDE was somewhat controversial, but is only one of several options available.
- The programming of the device, using USB mass storage, is different from most microcontrollers like Arduino.
- The US$4 price point puts it at a very competitive price/performance ratio, where most low cost microcontrollers are only 8-bit devices, and high-end microcontrollers are significantly more expensive.
What is perhaps not surprising is that the majority of the design is openly available, including hardware schematics, PCB layout, and CAD files. This is similar to what was done for the Raspberry Pi 4. Also not surprising was the fact that, like the Raspberry Pi 4 (and earlier releases), the Pico was an immediate success. Initial stocks quickly sold out. Two months after release they have sold over a million units. (The desktop Raspberry Pi series has now sold more than 38 million units).
Other RP2040-based Products and Add-ons
Adafruit Feather 2040L
As mentioned, the RP2040 chip is being offered to hardware manufacturers and there are already several RP2040-based boards out that offer different features and functionality from the Raspberry Pi Pico. Adafruit is offering their Feather 2040L and Adafruit ItsyBitsy 2040. Arduino is offering the Nano RP2040 Connect. Pimoroni has the Tiny 2040 and SparkFun has the Pro Micro, Thing Plus, and MicroMod RP2040 Processor.
Add-on boards are also becoming available, such as the SparkFun MicroMod Big Display Carrier Board, which allows generating HDMI signals to display graphics on a DVI or HDMI monitor or television.
The Raspberry Pi Pico is significant in terms of its price/performance ratio and its primary market being education and hobbyists (sometimes referred to as makers). It does have a few limitations, such as lack of WiFi, Ethernet and Bluetooth and limited RAM and storage, but there is only so much that can be expected of a $4 device. Some of the other RP2040-based products address these features (at a higher cost). Perhaps the biggest complaint is that it is hard to get your hands on a device due to the high demand!
The Raspberry Pi has also changed the traditional rules by using a different business model based on a non-profit foundation that is partnering with what would have traditionally been its competitors, offering the chip to other vendors and allowing everyone to benefit.
A problem I have encountered with some microcontrollers (e.g. the STM32 and ESP32 series) that are available from multiple vendors is that manufacturers' versions are slightly different. This can cause compatibility problems because board footprints, GPIO pin assignments, and boot loaders can vary and the devices are not fully interchangeable. There are even counterfeit devices on the market that are not what they claim to be. Like the Raspberry Pi 4, there is only one official model of Pi Pico, so compatibility should not be an issue.
The Programmable IO (PIO) feature of the Pico allows supporting user-programmable high-speed IO to do things like implementing video output and SD-card interfaces efficiently in software at the hardware level. I expect we will see some very interesting and creative uses of this capability.
Finally, with the Foundation's focus on education, the Raspberry Pi Pico is a great opportunity to introduce people to physical computing and microcontrollers at low cost with high quality documentation and development tools, preparing a new generation of hardware and software developers for a rapidly growing market that currently has a shortage of skilled developers.
For more on microcontrollers, stay current with our series Microcontrollers are Reshaping Development.