DIY : Building and Testing an Affordable Air Quality Monitor

Introduction

This post describes a laboratory experiment using a small, affordable air quality monitor with the capability to measure temperature, humidity and Particulate Matter (PM) 2.5 over the course of 24 hours. I’ll first explain the actual air quality monitor and its individual components and costs, and then dive into the test itself and the results that I obtained. If you are interested in air quality, DIY projects or are just curious about how today’s youth spend their time, I invite you to continue reading!

Context for air pollution and air quality monitoring

With the advent of industrialization around the world, economies are expanding, and technologies are improving. However, an unfortunate consequence of this development is drastic air pollution levels in both developing and developed nations. It has become one of the most pressing public health issues, and leads to a wide array of chronic diseases and health defects. Cardiovascular diseases, respiratory diseases and birth defects are common, and ambient particulate matter was the fifth most causal reason for deaths in 2015. These deaths and health effects lead to economic losses also, which grow overtime as more and more people need treatments for cancers and other diseases. In some countries, economies have been stifled as governments attempt to limit emitting air pollutants but have failed to truly combat the issue in many cases.

Low-cost air quality monitoring devices are extremely important for a number of reasons. For one, they can provide fairly reliable information to the average citizen of any country that wants to know more about the air quality in their area. Giving more people access to this public information can cause grass-root change, or at the very least inform citizens around the world of the quality of the air that they breathe.

Most of these low-cost air quality monitors can track temperature, humidity, PM2.5, PM10, ozone, VOCs, etc., but are not always reliable. They often differ greatly in accuracy and reliability and can be harder to maintain for long periods of time, and data standards are often insufficient or unreliable. However, they are still considered helpful in generating a broad glance at air quality, and if used in large quantities, can be effective at producing relatively accurate information and allow for higher special-resolution experiments.

Sensors

The device that I constructed and tested uses two sensors — one to detect temperature and humidity, and one to detect PM2.5 concentration. The temperature and humidity sensor, DHT-11, is a combined capacitive humidity sensor and a thermistor, and according to the Adafruit website, is “good for 20–80% humidity readings with 5% accuracy and good for 0–50°C temperature readings ±2°C accuracy.” There is also a small chip that converts the analog information to digital code to be sent to the computer. The second device, called a PPD42NS nephelometer, measures PM2.5 concentration in the air by drawing air into the device using a heater and then shining an LED light at an angle at the incoming air. If there is particulate matter, the dust will deflect the light into a perpendicular tube with a light detector, which transmits high or low pulses depending on if the light is scattered or not. The code used takes these pulses and translates them into a concentrated value.

Microcontroller

I used the Adafruit Feather HUZZAH ESP8266 for the microcontroller, which has several main features. For one, it can connect to WiFi on its own, and has the option to attach to an external battery, in addition to the micro USB port. For reading data, the microcontroller runs at 80 MHz with 3.3 V logic and can run both inputs and outputs from its pinouts. It can upload code at 921600 baud and can send this via WiFi to data centers or directly to a computer that it is attached to. Overall, it is a very effective, compact and affordable device that makes large undertakings like this and more possible. I also placed a FeatherWing OLED display on top of the Feather HUZZAH, which adds a 128×32 monochrome screen, a reset button and A, B and C buttons for additional interfaces. This allows us to see the actual temperature, humidity and PM2.5 concentrations in real time on the device.

Wiring

The Feather HUZZAH is placed on the breadboard and is connected to both the DHT-11 and PPD42NS sensors. The data wiring is yellow, and go from the 15th and 16th inputs on the Feather HUZZAH to each sensor, and the black (negative) wires go from the sensors to the negative horizontal power strips. The red wires connect the sensors to the positive power strips on the breadboard, and the FeatherWing attaches to the top of the Feather HUZZAH.

Figure 1. Diagram of Air Quality monitor, including breadboard, Arduino Feather HUZZAH, DHT-11 and PPD42NS sensors.
Figure 2. Picture of air quality monitor wiring, including black case for structure. PM2.5 sensor is vertical on the right side of the case.

3D-Printed parts and waterproof enclosure

The breadboard, Arduino pieces and sensors are all contained inside a 3D-printed container and screwed onto another 3D-printed platform, which is then screwed onto the bottom of a plastic waterproof container. The 3D-printed parts were courtesy of Professor Colin McCormick, who uploaded his own 3D STL files onto Thingiverse.com. The waterproof container is a simple plastic rectangular case with a transparent lid held together by four plastic screws, and has a cutout hole in the bottom for wires (and air) to go through (Figure 3 shows the entire device and containers together.

Battery and solar panel

To power the air quality monitor, I used several additional devices. Underneath the breadboard is a 3.7V, 2,500mah Lithium Ion battery that attaches to the Feather HUZZAH when it isn’t connected to an external power source such as a laptop of wall outlet. When the USB is plugged in, the battery charges, and once it is removed, the battery powers the Feather HUZZAH. In addition, the battery can be charged through a 6V, 2W solar PV panel, which sits apart from the rest of the monitor. In between the PV panel and the battery is a charge controller, which controls the charging and supplies power to the battery and device when needed. (Note: there was a little bit of soldering involved on the charge controller).

When there is sunlight, the PV panel simultaneously charges the battery and powers the monitor, and when there isn’t sunlight, the battery powers the monitor (which it can do on its own for a little over 24 hours). This system works fairly well, as long as the battery is charged fully before being placed outside. I had trouble keeping mine charged into the night because it wasn’t fully charged before the sun set. To do this, plug the USB port into a laptop or outlet and charge the battery. This should give it a longer, sustainable lifespan.

Figure 3. Picture of complete air quality monitor in 3D-printed case and external waterproof case. Transparent lid is removed, and solar PV panel is attached on the side.

Overall costs

Table 1. Costs and website source for all components of the air quality monitor (excluding tape, nuts and bolts, and wires).

Data connectivity

The Arduino Feather HUZZAH has a built-in WiFi chip that can connect to the internet through code on the Arduino code. Using the #define function, we can tell the WiFi connector to choose a specific Wifi connection — in this case, Georgetown University’s main campus free WiFi titled “Guest Net” — and the password that goes with it. Unfortunately, this only works where there is WiFi with a known password. On campus, this poses significant security threats, because there is no password, and anyone could hack into it. If used at home, however, the WiFi requires a password, and thus there is one more line of defense against potential hackers or threats. In this case, the only cost is the monthly cost for a WiFi connection, but on campus it is free.

Data hosting and visualization

In this experiment, the data is sent via WiFi to ThingSpeak.com, which is an online service that can receive data from the Internet of Things, model it and then analyze it. It is great for hosting large amounts of data and generating usable models and graphs to display the data. It can also receive data and post it publicly, and works with many different devices, including Arduino, Raspberry Pi, mobile apps and MATLAB, amongst others. In addition, it’s completely free, and helps make experiments like this as affordable and manageable to the everyday person. Finally, it controls time-stamping, and puts a time and date at each data point.

This system is very good considering its affordability and ease of use, and is perfect for small, personal DIY projects like this. If WiFi connectivity is strong and constant, there should be little chance for error. However, if the monitor’s power supply fails or if the WiFi being used is compromised, the device cannot connect to ThingSpeak, and the connection will be lost. I did not have any trouble with this system, except for trying to use ThingSpeak’s visualizations, which ended up being more difficult that I had expected. It was hard to use the graphs provided with the desired axes and number of data points, but otherwise it was as good of a system as was needed.

Description of code

The code starts by including seven libraries as part of the setup process, which allows the Arduino Feather HUZZAH to connect to the WiFi, FeatherWing and two sensors. Then, the Wifi and ThingSpeak settings are coded, which allows the device to connect to WiFi and send data to a specific channel on ThingSpeak.com. Following that are the two sensor settings. The DHT-11 settings set the second pin on the right side of the Feather Huzzah to correlate with the temperature and humidity sensor. The PPD42NS settings do the same on the 16th pin, and also set up the stopwatch time for measuring the time between high and low values of PM2.5. Finally, the FeatherWing OLED screen is connected to the Feather HUZZAH.

After this is all set up, the code goes into the first round of connection with the WiFi, FeatherWing display and two sensors. The while (WiFi.status() != WL_CONNECTED) statement means that if the WiFi isn’t connected, it will wait half of a second and then try again to connect, and will do that until it is connected. The void loop() statement, which is the bulk of the code, starts by staring the stopwatch for PM2.5, and then measures the PM2.5, temperature and humidity. The if () statement sees whether the time minus the start time is greater than or equal to the sample time, and if so, it goes onto the next phase of the code, which reads the PM2.5 concentration and sends it to ThingSpeak, along with the temperature and humidity data. It repeats after it has completed this task.

Description of testing

On May 3, 2018, around 4:00 PM, I placed my monitor and solar panel on the porch railing in my backyard, and let it sit for 24 hours. While the sun was out and strong, the monitor had unexpected problems, and shut down after about two hours. Because my data was rendered useless, the following was taken (with permission) from a classmate, who used the exact same setup. Her device was placed on a fence in her backyard in Georgetown, Washington D.C. on May 5 and was also plugged into an outlet for a guaranteed continuous charge throughout the night. Figure 4 shows her monitor in her backyard.

Being attached to the fence in her backyard was a suitable spot to measure air quality, as it was not next to the house and kitchen, but rather farther away from indoor sources of air pollution. It was also in a decent position to be hit by sunlight.

According to the data shown in figure 5, temperature fluctuated between 21 and 28 degrees Celsius, and humidity rose steadily and plateaued below 60 percent. The temperature was highest around 16:00:00 on May 5 and then decreased throughout the night and into the next day, and didn’t start to increase until 11:00:00 on May 6, which was normal and expected. Humidity was slightly more erratic, but that could have been a problem with the DHT sensor, which isn’t always accurate. During this time, however, there was no rain or unusual weather events, and wind was also fairly static.

PM2.5 concentrations were erratic but with only two main spikes around 15:00:00 on both days at around 600 pcs/cf. This could have been due to high levels of traffic when local schools let out, leading to more ambient exhaust from vehicles. There was one other small spike from around 06:00:00 to 10:00:00, when there was morning rush hour traffic in the neighborhood. In that sense, the PM2.5 concentrations matched what I would have expected. I anticipated a much higher level during the evening rush hour period, but there was actually a dip at 18:00:00 on May 5.

Figure 4. Classmate’s air quality monitor taped to a fence in her backyard. Wiring shows that it is plugged into an outlet instead of relying on solar PV panel and sunlight.
Figure 5. PM2.5 concentrations, Temperature and Humidity readings from 2018–05–05 15:18:04 UTC until 2018–05–06 16:04:44 UTC. Data was recorded and sent to ThingSpeak every 15 minutes, and were taken two blocks East from Georgetown University in Washington D.C.

Suggestions for improvement

Seeing as my monitor lost power after two hours, I would recommend fully charging the battery before leaving it out in the sun if the sun is about to set. Besides human error like that, the monitor itself is fairly reliable and easy to fix. The external case comes off with ease, so adjustments can be made quickly and with minimal effort. The wiring is a little clunky and cluttered, and they can fall out of the breadboard easily, so finding different wires or soldering them so they stay might help in long-term experiments. The DHT sensor is also too tall to fit into the black case, so it would be better to 3D-print a case that has a higher ceiling. Other than that, I wouldn’t change anything. For these prices, there aren’t too many other sensors and devices on the market that work as reliably and accurately, so increasing quality would mean increasing costs.

Conclusion

Building the monitor and attaching it to the case was not necessarily a difficult process; it was rather one that required a lot of help from our professor. I couldn’t have done it without his expertise, but once he explained everything, it was very manageable. Programming the code was new to me, but it wasn’t too alien of a process to be impossible. After it was explained thoroughly, I understood it and could easily adjust it on my own.

Testing the device was easy enough, as we had had enough practice in class and outside of class turning the monitor on and off. If I had remembered to charge my battery before putting it outside, I’m fairly certain that it would have worked. The solar panel was great at powering the monitor when it was in the sun, but once the sun set it was rendered useless (something I should have expected). My classmate’s device, however, worked very well, and had no problem working for 24 hours, albeit it was plugged into a wall outlet and not reliant on a solar panel.

This testing has shown me that with a little research, trial and error and $150, you can make an air quality monitor that can test temperature, humidity and PM2.5. Sensors for other pollutants such as ozone and carbon monoxide are more expensive, but not unreasonably so, and if someone wanted to make a monitor that tested for all six criteria pollutants, it probably wouldn’t be out of the question. Cheap monitors like these make it possible for citizens to be scientists and allow for the spread of knowledge of air quality, one of the most important measurements of environmental and human health. If people are interested in these kinds of devices, I highly recommend that they follow these steps and make their own — you might be surprised by how much you learn and enjoy this hands-on approach to atmospheric science.

LEAVE A REPLY

Please enter your comment!
Please enter your name here