Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Raspberry Pi Pico DIY Workshop
Raspberry Pi Pico DIY Workshop

Raspberry Pi Pico DIY Workshop: Build exciting projects in home automation, personal health, gardening, and citizen science

Arrow left icon
Profile Icon Sai Yamanoor Profile Icon Srihari Yamanoor
Arrow right icon
€21.99 €31.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
eBook May 2022 376 pages 1st Edition
eBook
€21.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Sai Yamanoor Profile Icon Srihari Yamanoor
Arrow right icon
€21.99 €31.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (3 Ratings)
eBook May 2022 376 pages 1st Edition
eBook
€21.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€21.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi Pico DIY Workshop

Chapter 1: Getting Started with the Raspberry Pi Pico

In this chapter, we would like to delve into a quick introduction to the Raspberry Pi Pico and the RP2040 microcontroller. We will discuss the Raspberry Pi Pico's features, the RP2040's peripherals, the add-on hardware for the Pico, and development boards for the RP2040 developed by other makers. We will also discuss the programming language options available for the Pico and supplement the chapter by discussing a simple "Hello World" example where we print something to the screen and blink a light-emitting diode (LED).

By the end of this first chapter, you will have gotten started with the Pico and will be ready to start programming the RP2040 microcontroller and start planning to implement projects from the later chapters of this book, as well as thinking ahead to how you can tackle your own projects with the Raspberry Pi Pico!

We are going to cover the following main topics:

  • Introducing the Raspberry Pi Pico and RP2040
  • Discussing variants of the Pico board
  • Soldering the Pico's headers
  • Implementing the "Hello World!" example
  • Implementing the LED-blinking example
  • Identifying useful add-on hardware for the Pico

Technical requirements

The hardware and software required for this introductory chapter will be used throughout the book. In further chapters, we will provide any additional or chapter-specific requirements.

The hardware requirements are listed as follows:

  • A laptop or a Raspberry Pi with a Universal Serial Bus (USB) port
  • Optional: Soldering equipment including iron, solder, safety glasses, and miscellaneous equipment
  • Optional: Prototyping breadboard and a jumper wire kit

Code in Action videos for this chapter can be viewed at https://bit.ly/3MRdYjx.

Introducing the Raspberry Pi Pico and RP2040

The Raspberry Pi Pico is the latest educational and industrial tool introduced by the Raspberry Pi Foundation. The Pico, a low-cost microcontroller, costs USD 4, and even at the low price point, the Pico packs quite a punch. The Pico is centered on the RP2040, a dual-core Cortex-M0+ microcontroller. The board comes with a total of 40 pins, where there are 20 pins on each side, as shown in the following screenshot. The Pico also comes with 2 MB of onboard flash memory and an LED on the GP25 (GP refers to General Purpose Input/Output) button.

Figure 1.1 – Raspberry Pi Pico

Figure 1.1 – Raspberry Pi Pico

The datasheet for the Raspberry Pi Pico is available from here: https://bit.ly/3cwv1Ic. In this book, we will be making use of the different peripherals available on the Pico in the projects discussed in each chapter. Hence, it is handy to print the pinout provided by the Raspberry Pi foundation (source: https://bit.ly/3wa0nwq). This pinout sheet can help with pin selection during project planning. A screenshot of the pinout from Adafruit Industries is shown next. You can purchase them for USD 0.50 from their website.

Figure 1.2 – Pico pinout (Image source: Adafruit Industries; License: CC BY-SA 3.0)

Figure 1.2 – Pico pinout (Image source: Adafruit Industries; License: CC BY-SA 3.0)

The Pico board can be used in various applications involving robots, remote monitoring, citizen science, and so on. In this book, we will walk you through different application examples while exploring the peripherals of the RP2040 microcontroller.

RP2040 microcontroller

The RP2040 is a dual-core ARM Cortex-M0+ microcontroller with 264 kilobytes (KB) of static random-access memory (SRAM) but does not have have in-built flash memory. The RP2040 comes with a volley of peripherals including Inter-Integrated Circuit (I2C), Serial Peripheral Interface (SPI), and Programmable Input/Output (PIO). The PIO on the RP2040 microcontroller enables you to design your own interface, such as an additional universal asynchronous receiver-transmitter (UART) interface or a video interface. In Chapter 12, Best Practices for Working with the Pico, we will discuss using the PIO peripheral.

Here is a list of the resources for RP2040:

  • The datasheet for the RP2040 is available at the following link:

https://bit.ly/3rw41x5

  • The datasheet for the Raspberry Pi Pico is available at the following link:

https://bit.ly/3cwv1Ic

  • A video from the Raspberry Pi foundation on the RP2040's PIO can be found at the following link:

https://bit.ly/39ni6Xg

  • Resources for the RP2040 from the Raspberry Pi Foundation can be found by visiting the following link:

https://bit.ly/3flFLv9

We recommend that you download Pico's datasheet along with the RP2040 datasheet. It will come in handy as a reference during development, and we will refer you to the datasheet at certain points in this book for more information.

Discussing variants of the Pico board

Since the launch of the Raspberry Pi Pico, there have been several developer board variants that include the RP2040 from various open hardware companies. These are boards that come with the RP2040 microcontroller and they are outlined in more detail here:

  • SparkFun Thing Plus – RP2040 (USD 17.95): This is an open source development board from SparkFun (https://bit.ly/2NS5vUn). The Thing Plus comes in the Feather form factor from Adafruit. Something unique about this board is that it comes with a microSD card holder and an individually addressable RGB LED. If you are not familiar with the Feather form factor, it simplifies prototyping due to its stacking capability and the ecosystem of prototyping tools available in the Feather form factor. In the following screenshot, you can notice the top (on the right) and bottom (on the left) sides of the RP2040 Thing Plus board:
    Figure 1.3 – SparkFun Thing Plus (RP2040)

Figure 1.3 – SparkFun Thing Plus (RP2040)

  • SparkFun MicroMod RP2040 Processor (USD 11.95): This is another variant from SparkFun (https://bit.ly/3clp0hG). It comes with 16 MB of onboard flash memory. It comes in the MicroMod form factor that makes use of the M.2 standard. In the following screenshot, you can find the top and bottom sides of the RP2040 MicroMod board. You will notice a notch in a half-moon shape that is used to fasten the board to a carrier board using an M2.5 screw:
Figure 1.4 – MicroMod RP2040 Processor

Figure 1.4 – MicroMod RP2040 Processor

SparkFun also makes carrier boards for the MicroMod ecosystem. For example, the carrier board (https://bit.ly/3cnlrHF) shown in the following screenshot was designed to drive a high-definition multimedia interface (HDMI) display using the RP2040:

Figure 1.5 – MicroMod Big Display Board for the RP2040 processor

Figure 1.5 – MicroMod Big Display Board for the RP2040 processor

  • SparkFun Pro Micro – RP2040 (USD 9.95): The Pro Micro – RP2040 board (https://bit.ly/3cnhVgH) is a variant that belongs to the relatively small ecosystem of the Pro Micro family of boards. It comes with 16 MB of flash, individually addressable RGB LEDs, and castellated pads that enable soldering the module directly onto another printed circuit board (PCB). The castellated pins of the Pro Micro are shown in the following screenshot:
Figure 1.6 – SparkFun Pro Micro – RP2040

Figure 1.6 – SparkFun Pro Micro – RP2040

  • Pimoroni Tiny 2040 (USD 11.55): This board from Pimoroni (https://bit.ly/3d9f7Tf) is about the size of a quarter and comes with 8 MB of flash and an RGB LED. The castellated pads enable it to be soldered onto your custom PCB directly. We must point out that you will need a cutout to solder the board onto your custom board. This is because the microcontroller in this development board is on the bottom side, as shown in the following screenshot. We will demonstrate using this board on your custom PCB.
Figure 1.7 – Pimoroni Tiny 2040

Figure 1.7 – Pimoroni Tiny 2040

  • Adafruit Feather RP2040 (USD 11.95): As the name indicates, this board from Adafruit (https://bit.ly/3cm3tW0) is a Feather board for the RP2040 microcontroller. As with the SparkFun Thing Plus, it packs a punch with a Qwiic/STEMMA connector and comes with 8 MB of flash. At the time of writing this book, this board was out of stock. Here's a screenshot showing the board:
Figure 1.8 – Adafruit Feather RP2040

Figure 1.8 – Adafruit Feather RP2040

  • Adafruit ItsyBitsy RP2040 (USD 9.95): This board from Adafruit (https://bit.ly/3sqdB5R) is an addition to their Itsy Bitsy line of products. In terms of its pinouts, it is identical to other Itsy Bitsy products from Adafruit. This board comes with 8 MB of onboard flash memory. This Itsy Bitsy variant, shown along with the Feather board in the following screenshot, is breadboard-friendly. This enables the board to be embedded into your project:
Figure 1.9 – Adafruit ItsyBitsy RP2040

Figure 1.9 – Adafruit ItsyBitsy RP2040

  • Adafruit QT Py RP2040 (USD 9.95): This board (https://bit.ly/3lU2O1q) is an addition to the QT Py family (pronounced "cutie pie") of products from Adafruit. This board also comes with 8 MB of onboard flash memory. The castellated pads of the board shown in the following screenshot enable a PCB to be designed whereby the board could be embedded in your design. Since the RP2040 microcontroller is located on the bottom side, you need to ensure that your design has a cutout to accommodate the QT Py.
Figure 1.10 – Adafruit QT Py RP2040

Figure 1.10 – Adafruit QT Py RP2040

The variants we discussed here are not comprehensive, but we wanted to present some options on getting started with the RP2040 microcontroller. For example, if you are familiar with the Feather form factor, you could get started with the Thing Plus board from SparkFun or the Feather board from Adafruit, discussed in this section. You can use any board of your choice, but the mode of use and interface may differ according to the variant. We will try to highlight any differences wherever possible.

Where to buy the Pico

The Pico costs USD 4 and you can buy it from any Raspberry Pi distributor. You can check out the list of Raspberry Pi distributors at this link: https://bit.ly/3dgra1a. You can buy variants of the Pico from the links provided with their description.

We must note that the Raspberry Pi Pico was not in stock in the US at the time of writing this chapter. This can be attributed to supply-chain constraints due to the ongoing Covid-19 pandemic at the time. It was also difficult to purchase the variants for the same reason. Things may change in the future.

We must also note that the RP2040 microcontroller was not available for purchase at the time of writing this chapter.

In this section, we discussed variants of the Pico and where to buy them. In the next section, we will take a look at setting up the Pico.

Soldering the Pico's headers

In this section, we will discuss setting up the Pico for our upcoming projects. This includes soldering the headers and an optional three-dimensional (3D)-printed enclosure.

Soldering the headers

The Pico comes with 40 pins in two rows of 20 pins. We need to solder the headers to access the peripherals of the RP2040 microcontroller for our project.

Important Note

Soldering the headers requires prior training and adult supervision. Do not attempt soldering without prior training. Here is a tutorial on soldering: https://bit.ly/3focmjM.

You can purchase the headers from the same source as the Pico. For example, you could purchase it from the following link: https://bit.ly/3d9rrUT. The steps to be carried out for soldering include the following:

  1. It is easier to solder the headers with a breadboard. Arrange the headers on a breadboard and stack the Pico on top of it, as shown in the following screenshot:
Figure 1.11 – Pico with headers stacked on a breadboard

Figure 1.11 – Pico with headers stacked on a breadboard

  1. If you are not quick at soldering the individual pins, you might end up damaging the breadboard due to the excess heat. The following image shows the pins of the Pico soldered:
Figure 1.12 – Pico on a breadboard

Figure 1.12 – Pico on a breadboard

Now that we have soldered the headers, we are ready to take it for a spin. In the next section, we will review the optional step of adding a reset button to the Pico.

Implementing the "Hello World!" example

In this section, we will discuss a hello world example. In any programming language, the first coding exercise is to print "Hello World" to the screen. We will discuss this example using MicroPython and CircuitPython.

Reset button for the Pico (optional)

The Pico does not come with a reset button. In order to reset the Pico, you would have to disconnect and reconnect the USB cable, which can be tedious. This can be overcome by adding a reset button between pin numbers 28 and 30 (note the extra button right next to the microcontroller), as shown in the following image (you can get this button fixture from this link: https://bit.ly/3w8AmO2):

Figure 1.13 – Reset button on the Pico

Figure 1.13 – Reset button on the Pico

The reset button makes it easier to restart the program during development. Adding a reset button is optional and it is not recommended if you are not comfortable with soldering. In the next section, we will be writing our first program for the Pico.

MicroPython

We will be using Thonny IDE (IDE stands for integrated development environment) for this example. Thonny IDE can be downloaded from https://thonny.org. The IDE is available for Windows, Mac, and Linux operating systems.

If you use a Raspberry Pi for your programming needs, it comes pre-installed with Thonny. You can launch Thonny from Menu | Programming and scroll down the drop-down button to find Thonny Python IDE, as illustrated in the following screenshot:

Figure 1.14 – Thonny IDE location on the Raspberry Pi Desktop

Figure 1.14 – Thonny IDE location on the Raspberry Pi Desktop

Now, let's prepare the Pico by flashing the MicroPython binary.

Flashing the MicroPython binary

The Pico needs to be connected to the computer in a specific manner to flash the banner. The steps to flash the binary are outlined here:

  1. The first step is to download the binary from https://bit.ly/31nBMFW.
  2. Press and hold the BOOTSEL button shown in the following screenshot as you connect a MicroUSB cable to your Pico. Ensure that the other end of the USB cable is connected to the computer.
Figure 1.15 – Pico BOOTSEL button

Figure 1.15 – Pico BOOTSEL button

  1. The Pico should enumerate as a storage device on your computer, which should look like something similar to this:
Figure 1.16 – Raspberry Pi Pico enumerated as a storage device

Figure 1.16 – Raspberry Pi Pico enumerated as a storage device

  1. Next, copy over the binary onto the storage drive. The Pico will reset itself and we are ready to write programs in MicroPython.

Now, we are ready to write our first program in MicroPython!

Writing our first program

Let's launch Thonny and take it for a test drive! You will need to take the following steps:

  1. Launch Thonny and you should see a window, as shown in the following screenshot:
Figure 1.17 – Thonny IDE

Figure 1.17 – Thonny IDE

  1. We are going to be running our first program using the interpreter running on your Pico. If you are not familiar with Python interpreters, they enable the testing of your code as you write them. Go to Run, and then click on Select Interpreter. From here, you will select the following options, as shown in Figure 1.18:
    • MicroPython (Raspberry Pi Pico)
    • < Try to detect port automatically >

These options can be seen in the following screenshot:

Figure 1.18 – Selecting the Python interpreter

Figure 1.18 – Selecting the Python interpreter

  1. Now, you should see the Python interpreter, as shown in the following screenshot. This is the MicroPython interpreter running on the Pico. Let's take it for a test drive.
Figure 1.19 – Python interpreter

Figure 1.19 – Python interpreter

  1. At the prompt >>>, type the following line of code:
    >>> print("Hello World")

You should see the following output:

Figure 1.20 – Interpreter output

Figure 1.20 – Interpreter output

You have just finished writing your first program on your Raspberry Pi Pico! In the next example, we will write a script that starts running continuously when the Pico is powered by a USB cable.

Implementing the LED-blinking example

In the previous section, we used an interpreter to write our program. An interpreter can be helpful when testing code or finding out more information about the modules being imported. In this example, we will discuss writing a script that runs automatically on powering the Pico. We will discuss the "hello world" example of getting started with electronics where we will blink an LED at a 1-second interval.

The Pico comes with a green LED on the board and its location is shown in the following image:

Figure 1.21 – Pico LED location

Figure 1.21 – Pico LED location

We will make this LED blink at a 1-second interval—that is, we will turn it on and off for a second. In order to write this program, we will need the machine and utime modules.

According to the Pico datasheet, the onboard LED is connected to general-purpose I/O (GPIO) pin number 25. We will proceed as follows:

  • We will use the Pin class from the machine module to control the LED.
  • We will be using the utime module to introduce the delay between turning ON and turning OFF the LED.

You will now need to take the following steps:

  1. Let's take a look at the following code sample:
    from machine import Pin
    import utime
    led = Pin(25, Pin.OUT)
    while True:
        led.toggle()
        utime.sleep(1)

    Exercise

    Develop a practice of actively using an interpreter while you are writing code. In the interpreter, import the machine and utime modules, try executing help(machine), help(utime), and find out for yourself.

  2. Create a new file and enter the preceding code snippet shown in Step 1. Set the file location as Raspberry Pi Pico, as seen in the following screenshot to the right:
Figure 1.22 – File location

Figure 1.22 – File location

  1. Save the file as main.py and your code should automatically begin execution.
  2. Try disconnecting the USB cable and reconnecting it. You will notice that the script starts running automatically.
  3. To stop the code execution, click on the STOP button located on the toolbar, as shown in the following screenshot:
Figure 1.23 – Pressing STOP to interrupt execution

Figure 1.23 – Pressing STOP to interrupt execution

  1. To resume execution, click the Run Current Script button, which is indicated by the green play button indicated at the top of the page, as shown in the following screenshot:
    Figure 1.24 – Clicking Run Current Script to resume execution

.

Figure 1.24 – Clicking Run Current Script to resume execution

In the next section, we will take a closer look at the code.

Description of the code sample

In this section, we will discuss in detail the code sample shown previously, as follows:

  1. We get started by importing the utime module and the Pin class from the machine module, as follows:
    from machine import Pin
    import utime

    GPIO

    A GPIO pin can be used as an input pin or an output pin. When you use a GPIO pin as an output pin, you can set it to HIGH or LOW. Likewise, when you use it as an input pin, you can read whether the pin is HIGH or LOW. In this example, we are turning the LED on/off by alternating between HIGH and LOW states.

  2. Next, we declare the GPIO pin 25 as an output pin using an object belonging to the Pin class. The first argument in the following code snippet refers to the pin number (pin 25), while the second argument sets the pin as an output pin:
    led = Pin(25, Pin.OUT)
  3. Now, we need to blink an LED at a 1-second interval. We are going to do this inside an infinite loop.
  4. The led object has a toggle() function that toggles the pin between the ON and OFF states.
  5. We will introduce a 1-second delay by calling the sleep function after toggling the pin, as follows:
    while True:
        led.toggle()
        utime.sleep(1)

Congratulations on your first step with the Raspberry Pi Pico! Now, we will discuss the same example in CircuitPython.

CircuitPython example

In this section, we will discuss using CircuitPython for programming the Pico. We will discuss the same LED-blinking example using Pico. We will also install the Mu IDE to the program by using CircuitPython.

Flashing the CircuitPython binary

In this section, we will flash the CircuitPython binary onto the Pico. The installation process is the same as for MicroPython. The binary can be downloaded from https://bit.ly/31pnLI4.

Once you have downloaded the binary, follow the instructions from the MicroPython section.

Coding with Mu

In this section, we will install the Mu IDE. The IDE is available for download from https://bit.ly/3ruxDKW. The IDE is available for Windows, Linux, and Mac operating systems.

Raspberry Pi installation

On a Raspberry Pi, Mu can be installed as follows:

  1. Go to Menu | Preferences | Recommended Software | Select Mu to choose Mu from the list of software to install.
  2. Mu can be launched from Menu | Programming | Mu.

In the next section, we will review writing our first program with Mu.

Launching Mu

The steps to writing a program with Mu include the following:

  1. Connect the Pico to your computer/Raspberry Pi using a USB cable.
  2. Once Mu is launched, we need to set the programming mode. Since we are programming in CircuitPython, we will set it to CircuitPython, as shown in the following screenshot:
Figure 1.25 – Selecting programming mode

Figure 1.25 – Selecting programming mode

  1. You can also change the programming mode from the main window of the IDE, as shown in the following screenshot:
Figure 1.26 – Changing Python mode

Figure 1.26 – Changing Python mode

Note the Pico being automatically detected in the preceding screenshot.

  1. Click the Serial button to launch access to the Python interpreter, as shown here:
Figure 1.27 – Serial button location

Figure 1.27 – Serial button location

  1. Launch the Python interpreter by pressing Ctrl + C, and it should take you to the >>> REPL prompt, as shown toward the bottom of the following screenshot:
Figure 1.28 – CircuitPython interpreter on Pico

Figure 1.28 – CircuitPython interpreter on Pico

Finally, in this process, repeat the Hello World! example from the MicroPython section by using the interpreter.

Second LED-blinking example

We will discuss the same LED-blinking example using CircuitPython and observe the differences between the two flavors of Python. Let's take a quick look at the following code snippet:

import time
import board
import digitalio
 
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
 
while True:
    led.value = True
    time.sleep(1)
    led.value = False
    time.sleep(2)

Let's review the code sample, as follows:

  1. We get started by importing the time, board, and digitalio modules. The time module is used to introduce a delay between turning the LED ON and OFF.
  2. The board module contains definitions of the pins and peripherals specific to the board. In this example, we are making use of the LED constant from the board module to drive the onboard LED on the Raspberry Pi Pico.
  3. The digitalio module provides access to the Pico's peripherals. In this example, we need to declare the LED pin (GPIO pin 25) as an output pin:
    led = digitalio.DigitalInOut(board.LED)
    led.direction = digitalio.Direction.OUTPUT
  4. In the first line of the preceding code snippet, we are declaring led as an instance of the DigitalInOut class.
  5. In the second line, we are setting the direction of the led pin to be an output pin. We are making use of the Direction class from the digitalio module.
  6. Next, we enter an infinite loop where we turn the LED on/off, as follows:
    while True:
        led.value = True
        time.sleep(1)
        led.value = False
        time.sleep(2)
  7. In the first line of the while loop, we set the value to be True. This turns ON the LED. This is followed by a 1-second delay. This is achieved by calling time.sleep(1).
  8. In the third line of the while loop, we set the value to be False. This turns OFF the LED. This is also followed by a 1-second delay.
  9. We want the script to launch upon reset. Load the code.py file located on the Pico that is currently enumerated on your computer as a storage device. The Load button is located on the top toolbar.
  10. Type the code sample we discussed into code.py and save it.
  11. Press Ctrl + D from the CircuitPython interpreter and you should notice the LED blinking on the Pico.

Congratulations on writing your first CircuitPython program for the Raspberry Pi Pico!

CircuitPython or MicroPython?

In this chapter, we discussed examples with both CircuitPython and MicroPython. The examples were somewhat identical and share a similar structure. What are their differences and which flavor of Python should you use for your development?

The short answer is that it is up to you. For the sake of consistency, we will be discussing all examples in CircuitPython using the Mu IDE.

Both implementations have a wide user base and libraries for add-on hardware. CircuitPython was spun off MicroPython by Adafruit. CircuitPython can be helpful while using sensor breakout boards from Adafruit Industries.

Thonny versus Mu IDE

In this chapter, you might have noticed that we used Thonny for the MicroPython example and Mu for the CircuitPython example. We wanted to demonstrate the various tools available for the Raspberry Pi Pico. You can even use a simple text editor for your development. We will show you how to save and upload your code to the Pico.

In the next section, we will discuss add-on hardware for the Pico.

Identifying useful add-on hardware for the Pico

In this section, we will discuss the add-on hardware available for the Pico. We must note that we are only discussing hardware designed specifically for the Pico. The list is not comprehensive, and we picked examples on the basis of their differences. You are welcome to select any development board of your choosing, but this is not necessary. A simple breadboard should suffice and would be assembled as shown in the following screenshot:

Figure 1.29 – Pico on a breadboard

Figure 1.29 – Pico on a breadboard

In the next example, we will take a look at add-on hardware where the Pico sits right next to the breadboard.

Pico Breadboard Kit (USD 19.31)

As the name suggests, this board comes with a breadboard, four LEDs, four pushbuttons, and a buzzer. There are a pair of headers to assemble the Pico onto the board and two rows of headers to access all the pins available on the Pico board. An image of the board can be seen in the following screenshot. This board can be helpful for an absolute beginner in electronics. The board can be purchased from https://bit.ly/3tV7aIa.

Figure 1.30 – Pico Breadboard Kit

Figure 1.30 – Pico Breadboard Kit

The Pico breadboard can be helpful for an absolute beginner in electronics.

Pico GPIO Expansion Board (USD 10.34)

This is a development that provides access to all the pins of the Pico. There are two rows of male and female headers on both sides, as shown in the following screenshot. This board can be purchased from https://bit.ly/3rprobq.

Figure 1.31 – Pico GPIO Expansion Board

Figure 1.31 – Pico GPIO Expansion Board

The two rows of male and female headers enable the use of male and female jumper cables for prototyping.

Pico HAT Expansion (USD 13.79)

This development board enables the interfacing of any Raspberry Pi HAT (which stands for Hardware Attached on Top) to the Pico. It comes with a 2x20 header that enables a HAT to be stacked on the board and can be seen in the following screenshot. The board also provides access to the pins of the Pico board and is connected to the HAT pinout. The board can be purchased from here: https://bit.ly/3lYRfpu. The web page also provides pin mapping from the Pico to the HAT.

Figure 1.32 – Pico HAT Expansion

Figure 1.32 – Pico HAT Expansion

This board enables a Pico to be added to your existing Raspberry Pi project. It could also enable you to use your Raspberry Pi HATs with your Pico.

Grove Shield for Pi Pico (USD 3.90)

The Grove Shield board helps to connect the Pico to the Grove ecosystem from Seeed Studio. In case you are not familiar with this, the Grove ecosystem consists of modular boards for prototyping in electronics. As you can see from the following screenshot, the board consists of a series of connectors that enables it to be interfaced to sensors and actuators. The board can be purchased from https://bit.ly/2NZG3MO.

Figure 1.33 – Grove Shield for Pi Pico

Figure 1.33 – Grove Shield for Pi Pico

In the next example, we will discuss prototyping with stackable hardware.

Pimoroni Pico Decker (Quad Expander) (USD 16.55)

As the name suggests, this board enables the interfacing of up to four expansion boards to the Pico, as shown in the following screenshot, but it is important to ensure that there are no pin conflicts between the add-on boards. The board can be purchased from https://bit.ly/3lXpWMt:

Figure 1.34 – Pimoroni Pico Decker (Quad Expander)

Figure 1.34 – Pimoroni Pico Decker (Quad Expander)

In this section, we reviewed various add-on hardware available for the Raspberry Pi Pico. The list is not comprehensive—for example, Feather/Thing Plus boards come with stackable hardware known as FeatherWings. Similarly, MicroMod boards come with their own ecosystem of add-on hardware.

Summary

In this chapter, we introduced you to the Raspberry Pi Pico. We discussed the peripherals of the RP2040 microcontroller and variants of the Pico development board from other hardware manufacturers. We also discussed the add-on hardware available for the Pico. We soldered the headers for the Pico and added a reset button. We also discussed a "Hello World!" example and an LED-blinking example using CircuitPython and MicroPython.

Now that you are done setting up the Pico and have familiarized yourself with the options available to program the Pico, we will discuss the features of the RP2040 microcontroller using practical examples.

Join us in the next chapter, where we will review the communication interfaces available on the Pico!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Make the most of the Raspberry Pi Pico—a low-cost microcontroller that is primed for innovation
  • Work with easy-to-follow examples and learn how to interface and program a Raspberry Pi Pico
  • Work on fun projects, right from home automation to building a seven-segment display to tracking air quality

Description

The Raspberry Pi Pico is the latest addition to the Raspberry Pi family of products. Introduced by the Raspberry Pi Foundation, based on their RP2040 chip, it is a tiny, fast microcontroller that packs enough punch to power an extensive range of applications. Raspberry Pi Pico DIY Workshop will help you get started with your own Pico and leverage its features to develop innovative products. This book begins with an introduction to the Raspberry Pi Pico, giving you a thorough understanding of the RP2040's peripherals and different development boards for the Pico designed and manufactured by various organizations. You'll explore add-on hardware and programming language options available for the Pico. Next, you'll focus on practical skills, starting with a simple LED blinking project and building up to a giant seven-segment display, while working with application examples such as citizen science displays, digital health, and robots. You'll also work on exciting projects around gardening, building a weather station, tracking air quality, hacking your personal health, and building a robot, along with discovering tips and tricks to give you the confidence needed to make the best use of RP2040. By the end of this Raspberry Pi book, you'll have built a solid foundation in product development using the RP2040, acquired a skillset crucial for embedded device development, and have a robot that you built yourself.

Who is this book for?

This book is for students, teachers, engineers, scientists, artists, and tech enthusiasts who want to develop embedded systems that drive cost-effective automation, IoT, robotics, medical devices, and art projects. If you consider yourself a maker and would like to learn how to use the Raspberry Pi Pico, then this book is for you. Familiarity with Python programming, MicroPython, CircuitPython, embedded hardware, and peripherals is helpful but not mandatory to get the most out of this book.

What you will learn

  • Understand the RP2040 s peripherals and apply them in the real world
  • Find out about the programming languages that can be used to program the RP2040
  • Delve into the applications of serial interfaces available on the Pico
  • Discover add-on hardware available for the RP2040
  • Explore different development board variants for the Raspberry Pi Pico
  • Discover tips and tricks for seamless product development with the Pico

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 26, 2022
Length: 376 pages
Edition : 1st
Language : English
ISBN-13 : 9781801810661
Vendor :
Raspberry Pi
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 26, 2022
Length: 376 pages
Edition : 1st
Language : English
ISBN-13 : 9781801810661
Vendor :
Raspberry Pi
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 96.97
Raspberry Pi Pico DIY Workshop
€38.99
Robotics at Home with Raspberry Pi Pico
€29.99
Raspberry Pi and MQTT Essentials
€27.99
Total 96.97 Stars icon

Table of Contents

16 Chapters
Section 1: An Introduction to the Pico Chevron down icon Chevron up icon
Chapter 1: Getting Started with the Raspberry Pi Pico Chevron down icon Chevron up icon
Chapter 2: Serial Interfaces and Applications Chevron down icon Chevron up icon
Chapter 3: Home Automation Projects Chevron down icon Chevron up icon
Chapter 4: Fun with Gardening! Chevron down icon Chevron up icon
Section 2: Learning by Making Chevron down icon Chevron up icon
Chapter 5: Building a Weather Station Chevron down icon Chevron up icon
Chapter 6: Designing a Giant Seven-Segment Display Chevron down icon Chevron up icon
Chapter 7: Designing a Visual Aid for Tracking Air Quality Chevron down icon Chevron up icon
Section 3: Advanced Topics Chevron down icon Chevron up icon
Chapter 8: Building Wireless Nodes Chevron down icon Chevron up icon
Chapter 9: Let's Build a Robot! Chevron down icon Chevron up icon
Chapter 10: Designing TinyML Applications Chevron down icon Chevron up icon
Chapter 11: Let's Build a Product! Chevron down icon Chevron up icon
Chapter 12: Best Practices for Working with the Pico Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(3 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Shyam Jan 08, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A very practical and easy to follow book to get first hand IoT knowledge using Raspberry Pi Pico. It teaches you how to add simple sensors like temperature sensor (AHT20) and use it for a gardening project. Likewise, it teaches you how to build air quality monitoring application. Very useful book for those seeking hands on knowledge.
Amazon Verified review Amazon
VD Jul 06, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Review written for Chapter 2 Serial Interfaces and ApplicationsBook Target Audience: Raspberry Pi Pico beginnersBeginner Note 1: Raspberry Pi Foundation released the Raspberry Pi Pico W with Bluetooth and 2.4GHz WiFi capabilities. The chapter reviewed uses ESP32 micro-controller to provide wireless communication capabilities to the then wireless version of the Raspberry Pi Pico on the market. Not much will change for beginners with the introduction of the Raspberry Pi Pico W as the Python programming frameworks used in this book will soon support the Raspberry Pi Pico W chip they chose to provide wireless capabilities, the Infineon CYW43439 chip natively.Beginner Note 2: As a beginner you may not possess much skills in programming micro controllers. This is why this book has made the decision to use the Python frameworks available for common micro controllers including the Raspberry Pi Pico. This book also uses sensor modules and displays that as a beginner you will need to purchase to complete the example projects. Prices are listed in the chapter but with the supply chain issues that are ongoing during the publishing of this book the prices you pay as a beginner may fluctuate from the printed prices within the book until the supply chain issues resolve. Prices for a given sensor can be indicative of but not necessarily relied on as a predictor of quality of a particular sensor as the less expensive mass produced sensors may be less precise but less expensive to purchase. As a beginner be aware that use of any given sensor is a design decision for whatever the end product or end purpose is. If you only need general temperature information for example a less expensive and less precise temperature sensor would suffice.Serial Interfaces are the most common interfaces users of micro controllers will use to communicate with the various sensor modules and even to other micro controllers such as the ESP32 used in this chapter to provide WiFi communication capabilities to any micro controller that does not already possess them. This is a very important chapter to pay attention to as a beginner.Wiring diagrams are provided in the form of Fritzing schematics which are at a high level and show color coded wire connections for the beginner to easily understand,. Rest assured there are no complicated circuit diagrams to learn.Serial communications technologies taught in this chapter include UART which will teach you asynchronous communications communications where there is no reference clock signal so both the micro controller and the device being communicated with must speak at an identical given speed, known as baud rate and then moves on to I2C invented by Philips Semiconductors in 1982 where one wire will carry the clock signal that all devices can reference so no need to separately set up a separate baud rate configuration and then covers the SparkFun QWIIC and AdaFruit STEMMA 3.3 volt and 5 volt respectively connector standards that build on top of I2C that allows users to daisy-chain different sensor boards together instead of using breadboards and wires to connect everything. The final serial communications standard covered is Serial Peripheral Interface (SPI) used by memory devices, sensors, displays and so on. As a beginner do not worry the coverage is not in depth to the point you will get lost but if you do wish to learn more there are links to external resources that are provided for those hungry for more information. The chapter ends with the interfacing a Raspberry Pi Pico with an ESP32 micro controller using SPI so that the Raspberry Pi Pico can borrow the wireless capabilities of the ESP32 micro controller to send and receive data on its behalf.The programming code is short. As a beginner most of it should be easy enough to understand, just be aware that some of the numbers provided will be in hexadecimal format, those with start with a "0x" before the actual number itself and then you will have normal numbers that will be easier for a beginner to comprehend.The heavy lifting of connecting the Raspberry Pi Pico to various sensors will already be done for you within the Python framework and any of the various libraries that have been written for a given sensor. You will not be required to understand lower level concepts in programming. If you do wish to further your education then the beginner is recommended to explore the Arduino Framework and Arduino IDE which give you some more control at a lower level of the micro controller and sensors.The writing style used in the chapter was clear and comprehensible.Overall as a book targeted towards the beginner the book provides enough for someone new to Raspberry Pi Pico to get their feet wet and experience various technologies used in the micro controller space. The program code provides the bare minimum to accomplish the communication technology being explained. There will not be completed complex applications, that is left to the beginner to analyze what their own specific problems or desires are and then try to make the Raspberry Pi Pico and any chosen sensors do what the beginner dreams up. If you are intermediate to advanced in IOT or micro controllers this is not written for you, it is for the beginners just getting their feet wet.
Amazon Verified review Amazon
Jason Russell Jul 12, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book provides clear and concise guidance for audiences from beginner to advanced levels that wish to expand their knowledge of the Raspberry Pi pico platform. For the new learner you will be up and running code within hours and for the advanced learner the book provides code examples and instructions for many complex and advanced builds. Jason Russell - Gray Hat Guy LLC
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.