An Introduction to Air Pollution and the Construction and Use of Low-Cost Air Quality Monitors

Brandon Greenblatt
16 min readMay 7, 2018

Introduction

This blog post will provide you with a deeper knowledge of current global air pollution problems, their impacts, and the importance of monitoring efforts to better understand air quality. The majority of this post will instruct you on how to build and utilize your own low-cost air quality monitor using Adafruit components and Arduino software. After reading this blog post, you will hopefully both understand contemporary air quality issues and be better equipped to monitor your own environment. Anyone with a budding interest in computer coding, electronics, and/or understanding their exposure to air pollution will find this blog post interesting.

Context for Air Pollution and Air Quality Monitoring

‘Air pollution’ describes abnormal or unusual vapors, gases, particles, or other small matter in the atmosphere that harms human and environmental health. Air pollutants come from natural and anthropogenic sources and persist in the troposphere, or the lowest layer of the atmosphere.

Air pollution is an important problem to address because of its adverse health, economic, and environmental impacts. The health impacts of outdoor air pollution on humans are often related to the respiratory and cardiac systems and include heart disease, lung cancer, ischemic heart disease, chronic obstructive pulmonary disease (COPD), and asthma. The Health Effects Institute found in its State of Global Air 2018 report that ozone pollution contributed to 234,000 deaths from chronic lung disease while PM2.5 exposure accounted for 4.1 million deaths from respiratory and cardiac illnesses in 2016. The major economic impacts of air pollution include increased healthcare expenditures to treat the aforementioned conditions, reduced labor productivity, and reduced economic output from a depleted labor force. In Egypt, for example, outdoor air pollution has been linked to 1 percent annual losses in GDP. The environmental impacts of outdoor air pollution include urban smog and soot, reduced visibility due to haze, climate change acceleration via greenhouse gas emissions, and stratospheric ozone depletion.

Air pollution over Mexico City causes a yellow haze that reduces visibility. Source: Britannica

Monitoring and measuring air pollution will provide individuals with greater knowledge about their exposure to harmful airborne materials at both point-source and ambient levels, and at small and large scales. Governments can use regulatory-grade air quality sensors to develop policies that minimize air pollution levels — such as the United States’ Corporate Average Fuel Economy (CAFÉ) standards, Environmental Protection Agency Renewable Energy Certificates, and industrial pollutant standards. Government agencies can also provide sensor network data to citizens. Individuals monitoring air pollution, through either regulatory-grade data or that which they collect from low-cost air quality monitoring devices, can adjust their behavior to minimize personal exposure.

Low-cost air quality monitoring devices are especially useful for individuals to measure exposure at small spatial scales where regulatory grade data is not available or too expensive to procure. This is often true in developing countries, where municipal and federal governments regularly lack the technology, infrastructure, and funding to install advanced monitors that meet World Health Organization specifications. However, even in these areas, individuals and/or nonprofits can sometimes afford to purchase and install low-cost devices that monitor air quality. These devices can measure small-scale spatial variations in places such as an individual household or one’s workplace. This could help an individual improve his/her personal health if he/she decides to consciously limit exposure to extreme temperatures and particulate matter, for example. Like regulatory-grade devices, low-cost devices can continuously monitor air quality at specified intervals and transmit data via a WiFi connection to relevant databases and cloud technology. A critical limitation of these devices is that since they are necessarily constructed from inexpensive materials, they are usually less accurate than regulatory-grade monitors. However, one key advantage of low-cost devices is that they are transportable, especially if battery operated, and can be used to measure air quality in a variety of locations.

Sensors, Microcontroller, and Wiring

This device uses a DHT11 sensor to monitor changes in temperature and humidity at a small spatial scale. The DHT11 sensor includes a thermistor to measure temperatures from 0°C to 50°C, with a margin of error of 2°C. The capacitive humidity sensor is accurate between 20% and 80% humidity, with a margin of error of 5%. The DHT11 sensor can collect measurements at most once every second. It also includes a computing chip that conducts simple analog to digital conversions so that the data can be read by a microcontroller.

DHT11 Temperature and Humidity Sensor. Source: Adafruit

The device also uses a PPD42NS grove-dust sensor to monitor PM2.5 concentrations. The nephelometer operates a small resistor/heating element that draws air through the sensor. Using an infrared LED beam, lighting baffle, and photodiode detector, the sensor then measures the intensity of scattered LED light caused by particles moving through the device. This measurement is used to calculate PM2.5 concentrations in pcs/ft3. A piece of tape covers a hole in the device to prevent extraneous light interference.

PPD42NS Grove-Dust Sensor. Source: Mouser Electronics

This sensor uses an Adafruit Feather Huzzah microcontroller that includes an ESP8266 WiFi transmitter. This sensor can receive temperature, humidity, and PM2.5 concentration data from the DHT11 and PPD42NS sensors, respectively. The microcontroller’s WiFi transmitter can wirelessly send collected data to the ThingSpeak platform, where data is automatically plotted and organized on a continuous timescale basis. This data is also displayed on a FeatherWing 128x32 OLED screen which rests atop the microcontroller and is secured by pins. This screen has an “A” button which has been coded to pause data collection when pressed, a “C” button which has been coded to resume data collection when pressed, and a “Reset” button that instructs the microcontroller to proceed from the start of its code when pressed.

Feather Huzzah Microcontroller. Source: Adafruit

With regard to physically attaching various components of the device, the microcontroller and DHT11 sensor both include pins that are inserted directly into holes in the Adafruit breadboard, while the PPD42NS sensor is bolted to the waterproof case within which the entire monitor sits. However, a wiring system is necessary to transmit power throughout the device and to enable components to communicate with one another.

This power is transmitted to the microcontroller device through a solar panel, battery, and charge controller network that is described in more detail below. However, once power is transmitted to the microcontroller, a wire from the VBUS port on the microcontroller connects to the red positive rail to transmit power to the breadboard. A second wire from the GND ground port on the microcontroller to the blue negative rail closes this circuit.

For the DHT11 sensor, a wire from the ‘+’ pin in row 26 connects to the positive red rail to transmit power. A wire from the ‘-’ pin in row 22 connects to the negative blue rail to close the circuit. A wire from the ‘out’ pin in row 25 to Pin 2 on the microcontroller transmits humidity and temperature data collected by the DHT11 sensor to the microcontroller.

For the PPD42NS sensor, the red wire connects to the red positive rail to transmit power. The black wire connects to the blue negative rail to ground and complete the circuit. The yellow wire connects to Pin 16 on the microcontroller to transmit PM2.5 data collected by the PPD42NS sensor to the microcontroller.

This picture shows the wired components of the low-cost air quality monitor within the waterproof enclosure. This wiring schematic can be reproduced to construct your own low-cost air quality monitor.

3D-Printed Parts and Waterproof Enclosure

This device includes three components that were 3D-printed. The STL files for all three components are available on Thingiverse here, with the specific files including the plastic case which holds the microcontroller, breadboard, battery, and DHT 11 sensor; the lid for that case; and a box adapter which is used to secure all device components to a waterproof plastic enclosure. The above picture shows the plastic case, but the lid has been removed and the box adapter cannot be clearly seen beneath all of the components. All three of these STL files can be printed after being converted to a gcode file format with the Slic3r program.

All of the device components sit within a waterproof plastic enclosure from Adafruit. The box adapter is bolted to the inside-bottom of this enclosure, and then all of the device components (the PPD42NS sensor; the charge controller; and the plastic case holding the microcontroller, breadboard, battery, DHT 11 sensor, and wires) are affixed to this box adapter using bolts or screws. The air from which the sensors derive their measurements enters the enclosure through a hole cut out in the bottom of the case as it stands upright. The solar panel sits outside this case.

Battery and Solar Panel

The monitor receives power through a network of a lithium polymer charge controller, a lithium polymer battery, and either a solar panel or electrical outlet in a wall. (Pictures and specifications for each of these components can be found via the hyperlinks in the subsequent ‘Overall Costs’ section.)

When the sun is shining, a medium 6V 2W solar panel derives energy from solar radiation and transmits it to a charge controller via a DC Jack Adapter Cable that connects to the black port of the charge controller. The charge controller regulates the transmission of power to the battery that sits underneath the breadboard, controlling charging based on whether or not the battery is fully. This connection is established via red and black wires that run from the battery to the ‘BATT’ port on the charge controller. The charge controller also has a second set of red and black wires soldered to it that connect to the ‘Optional Lipoly Battery’ port on the microcontroller in order to directly power the device.

When the sun is not shining, the battery can be charged via an electrical outlet in the wall. Power is transmitted to the charge controller from the electrical outlet through a USB-HDMI B cable to the gold ‘DCIN’ input port on the charge controller and then to the battery.

For optimal performance, the solar charging system should be used once the battery has been fully charged. The battery will lose its charge when powering the monitor, but the solar panel will transmit small amounts of power back into the battery and slow down this depletion. In effect, using the solar panel prolongs battery life. However, attempting to charge the battery via solar energy alone will not generate enough power to allow the monitor to run for a full 24 hours.

Overall Costs (USD)

Adafruit Feather HUZZAH with ESP8266 WiFi: $16.95

Adafruit half-size breadboard: $5.00

DHT11 basic temperature-humidity sensor: $5.00

PPD42NS Grove-Dust Sensor: $11.50

FeatherWing 128x32 OLED Display Screen: $14.95

Lithium Polymer Charge Controller (USB/DC/Solar Lithium Ion/Polymer charger — v2): $17.50

Lithium Polymer Battery — 3.7v 2500mAh: $14.95

Medium 6V 2W Solar panel — 2.0 Watt: $29.00

DC Jack Adapter Cable: $0.95

Right Angle HDMI to USB Cord: $2.79

Plastic Case for Breadboard, Feather Huzzah Microcontroller, Wiring, and Display Screen: $0.25

Plastic Lid for Case Holding Breadboard, Feather Huzzah Microcontroler, Wiring, and Display Screen: $0.10

Plastic Mounting Device for Waterproof Enclosure: $0.25

Large Plastic Project Enclosure — Weatherproof with Clear Top: $19.95

Total Cost: $139.14

Data Connectivity and Hosting

This device connects to the Internet through the ESP8266 WiFi transmitter included in the microcontroller. The Arduino code uploaded to the monitor includes instructions which define the particular WiFi network/password and subsequently transmit data over the Internet using an HTTP Post command. This method for connectivity will only work in places where the WiFi network login credentials are valid and the connection is reliable, which could reduce the portability of the device. Since the device represents a node to the WiFi network whenever it is connected, a security issue may arise if malicious code is uploaded to the device and later transmitted to the broader network, infecting devices which are independently connected to the network and entirely unrelated to the air quality monitor. Moreover, if the device is connected to an unsecure WiFi network, the data it collects could conceivably be corrupted or inhibited during transmission — though interference with low-cost air quality monitoring devices have rarely, if ever, been observed.

The device sends data to- and stores data on- the ThingSpeak platform via the aforementioned WiFi connection. The data is stored on a specific user account and channel as denoted by an API key that identifies the channel and is included in the Arduino code uploaded to the device. The ThingSpeak application can graphically plot air quality metrics as a function of time, and the display of these metrics can be adjusted to account for particular timescales and quantities on each axis. ThingSpeak can also calculate summary statistics — such as average, median, and sum — from the data it receives. Finally, the ThingSpeak application can conduct MATLAB analysis and visualizations and can also export data in Microsoft Excel file format. The ThingSpeak platform is especially useful because it saves data transmitted from the monitor such that users can retrieve data from previous experiments in the future. This would allow you to compare the results of different experiments conducted at disjoint times. The ThingSpeak is software relatively affordable and free for student use when the license is provided by Georgetown University. Otherwise, a student license costs $79.00/unit, a home license costs $95.00/unit, an academic license costs $250.00/unit, and a standard license costs $650.00/unit.

Description of Code

A full version of the Arduino code uploaded to this air quality monitor is available on the GitHub repository here.

The IDE code begins by loading all necessary libraries from the Arduino database and defining WiFi and ThingSpeak channel settings. This enables the device to transmit the collected data to the hosting platform.

The code then defines the DHT11 and PPD42NS settings to establish how often data points will be collected. The code also defines the SSD1306 settings to control the OLED display device. The code then defines settings for the microcontroller to display its activity and collected data on the OLED display in real time. The void setup loop includes a command to turn the display upside down (so that it is readable given the orientation of the device) as well as what text to display as the device is connecting to WiFi and once the monitor begins to function. Part of this WiFi set up command is a while () command that tells the microcontroller to attempt a connection with the WiFi network every 500 milliseconds until a connection is established.

Once this connection is established, the subsequent void loop if () tells the microcontroller to display text that instructs users how to use the aforementioned Buttons A and C. An ‘if’ statement then tells the microcontroller to wait until a connection has been established and then to proceed to the next portion of the code and begin collecting air quality data. This segment then instructs the microcontroller to collect measurements of temperature, humidity, and PM2.5 concentrations every 15 minutes. The high/low pulse command for the PPD42NS sensor applies a threshold level to convert measurements to binary ‘Low’ or ‘High’ levels. This portion of the code starts the measurement cycle when the value is low, stops the measurement cycle which the value is high, calculates a ratio over the length of the cycle to describe when the measurements were low or high, and then uses a calibration curve to determine a particle count value.

The next portion of the code, which uses ‘s=’ commands, instructs the device to print all measurement values from the DHT11 and PPD42NS sensors on the OLED display screen. A later if (client.connect) statement commands the microcontroller to connect to the ThingSpeak server and transmit collected data to particular fields on the channel, once the Internet connection has been established. This entire data collection and transmission process repeats every 15 minutes indefinitely until the client.stop() command closes the connection to ThingSpeak and resets the cycle.

Description of Testing

To measure my own exposure to outdoor air pollution, I positioned my monitor outside atop a railing on my house’s back deck and collected air quality data for 24 hours. The monitor sat approximately 1 foot away from the side of the house, in close proximity to the door which leads from my house’s kitchen to the back deck. Therefore, the temperature, humidity, and PM2.5 data collected by the device may include some interference from when the kitchen door was opened — such as cool air drafts from indoors or particulate matter created from someone burning food on the stove. On the whole, though, the positioning of the device was effective in collecting data from outside. The entire plastic enclosure was elevated vertically atop bricks on either side of the air hole such that air being monitored could freely enter the enclosure from below. The solar panel rested against the back of the plastic enclosure, facing the sun, such that the clear plastic case would face my house. This was an intentional decision to minimize overheating of the electronic circuits within the case. It was also an effective source of providing solar power to prolong the life of the battery.

The monitor was positioned on a railing on my back deck.
The monitor sat atop two bricks with the solar panel resting against the back of the enclosure. The clear plastic lid and case protect all sensitive monitor components from the weather.

The data plots provided below show measured temperature, relative humidity, and PM2.5 concentration values as measured between 8:50 PM on April 30, 2018 and 8:50 PM on May 1, 2018. There were no significant weather changes during that time, as the recorded temperature in Washington, DC ranged in the 60s-80s°F (approximately 16–27°C) during the daytime and 50s-60s°F (approximately 10–14°C) during the nighttime over the 24 hour period. Recorded relative humidity values ranged between approximately 17% and 55% over the 24 hour period. The skies were clear, and there was no rain at this time either.

The temperature varied as expected during the 24 hour measurement period. While the initial spike from 24°C to 38°C from 8:50 PM to 10:20 PM on April 30 was unexpected, it may be attributable to the monitoring device first starting to function and recalibrate itself. The general trend — in which temperatures cooled rapidly and then gradually overnight before beginning to rise around midday on May 1 and then continuing to rise through the early evening — comports with standard daily heating and cooling patterns. It is worth noting that the boundaries of the temperature data, between 12°C and 38°C, are a few degrees higher than the official temperature record reflects.

Relative humidity varied as expected during the 24 hour measurement period as well. As the ratio of partial pressure of water vapor to equilibrium pressure of water at a given temperature, relative humidity should be expected to rise as temperature falls. Temperature and relative humidity exhibit an inverse relationship because warmer air holds more moisture than colder air. The relative humidity data collected indicates this. As temperatures fell overnight and rose during the daytime on May 1, relative humidity generally rose overnight and until midday on May 1 before falling in the afternoon and evening.

The PM2.5 concentration data does not show a trend that corresponds to observed events in any particular manner. I would have expected PM2.5 concentrations to be low overnight when there was minimal traffic in the street behind my backyard before spiking around 9:00 AM and 6:00 PM as vehicular traffic increased due to peoples’ commuting schedules. The data collected does not reflect this trend. I do not have a discernible reason for why PM2.5 concentrations were relatively high during the early morning hours of May 1 and relatively low during the mid-late morning of that day. However, one possible explanation for the relatively higher PM2.5 concentrations from 1:00–3:00 PM on May 1 specifically is construction and demolition activity in the neighborhood, though I know that such activity occurred throughout the entire workday on May 1, so any elevated particulate matter levels should have been observed for a time period greater than just those two hours.

Suggestions for Improvement

It would be particularly helpful if the Arduino software for this device was coded to convert the PPD42NS sensor’s PM2.5 measurements from units of pcs/ft3 to units of μg/m3. Given that WHO standards and the vast majority of regulatory-grade air quality data are reported in μg/m3, collecting data in different units renders this PM2.5 data useless for purposes of comparison to other areas of the world. The device could also incorporate additional sensors, such the CCS811 Air Quality Sensor Breakout developed by Adafruit for $19.95 to measure Volatile Organic Compounds or carbon dioxide (CO2) concentrations indoors. If you wanted to make the air quality monitor mobile to measure pollution continuously in a variety of locations, the addition of the Adafruit Ultimate GPS Logger Shield and GPS module for $44.95 would be helpful in tracking where measurements were taken.

Conclusion

This low-cost air quality monitoring device was relatively easy to build and program, particularly as the Arduino code was provided in coherent increments by Professor McCormick, and a master version is currently available on GitHub. It was easy to print the 3D plastic components of the device and to physically assemble all of the hardware pieces into the waterproof enclosure. Testing this device is a simple process too, as long as you ensure that you correctly program the microcontroller to collect data at your preferred time interval.

From testing, I learned to analyze data on the ThingSpeak platform and in Microsoft Excel, while simultaneously attaining a greater understanding of the air quality situation in my backyard. Moreover, by rudimentarily comparing observational values to data provided by the National Weather Service, I was able to assess disparities between the accuracy of my device and the accuracy of regulatory-grade air quality monitors. The device performed as expected and registered sensible temperature and relative humidity values in particular, though I remain skeptical as to the true degree of accuracy for relatively inexpensive sensors.

Solar power proved unable to fully charge the device and sustain the battery life for a full 24 hours, but it was able to counteract the depleting charge of a battery. Solar power therefore successfully enabled me to collect data over the course of 24 hours in relatively clear and sunny skies during the daytime.

By conducting a test of my monitor outdoors, I learned that such devices offer enormous potential for understanding one’s personal air quality exposure. The device described above is simple to construct and operate, and it offers fairly reliable measurements of temperature, humidity, and PM2.5. However, despite being advertised as “low cost” the device is rather expensive at $140. A variety of components that make the device portable and operational outdoors — such as the solar panel, charge controller, lithium polymer battery, and waterproof enclosure — are especially pricey and quickly add up costs. Choosing to monitor indoor air quality alone –where an electrical outlet can power the microcontroller and the aforementioned components are not necessary — is a far cheaper option but inevitably impedes the functionality and usefulness of the device.

--

--