Category Archives: Blog


Small Form Factor RP2040 Boards

Small Form Factor RP2040 Boards

tags: Raspberry Pi RaspberryPi Raspberry Pi Pico RaspberryPiPico RP2040 MicroPython CircuitPython Arduino C/C++ Pimoroni Tiny2040 Tiny 2040 Seeed Seeed Studio XIAO XIAO RP2040 Waveshare RP2040-Zero

Introduction

Given the great potential of the RP2040 chip announced on the 21st of January 2021 as the first microcontroller designed by Raspberry Pi Ltd, more and more boards from different manufacturers have been populating the shelves of enthusiast makers.

About this article

This article will be covering the general characteristics of the RP2040 chip, and introduce three popular small form factor boards that I have been considering for some of my projects to come.

Front

Back


The RP2040 Microcontroller

At the very core of the aforementioned boards there is the RP2040 chip.

Here follows a list of its major characteristics:

Component Description
CPU: Dual ARM Cortex-M0+ @ 133 MHz
Memory: 264kB on-chip SRAM in six independent banks
Storage: Support for up to 16MB of off-chip Flash memory via dedicated QSPI bus
Architecture: DMA controller
Fully connected AHB crossbar
Interpolator and integer divider peripherals
On-chip programmable LDO to generate core voltage
2 × on-chip PLLs to generate USB and core clocks
Interfacing: 30 × GPIO pins, 4 of which can be used as analogue inputs
Peripherals: 2 × UARTs
2 × SPI controllers
2 × I2C controllers
16 × PWM channels
1 × USB 1.1 controller and PHY, with host and device support
8 × PIO state machines
Package: 7 × 7 mm QFN-56 package

Other notable properties include:

  • Supported input power 1.8–5.5V DC
  • Operating temperature -40°C to +85°C
  • Drag-and-drop programming using mass storage over USB
  • Low-power sleep and dormant modes
  • Accurate on-chip clock
  • Temperature sensor
  • Accelerated integer and floating-point libraries on-chip

RP2040 Pinout

Resources

https://www.raspberrypi.com/products/rp2040/specifications/
https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html
https://datasheets.raspberrypi.com/rp2040/rp2040-product-brief.pdf
https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf

^Top


Boards

Since all of the following boards use the same RP2040 microcontroller chip, only the relevant features that have been updated by the respective manufacturers in comparison with the original Raspberry Pi Pico will be listed.

※ Describing the Raspberry Pi Pico is beyond the scope of this article.

Pimoroni Tiny 2040

Overview

Features

Component Description
Board form factor: 16 + 3 pins
Storage: 2MB or 8MB of QSPI flash supporting XiP
Interfacing: 12 × GPIO pins
4 × 12-bit ADC channels
12 × PWM
Peripherals: 2 × I2C
2 × UART
1 × SPI
SWC/SWD pins
Power, programming, data transfer: USB Type-C interface
Castellated pads allows direct soldering onto a PCB
LED: 1 × user controllable RGB LED
Buttons: 1 × BOOT button (doubles up as user input button)
1 × RESET button
Software compatibility: Micropython ・ CircuitPython ・ C/C++ ・ Arduino
Dimensions: 21.3 x 18 mm
approx 22.9 x 18.2 x 6 mm (including the USB-C port)

What makes it stand out

  • 8MB of QSPI flash supporting XiP variant available
  • User input button (doubles up as DFU select on boot)

Resources

Product page: https://shop.pimoroni.com/products/tiny-2040?variant=39560012234835

^Top

Seeed Studio XIAO RP2040

Overview

Features

Component Description
Board form factor: 14 pins
Storage: 2MB of on-board Flash memory
Interfacing: 11 × GPIO pins
4 × 12-bit ADC channels
11 × PWM
Peripherals: 1 × I2C
1 × UART
1 × SPI
1 × SWD Bonding pad
Power & Downloading interface: USB Type-C interface
Castellated pads allows direct soldering onto a PCB
LEDs: 1 × user LED
1 × user WS2812 RGB LED
1 × power LED
2 × LEDs for serial port downloading
Buttons: 1 × BOOT button
1 × RESET button
Power Pads: For the battery power supply
Software compatibility: Micropython ・ CircuitPython ・ C/C++ ・ Arduino
Cover: Cover for protecting the circuit
Dimensions: 20 x 17.5 x 3.5 mm

What makes it stand out

  • No components on the back for seamless SMD integration via castellated pads
  • Small size of 20 x 17.5 x 3.5 mm for wearable devices and small projects
  • 2 × user controllable RGB LEDs

Resources

Product page: https://www.seeedstudio.com/XIAO-RP2040-v1-0-p-5026.html
Wiki: https://wiki.seeedstudio.com/XIAO-RP2040/

^Top

Waveshare RP2040-Zero

Overview

Features

Component Description
Board form factor: 18 + 5 pins + 10 solder points
Storage: 2MB of on-board NOR-Flash memory
Interfacing: 29 × GPIO pins (9 of which via solder points)
4 × 12-bit ADC channels
16 × PWM
Peripherals: 2 × I2C
2 × UART
2 × SPI
8 × PIO state machines
Power, programming, data transfer: USB Type-C interface
Castellated pads allows direct soldering onto a PCB
LED: 1 × user controllable WS2812 RGB LED
Buttons: 1 × BOOT button (doubles up as input button)
1 × RESET button
Software compatibility: Micropython ・ CircuitPython ・ C/C++ ・ Arduino
Dimensions: 23.5 x 18 mm

What makes it stand out

  • 29 × multi-function GPIO pins
  • Full peripherals range support

Resources

Product page: https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-pico-cat/rp2040-zero.htm
Wiki: https://www.waveshare.com/wiki/RP2040-Zero

^Top


Comparison

~

Board Form Factor

  • All of the three boards are contained in a small package that can be easily fit on wearable or space constrained devices, with the smallest of them being the Seeed XIAO RP2040 and the largest being the Waveshare RP2040-Zero.

Storage

  • Other than the standard 2MB on-board flash memory, the Pimoroni Tiny 2040 is also available for purchase in the 8MB variant.

GPIO and Peripherals Interfaces

  • An impressive amount of GPIO pinout has been squeezed onto the Waveshare RP2040-Zero for a total of 29 GPIO and full peripheral support, costing only a marginal increase in form factor size.
  • The Pimoroni Tiny 2040 loses only one of the two SPI peripheral interfaces, although the number or GPIO pins is more than halved down to 12.
  • The board with least amount of available GPIO pins is, understandably, the Seeed XIAO RP2040 with only 11 GPIO pins available, keeping only one interface for each type of supported peripheral.
  • Despite the above differences, each board provides access to all of the 4 ADC channels available on the RP2040 chip.

LED

  • RGB LEDs for visual signalling are available on each board, with the Seeed XIAO RP2040 actually sporting two user controllable RGB LEDs.

Reset Button

  • Each board also comes equipped with a reset button. In this case there is no obvious winner.

SMD Integration

  • SMD integration via castellated pads is a breeze with the Seeed XIAO RP2040 as there are completely no components on the bottom of the board.

^Top


Conclusion

Each board excels on one or more different aspects.
To wrap it up:

  • Pimoroni Tiny 2040:
    • Largest storage (in the 8MB variant)
  • Seeed Studio XIAO RP2040:
    • Smallest form factor
    • 2 × user LEDs
    • SMD friendly
  • Waveshare RP2040-Zero:
    • Most available GPIOs (29)
    • Full range of peripheral interfaces

^Top


Notes

※ The XIAO RP2040 board has been generously donated by Seeed Studio as part of their currently ongoing Free Shipping campaign in 221 countries and counting.

^Top


A Practical Introduction to the Raspberry Pi Pico

A Practical Introduction to the Raspberry Pi Pico

tags: Raspberry Pi RaspberryPi Raspberry Pi Pico RaspberryPiPico MicroPython

Introduction

My name is Salvatore and I am a Development Engineer at 株式会社Rist.

  • Robotics team, responsible for Robotics R&D.
  • Robot design, control, motion, perception and manipulation.
  • Image analysis, recognition and classification.
  • AI algorithms design and implementation.
  • UI/UX design and implementation.

About this article

This article aims to give a quick introduction to the Raspberry Pi Pico, through simple step-by-step instructions to its setup and providing some code examples in MicroPython.

※ No soldering nor external components are required to follow this tutorial~

What is the Raspberry Pi Pico

The Raspberry Pi Pico is a microcontroller able to acquire various inputs and provide outputs through a series of GPIO pins, similar to a Raspberry Pi computer [1][2].
Microcontrollers are most suitable for embedded applications or any other situations in which the use of a full computer running an Operating System would be considered not necessary.

Environment Setup

~

User group

In order to have read/write permission to the serial port created upon connecting the Pico, the current user must belong to the dialout group.
Verify the current groups the user belongs to with:

$ groups

If the user does not belong to the dialout group, add it as follows:

# usermod -a -G dialout $USER

To make the changes effective, relog the current user to the system.

※ A reboot might be needed after performing the operation, in the case which a simple relog would not be sufficient.

Thonny and MicroPython

Proceed with the installation of the Thonny Python IDE [3]:
As of writing this article, the easiest way to get the most updated version of the IDE on a variety of linux distributions is through pip.

$ pip install thonny

※ For more information and other platforms support, visit thonny.org.

Once installed, the Thonny IDE would look similar to:

In order to control the Pico, it is necessary to switch the Python interpreter to MicroPython (Raspberry Pi Pico).

Click on the bottom right corner to switch the interpreter:
Python 3.7.9 > Configure interpreter...
Then select MicroPython (Raspberry Pi Pico) from the combo box list.

Or alternatively, from the Thonny menu, select:
Run > Select interpreter... > Interpreter > MicroPython (Raspberry Pi Pico)

Connecting the Pico to the PC

As the Pico comes out of the box, it needs to be initialised by installing the MicroPython firmware.
This can be done easily from the Thonny IDE itself.

To connect the Pico to the computer:

  1. Press and hold the BOOTSEL button on the Pico
  2. Connect the Pico to the computer via micro USB
  3. Release the BOOTSEL button

The Pico is now connected as a USB mass storage device.

MicroPython firmware installation

By clicking the Stop/Restart button on the Thonny toolbar, the IDE will connect to the Pico and it will prompt for the MicroPython firmware installation.

Proceed with the installation.

At this point, the environment setup is complete.

Code

As mentioned in the introduction, for this tutorial no external component are required.
The provided sample code will make use of the on-board power LED (GPIO 25) and the embedded temperature sensor.

LED test

Let's skip the basic LED on/off/blink tests and try the PWM controlled brightness test instead.

Create a new file and paste the following code [1]:

from machine import Pin, PWM
from time import sleep

pwm = PWM(Pin(25))
pwm.freq(1000)

while True:
    for duty in range(1024, 65025, 2):
        pwm.duty_u16(duty)
        sleep(0.0001)
    for duty in range(65025, 1024, -4):
        pwm.duty_u16(duty)
        sleep(0.0005)

By running this code, the on-board LED will pulse smoothly according to the values specified in the ranges of the duty cycles and the sleep intervals.

※ The value 65025 corresponds to the LED maximum brightness.

Temperature test

For the temperature test, use the following code [4]:

import machine
from time import sleep

sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / 65535

while True:
    reading = sensor_temp.read_u16() * conversion_factor
    temperature = 27 - (reading-0.706)/0.001721
    print(temperature)
    sleep(2)

The temperature measured by the sensor will be printed in the Shell standard output every 2 seconds.

Putting it together

The following code will make the on-board LED pulse with variable speed.

from machine import Pin, PWM
from time import sleep

sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / 65535

pwm = machine.PWM(machine.Pin(25))
pwm.freq(1000)

while True:
    reading = sensor_temp.read_u16() * conversion_factor

    temperature = 27 - (reading-0.706)/0.001721
    print(temperature)

    if temperature < 19:  # Lower threshold
        steps = 16
    elif temperature > 23:  # Higher threshold
        steps = 64
    else:
        steps = temperature

    for duty in range(0, 65025, int(steps**2)):
        pwm.duty_u16(duty)
        sleep(0.001)
    for duty in range(65025, 0, -int(steps**3)):
        pwm.duty_u16(duty)
        sleep(0.05)

The LED will blink in three different ways, depending on the ambient temperature measured by the on-board sensor:

  • Temperature below the lower threshold:
    • The LED pulses at a slow pace
  • Temperature within the thresholds interval:
    • The LED pulses at a pace proportional to the temperature
  • Temperature above the upper threshold:
    • The LED pulses at a fast pace

Adjust the Lower and Higher thresholds to best suit the local environment temperature.

Stand-alone operation

It is time to store the program in the Pico.

File > Save as...
And select Raspberry Pi Pico from the following dialog window:

In order to make the code run upon power up, the file must be named main.py.

※ Safe operating voltages are between 1.8V and 5.5V.

Alternatives

Recently, various boards are taking advantage of the RP2040 chip to provide custom solutions. One of them is the Seeed Studio XIAO RP2040, currently available through a Free Shipping campain in 221 countries and counting.
More on this and other tiny boards soon! Please check it out if you like.

References

[G] https://github.com/slabua/RaspberryPiPico
[Q] https://qiita.com/slabua/items/ed0a49cd587d0c8103b8
[1] https://www.raspberrypi.org/documentation/pico/getting-started/
[2] https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico
[3] https://hsmag.cc/picobook
[4] https://tkrel.com/14899


Kyoto: A map of places to visit

I thought to share a map of Kyoto points of interest I created some time ago. It mostly contains locations of temples, but it also includes other places I found interesting to visit.

The map is dinamically linked from my google account, so whenever I'll add more places, they will automatically appear on this post as well. I realise that, for an easier reading of the map, I should change the pin appearance depending on the type of location pinned on the map, but this is something I'll try to do later, if I find some spare time.
(more…)


Growing a Durian tree

Back from my second round in Hong Kong and I brought back some nice Durian seeds to try to plant. After about two months in the soil, a little plant has come out and in three weeks since then it has grown up to 14 cm already!
Here some more pics of my little growing Durian tree.

 

 

 


First steps to Hong Kong: Booking

I finally - after more than six months of planning and now almost too late - booked the flight and the hotel for my long awaited stay in Hong Kong. Departure and arrival dates are planned for the 2011.06.06 and 2011.06.23, respectively.
Booking them by myself thru Alitalia (flight) and Agoda (hotel) websites made me save more than 1k of good euros over the agency flight+hotel package price.