Make the BackpAQ Personal Air Quality Monitor

Introduction: Make the BackpAQ Personal Air Quality Monitor

About: Board Chair for sustainability non-profit Sustainable Silicon Valley. CEO of BackpAQ Labs LLC

The BackpAQ Project

The BackpAQ project is part of a middle and high school STEM curriculum that promotes learning about and experience with the monitoring of air quality (AQ) particularly in disadvantaged communities, and drives engagement among underrepresented youth in STEM activities.

Key to the program is deployment of a suite of community-based mobile air quality monitors that leverage new low-cost sensors. These handheld units can be readily assembled by advanced middle-school and high school students and other STEM-oriented youth who are motivated by interest in obtaining, understanding and sharing hyper-local air quality data.

What we'll build

These student-built monitors, encased in a lightweight polycarbonate box, weigh less than a pound and are powered by rechargeable LiPo batteries. They feature carabineers and nylon straps for easy fastening to a backpack or bicycle frame.

What we’ll measure

As designed, the monitors will measure and display criteria pollutants PM1, PM2.5, and PM10 concentrations in ug/m3, as well as display the US EPA Air Quality Index (AQI). Monitoring of additional pollutants, such as CO, O3, NO2 and SO2 are possible future enhancements. The latest version pairs with a smartphone app to provide an interactive user experience and allow customization and personalization of monitored data and how it’s displayed. BackpAQ automatically uploads data to the Thingspeak cloud where it can be visualized using powerful analytics, and shared with other students or local community officials.

What we'll learn

To begin with, we'll learn design, build and fabrication techniques - along with some pretty powerful electronics, Internet-of-Things (IOT), and sensor technology skills. Perhaps most importantly, we'll learn how to curate and analyze data we capture from the monitors. Learning how to develop and apply critical judgement to the data and subsequent reporting and sharing of findings and implications are key outcomes of this project.

Outcomes

The intended outcome of this project is twofold: one, obtain a richer, deeper understanding of air pollution, where it comes from, how to measure it, how to harness powerful analytics to responsibly report and share findings, and (hopefully) gain some insight that will enable ordinary concerned people to do something about it. And two, build a monitoring device - BackpAQ - to better understand the science and engineering behind sensors, IOT, the Maker Movement, and have hands-on involvement with one of the more critical challenges facing communities today.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: How This Instructable Is Organized

The BackpAQ Instructable is organized as follows:

  • Introduction
  • Air Pollution and What We're Measuring
  • Design Point
  • Overview of the Project
  • Materials
  • The Build
  • Software and Cloud
  • Futures

Although we've laid out a sequential learn + build process, feel free to skip around or just jump to a specific Step. For example, you may wish to set up the software first before diving into the BackpAQ device. Your choice...have fun!

Step 2: What We're Measuring

For this project we are going to build a BackpAQ personal air quality (AQ) monitor. As you can see from the accompanying photos, BackpAQ is designed to be easily carried, clipped to a backpack, or placed in a mobile scenario such as a vehicle or other transport. As BackpAQ utilizes GPS positioning technology, the AQ information we collect will be geo-positioned no matter where the monitor goes.

Before we get started building, let's take a look at the science behind air quality, sensors and monitoring.

So what is "PM", and how does it get into the air?

Size comparisons for PM particles
PM stands for particulate matter (also called particle pollution): the term for a mixture of solid particles and liquid droplets found in the air. Some particles, such as dust, dirt, soot, or smoke, are large or dark enough to be seen with the naked eye.

Others are so small they can only be detected using an electron microscope. Particle pollution includes: PM10 : inhalable particles, with diameters that are generally 10 micrometers and smaller; and PM2.5 : fine inhalable particles, with diameters that are generally 2.5 micrometers and smaller. How small is 2.5 micrometers? Think about a single hair from your head. The average human hair is about 70 micrometers in diameter – making it 30 times larger than the largest fine particle.

Sources of PM

These particles come in many sizes and shapes and can be made up of hundreds of different chemicals. Some are emitted directly from a source, such as construction sites, unpaved roads, fields, smokestacks or fires. Most particles form in the atmosphere as a result of complex reactions of chemicals such as sulfur dioxide and nitrogen oxides, which are pollutants emitted from power plants, industries and automobiles.

What are the Harmful Effects of PM?

Particulate matter contains microscopic solids or liquid droplets that are so small that they can be inhaled and cause serious health problems. Some particles less than 10 micrometers in diameter can get deep into your lungs and some may even get into your bloodstream. Of these, particles less than 2.5 micrometers in diameter, also known as fine particles or PM2.5, pose the greatest risk to health. Fine particles are also the main cause of reduced visibility (haze) in parts of the United States, including many of our treasured national parks and wilderness areas. Learn more about health and environmental effects.

The PM Sensor for BackpAQ

The particulate sensor we have chosen for this project is the Plantower PMS7003. It is able to measure the concentration of fine particles of less than 1μm (PM1); less than 2.5μm (PM2.5) and less than 10μm (PM10). The operating principle of the PSM7003M sensor is as follows: a laser illuminates airborne particles. An optical sensor captures the laser light and generates an electrical signal proportional to the rate and size of the particles in the air. This block diagram shows what's going on inside the sensor. Note that there is a microprocessor that does some computation and digitization of the signal so that we can read the data in our own hardware.

What are ATM and CF1?

The CF_ATM and CF_1 values are calculated from the particle count data with a proprietary algorithm developed by the PMS5003 laser counter manufacturer, PlanTower. The specifics of the calculation are not available to the public (or us for that matter). However, to convert the particle count data (um/dl) to a mass concentration (ug/m3) they must use an average particle density. They do provide 2 different mass concentration conversion options; CF_1 uses the "average particle density" for indoor particulate matter and CF_ATM uses the "average particle density" for outdoor particulate matter. Depending on the density of the particles you are measuring the sensor could appear to read "high" or "low". Some groups have developed conversion factors to convert the data from the sensor to match the unique average particle density within their airshed.

An Important Caveat

The data the Plantower (and other optical counters) produce is an estimation of particulate mass concentration that relies on several assumptions for shape, diameter and density. The quality of your data will depend on those assumptions as well as environmental considerations such as humidity, light and temperature.
Because of the fact that optical counters rely on these assumptions, the data produced by them are not FRM or FEM certified.

Step 3: Design Characteristics

BackpAQ Design Point

  • Personal, portable air quality monitoring
  • Inexpensive to build, operate
  • Access and control through comprehensive smartphone app

  • Manage data, save measurements on the cloud
  • User-managed data privacy controls
  • Access to powerful Cloud-based data management and analytics
  • Battery powered, rechargeable, solar power option
  • Over-the-air software update capability

BackpAQ Characteristics

  • Size: 5" x 2" x 4"
  • Weight: 10 OZ
  • Case Material: Polycarbonate
  • Measured particles: PM1, PM2.5 and PM10
  • Battery Life: around 12-15 hours
  • Lithium-ion battery: 3v7 - 2500 mAh 2.1mm connector for charging
  • SD Card Storage (optional)
  • Sampling period: adjustable 5 - 60 minutes
  • Multicolored OLED interface for local data display and control
  • Smartphone Interface (Android, iOS) via Wifi and Blynk
  • Regular OTA software updates

Step 4: Technical Overview of BackpAQ

The BackpAQ project is constructed from a fairly broad combination of hardware, software and cloud. In building BackpAQ, the student will utilize a state-of-the-art stack, with Arduino-based IDE (C++), a handful of powerful APIs and data abstractions, two advanced environmental sensors, and a powerful cloud capability.

Here's a quick rundown of the basic components.

  • Processor: WeMos D1, an ESP8266 microcontroller (MCU)
  • PM Sensor: Plantower PMS-7003
  • Temperature/Humidity Sensor: BME280
  • Development Platform: Arduino IDE with simplified C++ programming
  • Cloud: Thingspeak (Matlab) via well-documented APIs
  • Smartphone App: Blynk, which runs via a powerful library on the Arduino IDE

The heart of BackpAQ is the ESP8266 (type ESP-12F). The WiFi-based ESP communicates with the PMS7003 sensor via a serial interface or UART. A small microcontroller inside the sensor transmits the particle concentration values and the number of particles. The BackpAQ firmware continuously reads the data stream, and sends the calculated values to the local OLED display, and to both the connected smartphone and the ThingSpeak cloud. BackpAQ also calculates AQI, the Air Quality Index. AQI is an index for reporting daily air quality. It tells you how clean or polluted your air is, and what associated health effects might be a concern for you.

The ESP8266 also continously measures the battery voltage. If it is below its limit voltage (3v2 = 0%), the device goes into standby. The battery is 100% when the voltage is 4v2 and is visually indicated on the companion smartphone app.

The companion smartphone app is really the control center of BackpAQ. Through the app, you can monitor all functions and display virtually any data collected or computed by the device. There are also mapping and reporting capabilities that will help you get the most of your portable AQ monitoring device.

Step 5: Design and Component Choices

Before we delve into the construction of our BackpAQ, let's review what key decisions and choices we must make in order to fulfill the design characteristics we just talked about.

  • Choice of PM Sensor

In the past few years a new generation of low-cost sensors has become available. Several of these have been the subject of some prominent evaluations, most recently from AQMD. As noted there and elsewhere, these sensors are generally more suitable for deployment in large numbers in terms of their cost but their precision and accuracy may not be sufficient for regulatory use. Based on our own evaluation, though, one of these would suffice for the usage scenarios we envision for BackpAQ.

In this recent study four PM sensors were compared: Plantower PMS5003, Plantower PMS7003, Honeywell HPMA115S040 and Alphasense OPC-N241. The table above lists their main characteristics. These sensors were incorporated into an evaluation breadboard for testing; and they are sufficiently small to be deployed in an enclosure small enough for mobile or wearable applications. They all report PM2.5 and PM10 concentrations in μg/m3. The Plantower PMS5003, the Plantower PMS7003 and the Alphasense OPC-N2 also report PM1 and particle count for different bin sizes - the Plantowers report size distribution for 0.3, 0.5, 1.0, 2.5, 5.0, 10 μm bins and the Alphasense OPC-N2 reports 16 bins ranging from 0.38 μm and17 μm. The Plantower sensors claim a counting efficiency of 98% for particles of diameter 0.5 μm and 50% for diameter 0.3 μm38. All use a sampling interval <10 s. According to the manufacturers, their accuracy is between ±10–15 μg/m3.

In reviewing these studies and others, we observed that the PMS5003/7003 received strong ratings in terms of accuracy, precision, and data recovery while also being price-appropriate for this type of instrument (see PurpleAir Evaluation Summary for details.) The Alphasense, at $450, was not appropriate for this project. The Honeywell, though low-cost, did not do particle counts. So that pretty much left the two Plantowers.

At BackpAQ Labs we also looked briefly at the Shinyei PPD42NS, Samyoung DSM501A and Sharp GP2Y1010AU0F sensors. Although these were much lower cost, their lack of digital output (in most modes) was a disqualifying factor for our design (electronics must sample the analog output and convert o digital form for the MCU.)

Ultimately we chose the PMS-5/7003 for performance, form factor, low cost and support among developers.

  • Choice of Microcontroller

This is obviously at the core of BackpAQ and is perhaps the most important design choice. We looked at several options here, including Arduino-compatible MCUs such as Adafruit Feather, NodeMCU, and WeMos D1. The ESP8266 base was chosen for the evaluation based mainly on tight WiFi integration and low-power consumption. Performance was virtually identical with all of these units and choice ultimately came down to footprint and ease of build and interconnection with sensors and other components. Ultimately, we chose a development board based around the WeMos D1, an MCU we have used in many previous projects and know to be dependable and quite inexpensive (as low as $.88 from several China suppliers). As the design evolves we will revisit this choice and re-evaluate best fit.

  • Choice of Temperature/Humidity Sensor

Several popular and low-cost sensors are available for accurate measurement of temperature and humidity (as well as several other quantities that may be useful, such as atmospheric pressure and altitude, wind speed and direction, ambient sound levels, even light intensity and color temperature.) We evaluated two such sensors, the popular DHT11/22 and the BMP/BME280. In our testing both performed well enough to use in our project, but the DHT proved to be somewhat flakey in terms of timing (with our choice of ESP8266); we were constantly losing measurements and getting a lot of NAN returned by the DHT library. As a result we were skipping roughly 15-20% of the reading cycles. Examining the library, it looks as if the timing optimization doesn't work properly with the DHT22 and ESP8266 we've chosen.

The new BME280 sensor, an environmental sensor with temperature, barometric pressure, and humidity. The BME280 is the next-generation of sensors from Bosch and is the upgrade to the BMP280. This precision sensor from Bosch is the best low-cost sensing solution for measuring humidity with ±3% accuracy, barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. It can be used in both I2C and SPI.

So in the end we chose the (bit more expensive) BMP/BME 280 sensor which seems to work well with the ESP and seems to get long ok with our other sensors (although there seems to be yet another timing issue on the I2C bus, some kind of flakey interaction with the OLED display which is also on the I2C bus.)

  • Communications Mode

To fulfill the design requirement to be 100% mobile and be able to interact with a smartphone and the Internet, we evaluated several comms scenarios. At the beginning of the project, we looked at (1) Cellular; (2) Bluetooth; and (3) WiFi. As was expected, and based on our previous experience with sensor projects, each mode of communications brings advantages and tradeoffs. So we build prototypes to evaluate all three. Cellular, which was arguably the most portable and scalable, cost the most and was the most power hungry. Bluetooth, in particular Bluetooth Low Energy (BLE), was the most flexible and least power intensive. WiFi, with it's wide availability, ease of use, and relatively low power needs, seemed to be the way to go. In the end we chose WiFi, based on it's low power draw, excellent integration with our choice of microcontroller (ESP8266), and near ubiquity across the range of usage scenarios we envision. We may revisit the use of BLE in a future iteration.

  • Smartphone as Communications Hub

As we've just discussed, WiFi seems the best technology choice for communicating the measurements from the sensors to be stored and obtaining the GPS position of the BackpAQ device. Since the ESP8266 contains networking capabilities in the form of WiFi, it could theoretically perform all tasks of the system but with the prerequisite that an active network connection is available at all times. This would require a local area network or the addition of a GSM modem connecting to a mobile network connection. For location services, another module would be needed to provide GPS support. So..... we need to thoughtfully consider how to inexpensively provide these capabilities.

Let's look closer at what is missing. What we need is an active network connection and navigational services for determining our current location. The solution may be right in our pocket! A piece of technology already including both of these features is a regular smartphone which could be used as a gateway between the BackpAQ and network, receiving sensor data and forwarding it. Using a smartphone, much computational work can be moved from the BackpAQ to the phone, also providing the network connection and location services. This means that the ESP8266-powered BackpAQ could be solely responsible for reading sensor data, receiving and acting upon commands and broadcasting data to the phone. The connection between BackpAQ and smartphone can be achieved using WiFi or Bluetooth since both protocols are supported by both devices. Using the network provider of the SIM-card, a connection to online services can be established. In addition to containing the basic features of network capabilities and WiFi/Bluetooth, the phone will also provide GPS in order to give us precise geo-location of the sensors. We'll need this later when we're doing our data analysis, matching AQ to locations.

  • Battery Monitoring

With any battery-powered device it's critical to be able to monitor power usage, or at least battery voltage. The Wemos D1 MCU we're using already has an internal voltage divider that connects the A0 pin to the ADC of the ESP8266 chip. The voltage divider is made up of 220k (R1) and 100k (R2). So, we have to add an external resistance with the inbuilt 220k resistor to read the battery voltage. By using a 100k resistor we can measure the max voltage of the battery, but adding some margin, we've selected a 220k resistor instead. We will add it to a two-pin JMT socket and plug in to the ESP Dev board (we'll show you how later in the Build.)

To select the voltage divider resistance values, you can use this online calculator.

You can also read this article on battery voltage monitoring.

  • Early prototypes and MVP candidate

In the photos above you can see some of the early design and functional prototypes we did. These were extremely valuable in evaluating basic functionality (are we meeting our design criteria), user experience (can the intended user actually use this thing?), and understanding the limits of our design -- what it can and can't do.

After 5 or 6 iterations with electronics, software, packaging, and overall user experience, we settled on our current design and generated our minimally viable product or MVP.

  • Things we left out...for now

One obvious thing we have left out, for now, is the ability to measure other pollutants, such as NOx, SOx, O3, CO, and other criteria gases. One reason is cost. To purchase reasonably accurate and calibratable sensors is cost-prohibitive for this low-cost project. Sure, there are dozens of "TVOC" and other such gaseous monitors available, but most carry huge disclaimers stating "not for quantitative measurement" or "use only in indoor environments". Others tell you that the sensors themselves will only last for a short time before needing replacement of their electrochemical elements.

  • And, Above All...

"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering" - Freeman Dyson

Step 6: Bill of Materials

KITS

In the near future the BackpAQ Kit can be ordered from BackpAQ Labs. For this project we'll utilize kits made available through Sustainable Silicon Valley.

The kit includes all the necessary components needed to build your own BackpAQ. Some benefits of getting the kit: overall lower cost, little soldering is required and the holes on the enclosure are pre-made. The option is also available to purchase the individual components which are listed below)

PARTS

Here's an annotated list of what you'll need to build a BackPAQ:

  • DOIT Grove Sensor ESP8266 Expansion Board eBay
  • Plantower PMS7003 Particulate Sensor w/cable eBay
  • Plantower PMS5003 Particulate Sensor w/cable eBay (we use the 5003 in this project)
  • BME280 Temperature/Humidity Sensor eBay
  • 128x64 OLED Display Amazon
  • 3.7V 2600 mAh LiPO Battery Adafruit
  • LiPO Charger/Regulator Board Adafruit
  • Mini Boost 3V to 5V Board Adafruit
  • Pelican Model 1010 Clear Poly Case B&H
  • Misc parts kits (jack, switch, screws, wire, etc.) SSV Labs will supply

Note: The parts in your kit may vary a bit from those in the photos or parts list. Don't worry...they'll work fine.

SOFTWARE

The software that runs BackpAQ can be downloaded here. You'll also need to utilize, download or update the following open source software packages:

TOOLS
With the BackpAQ kit, only a small Phillips-head screwdriver and glue gun with glue stick are required for assembly. Otherwise, the following tools are needed to build the unit: drill, various drill bits, files, Phillips-head screwdriver, glue gun and glue stick, soldering iron and solder, and various bits of wire, two-sided tape, and silicone.

Step 7: The Build

Ok, we're ready to get started building! First, let's lay out all of the parts on a flat, clean work surface. Pro tip: use an egg carton or old-school ice cube tray to organize the very small parts like fasteners, nuts, etc.

Assembly Instructions

The kit comes with a pre-drilled Pelican 1010 clear polycarbonate case and all parts necessary to complete the build. If you choose to order the parts and build yourself, you'll have to do some very basic mechanical and electronics (like soldering a few wires and drilling a few holes) to complete the build. And believe it or not, all of the parts you see in front of you will indeed fit in here! But it's a good idea to follow the suggested assembly sequence in order to fit the lower-level parts first before the one's that go on top. For example we'll want to secure the PMS7003 sensor (that's the small square blue box) in the lower left corner before we install the other components like the charger board or temperature sensor. Just follow along and you'll see the logic here.

OK, here's the recommended assembly sequence for the BackpAQ unit. See above photos for placement.

  1. Install the PMS7003 sensor (it has a double-sided adhesive and foam insulator pad) to align with the intake and outtake holes
  2. Place the LiPo charger board (it has adhesive on the bottom) atop the sensor
  3. Fasten the 5V up-converter to the LiPo charger board (single small screw and nut)
  4. Fasten the temp/humidity sensor, aligned with the hole on the bottom-left side of the case (either single screw or silicone goo).
  5. Install the LiPO battery (double sided adhesive) to the bottom of the case
  6. Install the ESP8266 expansion board to the case with 2 spacers and M2 screws & nuts
  7. Install the charging jack and power switch as shown. Some soldering needed to complete the connections.
  8. Fasten the OLED display to the case lid with 4 spacers and 4 sets of M2 screws & nuts. Connect 4-wire cable to the OLED, paying attention to the wire order (colors do not match traditional "red/black")
  9. Connect all remaining cables and wires for temp sensor, power pos and ground.
  10. Verify all connections (Very important!) and that battery is charged.
  11. Turn power on with BackpAQ unit...OLED display should light up with "BackpAQ (Version)"!

Now that we've verified that our BackpAQ is up and running correctly, we're ready to move on to the software.

Step 8: The Software

A Word About the Software and Firmware That Powers BackpAQ

So you've got a working BackpAQ...now what? Sure, you can start monitoring PM and see a little of the data, but you can't really do very much without connecting and configuring the software, or, more correctly, the firmware. Firmware is the computing logic or code that will run on the microcontroller that's running in the BackpAQ unit you just put together. We've actually done a lot of work for you already; the BackpAQ kits come with pre-flashed firmware that helps you get up and running quickly.

So to really get to know the full capabilities of your BackpAQ, you'll need to do a little configuration of the code. To do this, you'll need to install or update the Arduino IDE we talked about a few steps ago. With the IDE, you'll be able to edit the configuration of your BackpAQ to allow it to send the data it sees automatically to the cloud -- in this case, Thingspeak -- where you can then do some pretty trick analytics and even data science against your data.

And the best part is that all of the data is saved in the Thingspeak cloud where you can get at it any time you need to, even data from, say, months ago, to do some powerful analysis and comparisons. Now let's get the Thingspeak cloud set up so we can get this thing configured.

Step 9: Getting Set Up on Thingspeak

Thingspeak

ThingSpeak is an IoT platform that allows users to collect, store and analyze data remotely. It is integrated with MATLAB/MathWorks which helps with data visualizations and analysis. It's where we'll store and manage all of the data collected from the sensor. Data in Thingspeak are stored within the fields in what are known as channels. Each channel has eight fields. We will be using all of the fields and two channels.

For more information about Thingspeak, refer to the following: ThingSpeak website, ThingSpeak Q&A

Thingspeak Setup

1) First, go to the Thingspeak website.

2) Click on "Sign Up". A page is opened to create a MathWorks account. Enter credentials and click "Continue". If you already have a MathWorks account click on "Sign In".

3) An email will be sent for verification. Once confirmed, return to the Thingspeak page and click "Continue"

4) Create a User ID and Password. Check the "Online Services Agreement" box and click "Continue"

5) On the sign-up successful page, click"OK"

6) Finally, there will be a pop-menu asking about the intended usage. Select your option and click "OK"

Step 10: Create Thingspeak Channels for Your Data

1) Select "New Channel" (we'll do this twice)

2a) Fill in description. To keep things in sync with the data the sensors are collecting, we'll need to fill in each field as follows.

For Channel 1:

  • Enter Name as "BackpAQ Sensor Data I",
  • Check the box and enter Field 1 as "PM0.1 ug/m3"
  • Check the box and enter Field 2 as "PM2.5 ug/m3"
  • Check the box and enter Field 3 as "PM10 ug/m3"
  • Check the box and enter Field 4 as "Temperature (F)"
  • Check the box and enter Field 5 as "Humidity (%)"
  • Check the box and enter Field 6 as "Latitude (Degrees)"
  • Check the box and enter Field 7 as "Longitude (Degrees)"
  • Check the box and enter Field 8 as "Air Quality Index I"

For Channel 2:

  • Enter Name as "BackpAQ Sensor Data II",
  • Check the box and enter Field 1 as "Num of Particles Beyond 0.3 um/.1L"
  • Check the box and enter Field 2 as "Num of Particles Beyond 0.5 um/.1L"
  • Check the box and enter Field 3 as "Num of Particles Beyond 1.0 um/.1L"
  • Check the box and enter Field 4 as "Num of Particles Beyond 2.5 um/.1L"
  • Check the box and enter Field 5 as "Num of Particles Beyond 5.0 um/.1L"
  • Check the box and enter Field 6 as "Num of Particles Beyond 10 um/.1L"
  • Check the box and enter Field 7 as "Battery (V)"
  • Check the box and enter Field 8 as "WiFi RSSI"

2b) Click on "Save Channel" for each channel. A dashboard will open with eight charts for each. Each chart can then be edited individually.

When you're done, the new channels should resemble the last 2 pics above.

3a) Add some numerical or graphical displays to show the PM, particle counts, AQI, temp and humidity readings. To do this select "Add Widgets" then "Numerical Display" and click on "Next". Fill in the required information and click "Create". Repeat this for all of the appropriate fields. There are numerous examples of what can be computed and visualized.

3b) Finally, drag the widgets and place them side by side with the corresponding graphs.

Step 11: Complete the BackpAQ Configuration: Arduino

Get latest Arduino IDE

1) Download and install the latestArduino IDE for your computer and Operating System.

Wifi Login and ThingSpeak Credentials

1) Have the SSID / name and password for your wifi network on hand.

2) In order to upload data to ThingSpeak, you'll need your Thingspeak Channel IDs and Write API Keys. Go to your ThingSpeak account. In the "BackpAQ Sensor Data I and II" channels, click on "API Keys" and note the "Channel ID" and "Write API Key" for each.

Libraries

The code for this project makes use of several customized libraries and header files. They need to be added to the Arduino IDE before the code can be used.

1) Add ESP8266 library

In the IDE go to File -> Preferences -> Additional Boards Manager URLs. Enter the URL (ESP8266) and click "OK". In the IDE go to Sketch -> Include library -> Manage libraries. In the search bar of the Library Manager enter "esp8266". Look for the package titled "ESP8266". Select the package and click on install.

2) Add ESP8266 Wifi library

In the IDE go to Sketch -> Include library -> Manage libraries. In the search bar of the Library Manager enter "esp8266wifi". Look for the package titled "ESP8266WiFi". It may or may not be installed. If not, select the package and click on install.

3) Add WiFiManager library

Search for and download the zip file, WiFiManager onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

4) Add ESP8266WebServer library
Search for and download the zip file, ESP8266WebServer onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

5) Add DNSServer library
Search for and download the zip file, DNSServer onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

6) Add Adafruit_BME280 library

Search for and download the zip file, Adafruit BME280 onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

7) Add Adafruit_SSD1306 library

Search for and download the zip file, Adafruit SSD1306 onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

8) Add Adafruit_GFX library
Search for and download the zip file, Adafruit GFX onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

9) Add Double_Reset_Detector library
Search for and download the zip file, Double Reset Detector onto your computer. In the IDE go to Sketch -> Include library -> Add .ZIP Library. Locate the zip file and select to add.

Step 12: Load BackpAQ Firmware Using Arduino IDE

Although the BackpAQ kits come pre-flashed with the BackpAQ firmware, we do need to configure a few fields and variables so let's go ahead and get Arduino IDE going.

1) First we'll need to set up IDE for the BackpAQ hardware we're using, in this case the WeMos D1 microcontroller. Go ahead and connect the BackpAQ to the computer through the micro-USB connector on the side.
1a) In the Arduino IDE: - Go to Tools -> Board -> select "WeMos D1". - Tools -> Flash size -> select "4M (1M SPIFFS)" - Tools -> CPU Frequency -> select "80MHz" - Tools -> Upload Speed -> select "115200" - Tools -> Port -> select the serial port where the Adafruit module is connected. This will be computer-dependent and will vary greatly across PCs and Macs. Typically, the WeMos D1 we are using uses the CH340 USB chip, and may require a driver download depending on what's already on your system. On my Mac the port is known as "dev/tty.wchusbserial". Your mileage may vary.

2) Access the project code we'll be using from BackpAQ Code. Copy the code onto the IDE work panel or, if you know how, download and save the .zip and open the file in the IDE (this involves knowing the IDE directories and nuances...not recommended if you haven't done it before.)

3) Here's where we configure the code for your unique device and Thingspeak channel. In the code, click on the "Config.h" tab, add your wifi name, password, ThingSpeak channel IDs and ThingSpeak write API keys.

4) Compile and upload the code. Messages, as well as sensor data, can be viewed on the serial monitor. To open the serial monitor, go to Tools -> Serial Monitor or press Ctrl+Shift+M on your keyboard. Set the baud rate to 9600 and select "Carriage return". Data should now be uploading to ThingSpeak. Note: The upload rate is set to every 17 seconds. The adjustment for a longer upload period can be made within the BackpAQ code. However, less than 17 seconds is not recommended due to Thingspeak limits on their API.

Step 13: Get the Blynk App and Libraries

As you may have surmised from the earlier steps, we are using the versatile and easy-to-program Blynk system to run our BackpAQ smartphone app. It's actually very easy to deploy and get running, so let's get started.

Here are the three easy steps to get the Blynk platform up and running:

1) Download the Blynk App

Blynk app for iOS and Android is the easiest way to build your own mobile app that work with the hardware of your choice. No iOS or Android coding required. It's the base for the BackpAQ app that runs on your smartphone. Grab the IOS Blynk app here and Andriod Blynk app here

Next,

1) Create New Account in Blynk app Account is needed to save your projects and provide access from any smartphone you have.☝️Use a valid email address as it will be later used often

2) Create New Project • Create New Project and clone the BackpAQ project. See next Step for details.

3) Get Auth Token Check your inbox to see if you get an email from Blynk with the Auth Token. You will need it later

2) Install the Blynk Library

Blynk Library is an extension that runs on top of your hardware application. It handles all the connection routines and data exchange between your hardware, Blynk Cloud, and your app project. This library will handle all of the interaction with the hardware (the BackpAQ device) and the smartphone app.

To install Blynk Library using built-in library manager in Arduino IDE (as you did in STEP 11):
-- Use the Library Manager. Open the IDE and click to the "Sketch" menu and then Include Library > Manage Libraries.

-- Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. Search for Blynk library and in the version selection choose the latest version to date

-- Finally click on Install and wait for the IDE to install the new library. Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the Bridge library. You can close the library manager.

You can now find the new library available in the Sketch > Include Library menu.

3) Connect to BackpAQ

To get your BackpAQ online and connect it to Blynk Cloud, you will need a device Authentication Token. Note that for BackpAQ, the app token needs to be inserted into the BackpAQ "Config.h" file.

Step 14: Installing and Customizing the BackpAQ Blynk App

After you've downloaded and installed the Blynk app, it's time to "clone" the BackpAQ app onto your smartphone.

First, launch the Blynk app on your smartphone.

Next, create a new account.

NOTE - For this project 6800 energy points are required make sure you have enough energy points. For a new account Blynk gives 2000 free energy points, so you'll just have to make up the 4,800 point difference. Energy points may be purchased through the Blynk app and subsequently via your Apple App Store or Google Play Store and are a great deal at just a few dollars.

To clone the BackpAQ project follow the directions to scan above QR code using your smartphone's camera.

Once, you've cloned the project you can add various widgets and displays to the basic BackpAQ. We'll cover that in a future Instructable. For now, we'll just do one configuration needed to send the data to Thingspeak.

Edit Webhook Widget to Update Thingspeak

This step is a bit complicated but will result in a powerful capability to send all of your data to Thingspeak with basically one click.

1) Click on the "Thingspeak 1" label which should bring up the Webhook widget. Settings should be all done except for the "URL" box which must be edited to include your Thingspeak WRITE API key.

2) Basically, all you need to do here is to overwrite the token that's already there. Be sure to NOT touch the other fields as they are all set for Thingspeak already.

This is what the Webhook URL field will look like before your edit. The field in bold is the Thingspeak WRITE API key...that's what you need to replace with the one you got from Step 10.

https://api.thingspeak.com/update?api_key=A9L9601U1FROH6BE&field1=/pin[0]/&field2=/pin[1]/&field3=/pin[2]/&field4=/pin[3]/&field5=/pin[4]/&field6=/pin[5]/&field7=/pin[6]/&field8=/pin[7]/

3) Do the same for "Thingspeak 2" label and you're done!

Step 15: Operating Your BackpAQ

First, ensure your BackpAQ is fully charged, or plug in the charger to operate. Flip the toggle switch to the On position. The OLED display should light up with the first two lines displayed, and a red LED will light inside the case. If the charger is plugged in, you will observe either the 'charge' or 'done' light on the charger board.

At startup, the BackpAQ is configured in Access Point -> AP (Wifi point). If no known SSID is located, you will be instructed to access the SSID "BACKPAQ". Using your smartphone or any WiFi connected device (such as a tablet or laptop), simply connected to "BACKPAQ" and a special "Captive Portal" will automatically pop up to give you an opportunity to select the WiFi you wish to use.

After connecting the display will verify the WiFi and then enter a "sensor warmup" period of 30 seconds. This allows the particle sensor time to initialize.

Finishing warmup, you'll see the basic PM readings appear on the OLED. At present, this will be:

  • PM1.0
  • PM2.5
  • AQI

As the unit is almost completely programmable, we can change the data on the OLED to display any of the PM sensor data.

Step 16: Using the BackpAQ App

Welcome to BackpAQ!

The BackpAQ app has been designed to be useful and engaging to aid you in pursuing your AQ monitoring activities and investigations. However, please recognize that it's very much a work-in-progress and while functional has some bugs, glitches and not-quite-yet functions. Indeed, we hope that you will help refine this design or, better yet, help design something better! Consider this app a starter set of capabilities that you can build on + refine + share.

Basic Functions

In the photo above you can see the current three app screens: center is the main screen, left is the map, and right is the detailed data. We'll go briefly through each next.

  • Main

The screen you see when BackpAQ starts. There is a lot of data on this panel:

- Gauges showing PM1.0, PM2.5 and PM10 particle concentrations

- Gauge showing AQI based on PM2.5 measurement

- Multi-graph showing these concentrations in Live and various timed intervals

- Temperature (in deg F) and Relative Humidity (in %)

- Latitude and Longitude of your current position (see Map below)

- BackpAQ battery voltage (do I need to recharge?)

  • Map

The Map show your current position and the last 10 positions based on 10 minute intervals (this is adjustable). You can click on any position icon to see the PM25 reading that was captured at that position.

  • Detailed Data

The Detailed Data screen displays the various particle counts from the PM sensor, eg, Number of Particles Beyond 5.0 ug/.mL. Also displayed is a graph showing these counts in Live and various timed intervals.

Quirks, Bugs, and Not-quite-working, ...

As mentioned above this app is at a Beta stage of maturity and naturally has some quirks and bugs, as well as some functions that are still being developed. Here's a list of what's known (help us find the rest!)

  • The readings will not be accurate until the sensor has warmed up and various connections are complete. Wait for at least 30 seconds until things settle down.
  • The WiFi login and credentials function is still maturing. Sometimes it "forgets" your WiFi and you have to re-configure. Sometimes it will ask you to re-enter your WiFi and password even though you previously "Saved" it. The double-click of RESET doesn't always recognize your double-click and strange things then happen. Appreciate your patience as we evolve this function.
  • The Map occasionally misbehaves and places position markers in strange countries. Not sure what's going on but it does seem to know where you currently are and have been.
  • The Battery Level indicator is approximate...best practice is to just recharge nightly as you would your smartphone.
  • The PM sensor is obviously directional in this application as it depends on pulling in air through the intake hole in the BackpAQ case. So, best to orient the device so that the intake has a "view" of where you wish to monitor and is not impeded or blocked.
  • The PM sensor is currently the larger PMS5003 and not the more svelt PMS7003, due mainly to invalid measurement data from the 7003 with this software. Future versions will utilize the 7003 it is hoped.
  • The BackpAQ software running on the device is still young and fragile. This means it may crash occasionally or need to be restarted when it "bogs down". The prototype units have been run successfully for 12-15 hours without problems but things do happen in software, especially when handing several temperamental sensors with a low-cost processor, on a small battery.
  • The AQI gauge and values are slightly controversial in the way they are calculated here and in most other portable devices. The NowCast function (code included but not invoked) is designed to handle this. We will discuss this in class and hopefully come up with a better way to calculate and use it in this context.

Step 17: AQI: Air Quality Index

AQI, Air Quality Index

The AQI is an index for reporting daily air quality. It tells you how clean or polluted your air is, and what associated health effects might be a concern for you. The AQI focuses on health effects you may experience within a few hours or days after breathing polluted air. EPA calculates the AQI for five major air pollutants regulated by the Clean Air Act: ground-level ozone, particle pollution (also known as particulate matter), carbon monoxide, sulfur dioxide, and nitrogen dioxide. For each of these pollutants, EPA has established national air quality standards to protect public health. Ground-level ozone and airborne particles are the two pollutants that pose the greatest threat to human health in this country.

How Does the AQI Work?

Think of the AQI as a yardstick that runs from 0 to 500. The higher the AQI value, the greater the level of air pollution and the greater the health concern. For example, an AQI value of 50 represents good air quality with little potential to affect public health, while an AQI value over 300 represents hazardous air quality. An AQI value of 100 generally corresponds to the national air quality standard for the pollutant, which is the level EPA has set to protect public health. AQI values below 100 are generally thought of as satisfactory. When AQI values are above 100, air quality is considered to be unhealthy-at first for certain sensitive groups of people, then for everyone as AQI values get higher.

How is AQI Calculated?

Consult the above figure (1) for the actual AQI calculation.

See AQI Calculation for more detail on how the AQI is calculated.

NOTE: By definition, the AQI is calculated using data from a 24-hour period. That’s because the science we have about air pollution exposure and health is based on 24 hours and therefore EPA’s air quality standards are based on 24 hours average of sampled AQ. It is not valid to use shorter-term (e.g. hourly) data to calculate an AQI value.

Finally, it's important to always use the most current breakpoints when calculating AQI. Below are the newly revised (12/19) breakpoints from US EPA which we use in BackpAQ:

"AQI Category","Low AQI","High AQI","Low Breakpoint","High Breakpoint"

  • "GOOD",0,50,0.0,12.0
  • "MODERATE",51,100,12.1,35.4
  • "UNHEALTHY FOR SENSITIVE",101,150,35.5,55.4
  • "UNHEALTHY",151,200,55.5,150.4
  • "VERY UNHEALTHY",201,300,150.5,250.4
  • "HAZARDOUS",301,400,250.5,350.4
  • "HAZARDOUS",401,500,350.5,500.4
  • "HAZARDOUS",501,999,500.5,99999.9

See also Revised 2019 US EPA Air Quality Breakpoints

Making AQI More Useful Now: Nowcasting

The AQI is used to deliver a daily air quality report which means at the end of the day, we attain an effective reading for the air quality but this also means that we defeat the purpose of the AQI in the first place. The AQI is intended to help users take immediate actions if air is of harmful quality. This is where the Nowcasting algorithm comes into place. A mixture of the words “now” and “forecasting”, Nowcasting in air quality is a method to give readings for concentrations of harmful substances in the air in a form that immediately usable.

Obviously, simply giving a reading for a harmful concentration in an environment of frequently changing air would be misleading as the immediate reading would in most cases present just an anomaly to an overall cleaner air than what is depicted. This means that even on days when the AQI forecast at the end of the day predicts unhealthy conditions, it is possible that pollution levels might be lower during some parts of the day and vice versa.

Thus the NowCast allows current condition maps to align more closely with what people are actually seeing or experiencing. The technique of Nowcasting is to take a weighted average instead of taking the average of the last relevant span of time. The equation (2) above is used to Nowcast a concentration at any given time.

So to separate the two, for momentary AQI readings, Nowcasting is used; for a daily report the general formula is practiced.

Here is an excellent overview of where AQI and Nowcasting are headed.

Step 18: AQ Monitoring and Data Analysis

Ready, set, go!

Now that you've built your BackpAQ device and configured the software, you're ready to do some AQ monitoring. This is where the opportunity to learn about where air pollution exists in your community and what you, as a concerned citizen, can do about it (and encourage others to join in!). See here for more insights.

Among the first things you'll want to consider are:

  • Where can/should I monitor AQ?
  • Is it OK to go onto private property? How do I go about asking permission?
  • Where are likely sources of air pollution?
  • What are the kinds of pollution that I can monitor with BackpAQ?
  • What kinds of data will I be collecting?

Then, once you've monitored in a few places, you'll want to consider:

  • How will I analyze the data I've collected? Are there Thingspeak or other tools I need to learn?
  • How does my data correspond or correlate with my classmates data?
  • How does my data correlate with official or regulatory data (ie, BAAQMD)?
  • Do I need to calibrate my BackpAQ with "official" monitors? With other BackpAQs? Why is this important?

We'll cover these and many more in the next module. Stay tuned and happy monitoring!

Step 19: Futures...

If you've made it this far then congratulations are in order! I realize that with all of the software and cloud configuration it's quite a task but I hope you've found it worth the trouble. Part of the very reason so much is done in the software and cloud is extensibility and future proofing. If everything was hard-coded in the hardware, it would be difficult indeed to make changes and try new things.

So, what new things might we try? Well, here's a starter list...

Easy

  • Send or share data to other clouds, such as WeatherUnderground or other environmental-related
  • Add analytics (graphs, tables, charts) to your Thingspeak/Matlab channels
  • Add NowCast calculation for more accurate realtime AQI
  • Add real-time-clock to allow more accurate timing
  • Add local SD-card data storage (this is partly implemented in V1)
  • Add NeoPixels multicolor LED display for AQI
  • More robust WiFi/credentials handling
  • Add/Change communications to Cellular or Bluetooth Low Energy (BLE)

Moderate

  • Automate data collection and analytics/reporting with Thingspeak & Matlab
  • Develop more sophisticated analytics on Matlab or similar platform
  • Calibrate with similar quality and accuracy monitors/sensors
  • Add accelerometer to measure and compensate for forces on the PM sensor
  • Add time/location-based recording capability
  • Evolve device to fit other use cases, such as mobile for use in Taxis, Uber/Lyft, Scooters, etc.
  • Connect and trigger alerts to SmartHome devices such as Alexa, Google, Siri

Harder

  • Add additional sensors Monitor gases such as CO, CO2, Nox, Sox, O3, maybe TVOC
  • Calibrate/co-locate with BAAQMD or other high-precision monitors

What's on your list?

Be the First to Share

    Recommendations

    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions

    0
    audreyobscura
    audreyobscura

    25 days ago

    THis is a really good idea! I just favorited to come see your analytics when they're up!