Reader small image

You're reading from  Raspberry Pi Pico DIY Workshop

Product typeBook
Published inMay 2022
PublisherPackt
ISBN-139781801814812
Edition1st Edition
Right arrow
Authors (2):
Sai Yamanoor
Sai Yamanoor
author image
Sai Yamanoor

Sai Yamanoor is an embedded systems engineer working for a private startup school in the San Francisco Bay Area, where he builds devices that help students achieve their full potential. He completed his undergraduate work in mechatronics engineering from Sri Krishna College of Engineering and Technology, Coimbatore, India and his graduate studies in mechanical engineering at Carnegie Mellon University, Pittsburgh PA. His interests, deeply rooted in DIY and open software and hardware cultures, include developing gadgets and apps that improve the quality of life, Internet of Things, crowdfunding, education, and new technologies. In his spare time, he plays with various devices and architectures, such as the Raspberry Pi, Arduino, Galileo, Android devices and others. Sai has earlier published a book titled Raspberry Pi Mechatronics Projects.
Read more about Sai Yamanoor

Srihari Yamanoor
Srihari Yamanoor
author image
Srihari Yamanoor

Srihari Yamanoor is a mechanical engineer, working on medical devices, sustainability, and robotics in the San Francisco Bay Area. He completed his undergraduate studies in mechanical engineering from PSG College of Technology, Coimbatore, India and graduate studies in mechanical engineering at Stanford University. He is certified in SolidWorks, simulation, sustainable design, PDM as well as in quality and reliability engineering and auditing. His has a wide range of interests, from DIY, crowdfunding, AI, travelling, photography to gardening and ecology.
Read more about Srihari Yamanoor

View More author details
Right arrow

Chapter 7: Designing a Visual Aid for Tracking Air Quality

In the previous chapter, we built a visual aid containing a giant seven-segment display to track physical activity. In this chapter, we are going to build a visual aid that can serve as an interactive exhibit to track air quality. By the end of this chapter, you will be able to build something like the one shown in the following figure.

Figure 7.1 – Air quality exhibit

The goal of this project is to educate people about air quality in our immediate surroundings. We will discuss the project in two different ways. In the first approach, we will build the display using publicly available data sources. In the second approach, we will discuss building it using a carbon dioxide sensor that is interfaced with the Raspberry Pi Pico.

The topics discussed in this chapter include the following:

  • Inspiration for the project
  • Installing requisite libraries
  • Using public data sources for air...

Technical requirements

The following hardware is recommended for this chapter:

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

CircuitPython Installation

We are assuming that you have...

Inspiration for the project

Good quality air is a prime right for humans everywhere. Increasing urbanization and global pollution have continued to lower the quality of air, which severely affects the quality of life for citizens everywhere, be it Peshawar, New Delhi, or anywhere else. Citizen scientists want to engage in monitoring air quality to help develop a better understanding of pollution levels and the elements that contribute to poor air quality. Parameters of interest include Oxygen (O2) and Carbon dioxide (CO2) levels, the presence of Volatile Organic Compounds (VOCs), Particulate Matter (PM) arising from the residue of burnt coal, wood, and other materials, as well as compounds of Sulphur, Nitrogen, and other elements.

Sensors that monitor air quality are increasingly becoming lower in cost, while simultaneously continuing to gain in accuracy and precision. This will allow citizen scientists to develop solutions that allow the monitoring of air quality. The data collected...

Installing requisite libraries

In this " section, we will install the requisite libraries needed for this chapter, including the stepper motor, the CO2 sensor, and the wireless pack to the Raspberry Pi Pico. The libraries are all a part of the Adafruit CircuitPython bundle. The latest bundle can be downloaded as a ZIP file from https://circuitpython.org/libraries. We used the bundle version meant for CircuitPython 6.x.x.

After downloading the ZIP file, extract its contents so that we can copy the libraries we need for the project.

Stepper motor

We need the adafruit_motor library to control the stepper motor (shown in the following figure). The stepper motor has a needle that is used to point at the corresponding air quality category. Copy the adafruit_motor library to the lib folder of your Pico.

Figure 7.2 – Automotive gauge stepper motor

Next, we will review installing libraries for the wireless pack.

Wireless pack

We need the...

Using public data sources for air quality data

In this section, we are going to discuss retrieving air quality data using publicly available data, namely the AirNow API provided by the United States Environmental Protection Agency (US EPA). API is the acronym for Application Programming Interface. Here, it refers to the interface provided to retrieve air quality data. An API typically comes with specifications for access. Here, it is a program that aggregates data from federal, state, and local agencies to report the Air Quality Index (AQI). We are going to test the API and then discuss the code needed to retrieve the air quality data using the Pico:

Data Sources Outside the United States

If you live outside the United States, we recommend using the local data source in your region. If one doesn't exist, we recommend checking out the Interfacing a CO2 sensor on a Pico section of this chapter.

The steps to retrieve air quality data using publicly available data are as...

Interfacing a CO2 sensor with the Pico

In this section, we will discuss interfacing the CO2 sensor with the Raspberry Pi Pico. This section is meant for those who don't have access to a local data source for air quality. The SCD30 sensor has a measurement range of 400–10,000 ppm. We chose this sensor because it comes with an onboard temperature sensor that provides temperature compensation to the CO2 concentration calculation. The datasheet for the sensor is available from here: https://bit.ly/3tyJZ9C. We will measure the CO2 concentration and publish it to ThingSpeak, a service we discussed in Chapter 4, Fun with Gardening!. This will enable us to share a public dashboard of the local air quality levels.

If you have access to a public data source, you are welcome to skip this section and move to the next section where we test the motors.

We are assuming that you have installed the required libraries to communicate with the sensor using the instructions from earlier...

Interfacing the stepper motor

In this section, we will discuss interfacing a stepper motor with the Raspberry Pi Pico using the DRV8833 Stepper Motor Driver. This will enable us to build a display where the stepper motor will point to the corresponding air quality category.

Motor Selection

For this project, we chose a stepper motor that is used in automotive gauges. This is because the motor has a total movement range of 315°. It also comes with a needle that is useful in building our visual aid. Motor selection for an application involves several factors. We recommend the following article from SparkFun: https://bit.ly/3qyYxnX.

The first step is to wire up the stepper motor driver to the Raspberry Pi Pico. Figure 7.21 shows the connections of the stepper motor driver to the Pico. The stepper motor driver is connected as follows where the left-hand side of the arrow refers to a pin available on the Raspberry Pi Pico while the right refers to a pin on the DRV8833 stepper...

Building the display

It is time to assemble the display inside the shadow box. We printed the various air quality categories on a semi-circle and tested its fit inside the shadow box as shown in the following figure. If you are not familiar with shadow boxes, they are display boxes with a recess and glass at the front. They are used for prominently displaying souvenirs, medals, mementos, and so on. They are usually carried by stores that sell supplies for arts, crafts, and other related hobbies.

Figure 7.23 – Testing the fit inside the shadow box

We ensure that the stepper motor sits in the middle of the shadow box on top of the air quality categories. Once the stepper motor is installed, it is time to calibrate the stepper motor movements and calculate the number of steps needed for each category.

Now we are ready to take the display for a spin. The following figure shows the display pointing to the air quality being Good:

...

Summary

In this chapter, we discussed retrieving air quality data from publicly available data sources. We also discussed interfacing a CO2 sensor to the Raspberry Pi Pico to build a dashboard that tracks air quality. Then, we discussed controlling a stepper motor using the Pico, which can be used to point at one among six different categories of air quality. This enables us to build a display that keeps track of air quality in our community.

In the next chapter, we are going to have fun with radios! Join us in the adventure.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Pico DIY Workshop
Published in: May 2022Publisher: PacktISBN-13: 9781801814812
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Sai Yamanoor

Sai Yamanoor is an embedded systems engineer working for a private startup school in the San Francisco Bay Area, where he builds devices that help students achieve their full potential. He completed his undergraduate work in mechatronics engineering from Sri Krishna College of Engineering and Technology, Coimbatore, India and his graduate studies in mechanical engineering at Carnegie Mellon University, Pittsburgh PA. His interests, deeply rooted in DIY and open software and hardware cultures, include developing gadgets and apps that improve the quality of life, Internet of Things, crowdfunding, education, and new technologies. In his spare time, he plays with various devices and architectures, such as the Raspberry Pi, Arduino, Galileo, Android devices and others. Sai has earlier published a book titled Raspberry Pi Mechatronics Projects.
Read more about Sai Yamanoor

author image
Srihari Yamanoor

Srihari Yamanoor is a mechanical engineer, working on medical devices, sustainability, and robotics in the San Francisco Bay Area. He completed his undergraduate studies in mechanical engineering from PSG College of Technology, Coimbatore, India and graduate studies in mechanical engineering at Stanford University. He is certified in SolidWorks, simulation, sustainable design, PDM as well as in quality and reliability engineering and auditing. His has a wide range of interests, from DIY, crowdfunding, AI, travelling, photography to gardening and ecology.
Read more about Srihari Yamanoor