Hello everyone and welcome back to another Friday Product Post, filled with Raspberry Pi-powered products! We lead the week off with new versions of our popular Raspberry Pi 4 kits, but we now offer them without Raspberry Pi 4s. This way, if you already own a Raspberry Pi 4, you have an option to cut some costs and use the Pi you are most familiar with! Speaking of "Powered by Pi," earlier in the week we also co-launched new HNT Hotspot Miners from Nebra, both of which are controlled by a Raspberry Pi Compute Module at their cores. We round out the day with a new Qwiic-enabled version of our Soil Moisture Sensor. Now, let's jump in and take a closer look at each of this week's new products!
Check it out: the SparkFun Raspberry Pi 4 Basic Kit, Hardware Starter Kit and Desktop Kits now all have options without RPi4s. We've received multiple requests to start carrying our in-house Raspberry Pi 4 kits without one, so you will be able to choose which board you want to use and to save a few bucks if you don't want to buy a whole new Pi.
Earn HNT cryptocurrency by mining Helium and building coverage for The People’s Network using the Nebra Outdoor and Indoor HNT Hotspot Miners. Anyone can join The People's Network, and provide hundreds of square miles of wireless network coverage while mining HNT on the Helium Blockchain just as hotspot miners do.
The Indoor HNT Hotspot Miner is expected to start shipping as soon as March 2021, while the Outdoor HNT Hotspot Miner is due to start shipping in April 2021. Since both are available for pre-order only, each order will be fulfilled in the order they are received. If you are ordering this product alongside live/in-stock products and want to receive these products ASAP, be sure to designate your order for split shipments in checkout.
The SparkFun Qwiic Soil Moisture Sensor is a simple breakout for measuring the moisture in soil and similar materials. The soil moisture sensor is pretty straightforward to use. The two large, exposed pads function as probes for the sensor, together acting as a variable resistor. The more water in the soil, the better the conductivity between the pads will be, resulting in a lower resistance and a higher SIG out. This version of the Soil Moisture Sensor includes a Qwiic connector, making it even easier to use this sensor!
That's it for this week! As always, we can't wait to see what you make! Shoot us a tweet @sparkfun, or let us know on Instagram or Facebook. We’d love to see what projects you’ve made! Please be safe out there, be kind to one another, and we'll see you next week with even more new products!
The new Raspberry Pi Pico is very different from a traditional Raspberry Pi. Pico is a microcontroller, rather than a microcomputer. Unlike a Raspberry Pi it’s a platform you develop for, not a platform you develop on.
But you still have choices if you want to develop for Pico, because there is both a C/C++ SDK and an official MicroPython port. Beyond that there are other options opening up, with a port of CircuitPython from Adafruit and the prospect of Arduino support, or even a Rust port.
Here I’m going to talk about how to get started with the C/C++ SDK, which lets you develop for Raspberry Pi Pico from your laptop or Raspberry Pi.
I’m going to assume you’re using a Raspberry Pi; after all, why wouldn’t you want to do that? But if you want to develop for Pico from your Windows or Mac laptop, you’ll find full instructions on how to do that in our Getting Started guide.
Blinking your first LED
When you’re writing software for hardware, the first program that gets run in a new programming environment is typically turning an LED on, off, and then on again. Learning how to blink an LED gets you halfway to anywhere. We’re going to go ahead and blink the onboard LED on Pico, which is connected to pin 25 of the RP2040 chip.
We’ve tried to make getting started with Raspberry Pi Pico as easy as possible. In fact, we’ve provided some pre-built binaries that you can just drag and drop onto your Raspberry Pi Pico to make sure everything is working even before you start writing your own code.
Go to the Getting Started page and click on the “Getting started with C/C++” tab, then the “Download UF2 file” button in the “Blink an LED” box.
A file called blink.uf2 will be downloaded to your computer. Go grab your Raspberry Pi Pico board and a micro USB cable. Plug the cable into your Raspberry Pi or laptop, then press and hold the BOOTSEL button on your Pico while you plug the other end of the micro USB cable into the board. Then release the button after the board is plugged in.
A disk volume called RPI-RP2 should pop up on your desktop. Double-click to open it, and then drag and drop the UF2 file into it. The volume will automatically unmount and the light on your board should start blinking.
Congratulations! You’ve just put code onto your Raspberry Pi Pico for the first time. Now we’ve made sure that we can successfully get a program onto the board, let’s take a step back and look at how we’d write that program in the first place.
Getting the SDK
Somewhat unsurprisingly, we’ve gone to a lot of trouble to make installing the tools you’ll need to develop for Pico as easy as possible on a Raspberry Pi. We’re hoping to make things easier still in the future, but you should be able to install everything you need by running a setup script.
However, before we do anything, the first thing you’ll need to do is make sure your operating system is up to date.
$ sudo apt update
$ sudo apt full-upgrade
Once that’s complete you can grab the setup script directly from Github, and run it at the command line.
The script will do a lot of things behind the scenes to configure your Raspberry Pi for development, including installing the C/C++ command line toolchain and Visual Studio Code. Once it has run, you will need to reboot your Raspberry Pi.
$ sudo reboot
The script has been tested and is known to work from a clean, up-to-date installation of Raspberry Pi OS. However, full instructions, along with instructions for manual installation of the toolchain if you prefer to do that, can be found in the “Getting Started” guide.
Once your Raspberry Pi has rebooted we can get started writing code.
Writing code for your Pico
There is a large amount of example code for Pico, and one of the things that the setup script will have done is to download the examples and build both the Blink and “Hello World” examples to verify that your toolchain is working.
But we’re going to go ahead and write our own.
We’re going to be working in the ~/pico directory created by the setup script, and the first thing we need to do is to create a directory to house our project.
$ cd pico
$ ls -la
drwxr-xr-x 9 pi pi 4096 Jan 28 10:26 .
drwxr-xr-x 19 pi pi 4096 Jan 28 10:29 ..
drwxr-xr-x 12 pi pi 4096 Jan 28 10:24 openocd
drwxr-xr-x 28 pi pi 4096 Jan 28 10:20 pico-examples
drwxr-xr-x 7 pi pi 4096 Jan 28 10:20 pico-extras
drwxr-xr-x 10 pi pi 4096 Jan 28 10:20 pico-playground
drwxr-xr-x 5 pi pi 4096 Jan 28 10:21 picoprobe
drwxr-xr-x 10 pi pi 4096 Jan 28 10:19 pico-sdk
drwxr-xr-x 7 pi pi 4096 Jan 28 10:22 picotool
-rw-r--r-- 1 pi pi 60667760 Dec 16 16:36 vscode.deb
$ mkdir blink
$ cd blink
Now open up your favourite editor and create a file called blink.c in the blink directory.
Then copy the pico_sdk_import.cmake file from the external folder in your pico-sdk installation to your test project folder.
$ cp ../pico-sdk/external/pico_sdk_import.cmake .
You should now have something that looks like this:
$ ls -la
drwxr-xr-x 2 pi pi 4096 Jan 28 11:32 .
drwxr-xr-x 10 pi pi 4096 Jan 28 11:01 ..
-rw-r--r-- 1 pi pi 398 Jan 28 11:06 blink.c
-rw-r--r-- 1 pi pi 211 Jan 28 11:32 CMakeLists.txt
-rw-r--r-- 1 pi pi 2721 Jan 28 11:32 pico_sdk_import.cmake
We are ready to build our project using CMake.
$ mkdir build
$ cd build
$ export PICO_SDK_PATH=../../pico-sdk
$ cmake ..
If all goes well you should see a whole bunch of messages flash past in your Terminal window and a number of files will be generated in the build/ directory, including one called blink.uf2.
Just as we did before with the UF2 file we downloaded from the Getting Started page, we can now drag and drop this file on to our Pico.
Unplug the cable from your Pico, then press and hold the BOOTSEL button on your Pico and plug it back in. Then release the button after the board is plugged in.
The RPI-RP2 disk volume should pop up on your desktop again. Double-click to open it, then open a file viewer in the pico/blink/build/ directory and drag and drop the UF2 file you’ll find there on to the RPI-RP2 volume. It will automatically unmount, and the light on your board should start blinking. But this time it will blink a little bit differently from before.
Try playing around with the sleep_ms( ) lines in our code to vary how much time there is between blinks. You could even take a peek at one of the examples, which shows you how to blink the onboard LED in Morse code.
One way to convince yourself that the program running on your Pico is the one we just built is to use something called picotool. Picotool is a command line utility installed by the setup script that is a Swiss Army knife for all things Pico.
Go ahead and unplug your Pico from your Raspberry Pi, press and hold the BOOTSEL button, and plug it back in. Then run picotool.
$ sudo picotool info -a
description: First Blink
binary start: 0x10000000
binary end: 0x10003344
Fixed Pin Information
25: On-board LED
sdk version: 1.0.0
build date: Jan 28 2021
build attributes: Release
flash size: 2048K
ROM version: 1
You’ll see lots of information about the program currently on your Pico. Then if you want to start it blinking again, just unplug and replug Pico to leave BOOTSEL mode and start your program running once more.
Picotool can do a lot more than this, and you’ll find more information about it in Appendix B of the “Getting Started” guide.
Using Visual Studio Code
So far we’ve been building our Pico projects from the command line, but the setup script also installed and configured Visual Studio Code, and we can build the exact same CMake-based project in the Visual Studio Code environment. You can open it as below:
$ cd ~/pico
$ export PICO_SDK_PATH=/home/pi/pico/pico-sdk
Chapter 6 of the Getting Started guide has full details of how to load and compile a Pico project inside Visual Studio Code. If you’re used to Visual Studio Code, you might be able to make your way from here without much extra help, as the setup script has done most of the heavy lifting for you in configuring the IDE.
What’s left is to open the pico/blink folder and allow the CMake Tools extension to configure the project. After selecting arm-none-eabi as your compiler, just hit the “Build’ button in the blue bottom bar.
While we recommend and support Visual Studio Code as the development environment of choice for developing for Pico — it works cross-platform under Linux, Windows, and macOS and has good plugin support for debugging — you can also take a look at Chapter 9 of the Getting Started guide. There we talk about how to use both Eclipse and CLion to develop for Pico, and if you’re more used to those environments you should be able to get up and running in either without much trouble.
If you’ve got this far, you’ve built and deployed your very first C program to your Raspberry Pi Pico. Well done! The next step is probably going to be saying “Hello World!” over serial back to your Raspberry Pi.
From here, you probably want to sit down and read the Getting Started guide I’ve mentioned throughout the article, especially if you want to make use of SWD debugging, which is discussed at length in the guide. Beyond that I’d point you to the book on the C/C++ SDK which has the API-level documentation, as well as a high-level discussion of the design of the SDK.
Support for developing for Pico can be found on the Raspberry Pi forums. There is also an (unofficial) Discord server where a lot of people active in the new community seem to be hanging out. Feedback on the documentation should be posted as an Issue to the pico-feedback repository on Github, or directly to the relevant repository it concerns.
All of the documentation, along with lots of other help and links, can be found on the same Getting Started page from which we grabbed our original UF2 file.
If you lose track of where that is in the future, you can always find it from your Pico: to access the page, just press and hold the BOOTSEL button on your Pico, plug it into your laptop or Raspberry Pi, then release the button. Go ahead and open the RPI-RP2 volume, and then click on the INDEX.HTM file.
Hi everyone! We’re excited to share that our friends at Elektor Magazine have a new subscriber promo that they would like to extend to the SparkFun community! Choose a one-year digital or print subscription and get one free edition. Simply go to their site to get more information and choose your membership.
If you haven’t heard of Elektor, they offer a great magazine full of the latest news, product tests and DIY projects. In addition to a bi-monthly magazine (six editions a year), subscribers also have access to Elektor’s extensive edition archive (the English archive goes back to 1974, so that’s a lot of additional material if you’re looking for something else to binge during quarantine)!
Check out a free article below, or head over to their page for subscription information and promo rules!
The Raspberry Pi Pico board announced today is not yet another slightly different Raspberry Pi board. No, the Raspberry Pi Pico is a microcontroller module based on, and this is the big news, an RP2040 microcontroller. Why is this big news? Because this microcontroller was designed by Raspberry Pi!
“It’s a flexible product and platform,” says Nick Francis, Senior Engineering Manager at Raspberry Pi, when discussing the work the Application-Specific Integrated Circuit (ASIC) team put into designing RP2040, the microcontroller at the heart of Raspberry Pi Pico.
It would have been easy to have said, well, let’s do a purely educational microcontroller “quite low-level, quite limited performance,” he tells us. “But we’ve done the high-performance thing without forgetting about making it easy to use for beginners. To do that at this price point is really good.”
“I think we’ve done a pretty good job,” agrees James Adams, Chief Operating Officer at Raspberry Pi. “We’ve obviously tossed around a lot of different ideas about what we could include along the way, and we’ve iterated quite a lot and got down to a good set of features.”
A board and chip
“The idea is it’s [Pico] a component in itself,” says James. “The intent was to expose as many of the I/O (input/output) pins for users as possible, and expose them in the DIP-like (Dual Inline Package) form factor, so you can use Raspberry Pi Pico as you might use an old 40-pin DIP chip. Now, Pico is 2.54 millimetres or 0.1 inch pitch wider than a ‘standard’ 40-pin DIP, so not exactly the same, but still very similar.
“After the first prototype, I changed the pins to be castellated so you can solder it down as a module, without needing to put any headers in. Which is, yes, another nod to using it as a component.”
Getting the price right
“One of the things that we’re very excited about is the price,” says James. “We’re able to make these available cheap as chips – for less than the price of a cup of coffee.”
“It’s extremely low-cost,” Nick agrees. “One of the driving requirements right at the start was to build a very low-cost chip, but which also had good performance. Typically, you’d expect a microcontroller with this specification to be more expensive, or one at this price to have a lower specification. We tried to push the performance and keep the cost down.”
Raspberry Pi Pico also fits nicely into the Raspberry Pi ecosystem: “Most people are doing a lot of the software development for this, the SDK (software development kit) and all the rest of it, on Raspberry Pi 4 or Raspberry Pi 400,” James explains. “That’s our primary platform of choice. Of course, we’ll make it work on everything else as well. I would hope that it will be as easy to use as any other microcontroller platform out there.”
Eben Upton on RP2040
“RP2040 is an exciting development for Raspberry Pi because it’s Raspberry Pi people making silicon,” says Eben Upton, CEO and co-founder of Raspberry Pi. “I don’t think other people bring their A-game to making microcontrollers; this team really brought its A-game. I think it’s just beautiful.
“What does Raspberry Pi do? Well, we make products which are high performance, which are cost-effective, and which are implemented with insanely high levels of engineering attention to detail – and this is that. This is that ethos, in the microcontroller space. And that couldn’t have been done with anyone else’s silicon.”
Issue #102 of The MagPi Magazine is out NOW
Never want to miss an issue? Subscribe to The MagPi and we’ll deliver every issue straight to your door. Also, if you’re a new subscriber and get the 12-month subscription, you’ll get a completely free Raspberry Pi Zero bundle with a Raspberry Pi Zero W and accessories.
Customer and forum user Brian Gormanly (known as bg305 on our forum) just released the first video in his new Arduino Lab Series: Introduction to Robotics: Building an Autonomous Mobile Robot. Brian writes, “Throughout this series we will be introducing topics on building and programming an autonomous mobile robot! You can follow along with each lab adding amazing new behaviors to your robot projects and learning the algorithms and tuning techniques that produce incredible robots!”
Brian is using our new 3pi+ 32U4 Robot in his videos and from the first video, it looks like the series will be a great introduction to robotics and the 3pi+! Subscribe to Brian’s channel Coding Coach so you can make sure to catch each video as it is released.