Stephen Smith's Blog

Musings on Machine Learning…

Adafruit Feather RP2040 First Impressions

with 6 comments


Introduction

Last week we talked about the Raspberry Pi’s entry into the microcontroller market with their new RP2040 chip. I had ordered a couple of these, but had yet to receive one. Last Wednesday I received my Adafruit Feather RP2040, this is Adafruit’s entry into this market using Raspberry’s new ARM based RP2040 microcontroller. In this article, I’ll give my first impressions of this Adafruit board, with the caveat that I’ve only had it two days now.

The Adafruit board is similar to the Raspberry Pi Pico, but it is in the form factor for Adafruit’s feather line of peripherals. This means you can stack and intermix the peripherals just like with any other feather microcontrollers. This means the pins correspond to the feather specification rather than those on the Raspberry Pi Pico. This is good since it means you have a large selection of peripherals that are easy to use and pretty much snap together. Further Adafruit has done a good job of providing Python drivers for all their devices. Beyond this, the Adafruit board has a connector for a battery and will manage running off the battery, or charging the battery when connected via USB. The Adafruit board also has an RGB LED that programs can use and a reset button in addition to the boot selection button.

Painful Shipping

The best thing about the Adafruit board was that it was the first RP2040 board that I found that I could actually order, no waiting list, no back order. Kudos, it actually shipped later in the day I ordered it on. The bad news was that the only shipping option was DHL at the exorbitant price of $20USD. I think a lot of companies that sell inexpensive microcontroller parts, usually at around $5 USD each, make all their money by overcharging for shipping. DHL used to be good when they had a big contract to do deliveries for Amazon, then they delivered here reliably every day. Since they lost the Amazon contract, they don’t even deliver to our community and as a result it took an extra four days for the package to get to Gibsons from Vancouver, because they reshipped it with a different courier company and were slow about the process. If Adafruit had an option to use the regular post, it would have been cheaper and would have gotten here quicker. They could have still overcharged for it, but perhaps not as much.

Unboxing

I ordered a few extras along with the Adafruit board, namely a FeatherWing 128×32 OLED display and a lithium ion battery and connector cables. This all arrived in a cardboard box full of bubble wrap with the actual parts safely tucked inside.

I saw that a Raspberry Pi Pico connects to your computer via a micro-USB cable, so I had one of these ready. Picking up the Adafruit RP2040 revealed it uses a USB-C cable, so I had to run upstairs and dig one of these out. This highlights that if there are easy choices in the board design, Adafruit chooses the alternative to what Raspberry chose, I guess to differentiate themselves. Anyway, plugging in the Adafruit to my Raspberry Pi worked, namely it displayed in the Raspberry Pi as a removable disk drive, showing a view to the 8MB flash ROM where you copy your programs to run. Yay, it is working. Next I installed CircuitPython and ran a test program that blinks one of the LEDs on the board. I’ll talk more about CircuitPython after a bit of soldering.

Assembly Requires Soldering

The nice thing about the Arduino Uno and regular Raspberry Pi’s is that they are easy to attach to breadboards for prototyping and experimenting with electronics, everything just snaps together, no soldering required. That isn’t true for either the Adafruit Feather nor the Raspberry Pi Pico. If you want to use a breadboard, you need to solder some pins to them. Both Adafruit and Raspberry have excellent tutorials on how to do this. It was a bit intimidating, since I have a cheap $10 soldering iron from Canadian Tire and the board is very small. Another good thing about the Adafruit RP2040 (and the OLED display board) is that they come with the pins you need for this (you need to order these separately for the Raspberry Pi Pico).

Anyway I went ahead to do this and it turned out to be easier than expected. Heat the pin up with the soldering iron first and then the solder easily flows into position. A bit of a relief since Adafruit recommends buying a $200 soldering iron.

Perhaps down the road, either the various board makers or the companies that assemble kits from these will include an option where these are already soldered in place and perhaps integrated with a breadboard, like the official Arduino Uno starter kit. I see other Adafruit feather boards can be ordered with or without the pins installed, so perhaps they’ll have this available soon.

The reason these pins aren’t automatically built in place, is that this leaves makers a lot of options to package their final products into much smaller packages, since you can solder wires and devices directly to these points.

CircuitPython

The Raspberry Pi tutorial and documentation is all oriented around MicroPython and then the Adafruit documentation and tutorials are all oriented around CircuitPython. CircuitPython is based on Micropython, but taken by Adafruit and made a bit easier to use, especially if you use Adafruit devices. These RP2040 boards basically run one program, so to run Python you need to install the Python runtime to be that one program. To do this you download the CircuitPython UF2 file from Adafruit’s website and copy it to the board’s flash ROM. The board then reboots and the removable drive changes to be a folder inside the CircuitPython environment where you copy your Python program to run. Basically if you copy a file called code.py to this folder then it will be run. You can use the bootsel button to boot into the original view, if you want to later replace the Python runtime with something else.

To actually develop, you need a Python IDE running on a proper computer. Raspberry recommends using Thonny and Adafruit recommends using mu-editor. Thonny comes pre-installed on the Raspberry Pi OS, but adding mu-editor was easy, since it is written in Python, you install it with pip3:

pip3 install mu-editor==1.1.0b3

With this I could cut/paste the blink program from the Adafruit tutorial in and save it as code.py to the device and see the LED on the board flashing. The CircuitPython runtime provides a serial connection back to the IDE via the USB port, so if you click the “Serial” button in the IDE you can see the Python console. At this point you can control Python to some degree through the command line as well as see the output from print statements.

Next up, I connected up the OLED display and wanted to get this to try. Below is a picture of the two devices connected together on a breadboard.

I copy/pasted the Python code for this from another Adafruit tutorial, saved it to the board and nothing happened. Looking at the serial port showed I was getting missing library errors. Of course the next step in the tutorial is to download all  the device specific CircuitPython libraries. Adafruit provides a bundle of all the drivers for their devices, so I downloaded this.

First I tried just copying the libraries I thought I needed, but I didn’t have much luck and kept getting errors. Then I just copied all the libraries and then everything worked as shown in the above photo. The whole library takes 1.9Meg of the 8Meg Flash ROM, so I might try deleting some later.

To give a flavour of CircuitPython programming, below is the sample program to display “Hello World!” in a box on the display:

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
“””
This test will initialize the display using displayio and draw a solid white
background, a smaller black rectangle, and some white text.
“””

import board
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306

displayio.release_displays()
i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)

# Make the display context

splash = displayio.Group(max_size=10)
display.show(splash)
color_bitmap = displayio.Bitmap(128, 32, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF  # White
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle

inner_bitmap = displayio.Bitmap(118, 24, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000  # Black
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=4)
splash.append(inner_sprite)

# Draw a label

text = “Hello World!”
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=28, y=15)
splash.append(text_area)

while True:
    pass

Summary

The Adafruit Feather RP2040 is a good choice for a more powerful ARM based microcontroller. Its advantage over the Raspberry Pi Pico is the feather hardware ecosystem. Many people will also find the battery connector convenient, since many people will want their final build running off a rechargeable battery. Adafruit has done a good job getting all their CircuitPython support going and there is quite a bit of documentation and tutorials on their website.

I haven’t gotten the RP2040 C/C++ SDK going with the Adafruit board yet, but there is support for this board in the SDK, with a header file of all the pin definitions. For people using this SDK, you can program in 32-bit ARM Assembly Language and might want to consider my book “Raspberry Pi Assembly Language Programming”.

Written by smist08

April 2, 2021 at 11:16 am

6 Responses

Subscribe to comments with RSS.

  1. I hope you consider writing an assembly tutorial for the RP2040. Thank you.

    jlgreer1

    April 2, 2021 at 1:41 pm

  2. […] Last week, I blogged about Adafruit’s Feather RP2040 microcontroller. I’ve now received a Raspberry Pi Pico which is also based on the ARM RP2040 processor. The Adafruit version is oriented around programming with CircuitPython and then interfacing to the various companion boards in Adafruit’s Feather lineup. The Raspberry Pi Pico is oriented around programming in C/C++ using the Raspberry Pico SDK and then designing interfaces to other devices yourself. Although you can do either with both boards, I’m going by the direction of the two companies tutorials and volume of documentation. The Raspberry Pi Pico also favours doing your development from a full Raspberry Pi, although you can use a Windows, Linux or Mac, it is quite a bit harder to setup serial communications and debugging. […]

  3. Any idea how long it will run off the battery? Are we talking hours, or maybe a few days?

    John V

    June 25, 2021 at 7:54 am

  4. […] has since appeared on the boards from various other hardware vendors. Previously, we discussed the Adafruit Feather RP2040 and in this article is about Seeed Studio’s Wio RP2040 which is another of these boards. The […]

  5. […] in the Raspberry Pi Pico along with boards from several other manufacturers such as Seeed Studios, AdaFruit, Arduino and […]


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.