Friday, October 18, 2013

Measure air pollution in your home or backyard with a DustDuino


This week, the World Health Organization (WHO) took a major step by announcing that air pollution is carcinogenic to humans.

WHO also announced they are considering particulate matter, a major component of indoor and outdoor air pollution, as carcinogenic to humans as well.


The International Agency for Research on Cancer (IARC), a special unit inside WHO tasked with promoting international collaborations on cancer research, reached that conclusion after reviewing more than 1000 scientific papers on the carcinogenicity of air pollutants.

Air pollution and particulate matter will be included in IARC's Monograph, which is an encyclopedia of known carcinogens. Particulate matter will be classified as a Group 1 carcinogen, along with tobacco smoke and asbestos.

In an IARC press release [1], the Deputy Head of the Monographs Programme, Dr. Dana Loomis, said that the group's goal was to "evaluate the air everyone breathes rather than focus on specific air pollutants."

"The results from the reviewed studies point in the same direction: the risk of developing lung cancer is significantly increased in people exposed to air pollution," he said.

This finding elevates the urgency to clean up the air, both outdoors and indoors. But how does one find out the condition of the air in the first place? How healthy is your air?

Finding that answer can be difficult and expensive. Most Environmental Protection Agency-quality particulate matter monitors send air through a filter, which must be precisely weighed, and produce only one reading a day. Other EPA monitors that sample continuously cost more than $14,000 each to deploy.[2]

Mass concentration is the norm for quantifying airborne particulate matter worldwide, and is usually expressed in micrograms of particulates per cubic meter of air (μg/m3). However, there are an increasing number of affordable particulate sensors coming on the market which rely instead on lasers and LEDs to count the number of particles instead.

For more background on the specifics of particulate matter sensing, please refer to earlier work on Mental Munition regarding particle counting sensors [3,4]. This post will focus on hacking together your own DustDuino prototype, which will allow you to monitor dust levels in your home (or back yard) from anywhere you have internet access, for about $100.

What will the end product look like, online? It will look a little like this (my own live DustDuino feed).

To make a DustDuino, you will need:



1) A WiFi network in your home
2) Arduino Uno development board
3) Arduino Wireless Proto Shield
4) Shinyei PPD-42 Dust Sensor
5) Sparkfun Roving Networks RN-XV WiFi module
6) USB type B cable (for programming the Arduino)
7) 9V DC power supply (or a 5V USB cell phone charger along with your USB-B cable)
8) 22AWG solid core hookup wire (M/M jumper wires can be used in a pinch)
9) Soldering equipment (soldering iron, solder, and soldering paste)
10) Arduino sketch from the DustDuino GitHub repository (zipped repo also contains background literature on the PPD-42, mass concentration algorithms, and the DustDuino logo).

Step 1: Program the WiFi module


For the DustDuino to transmit any data, it needs to be connected to your home WiFi network. Consult my post on programming the RN-XV for details.

Like the Arduino Uno, which serves as the DustDuino's "brain," the RN-XV will be on constantly. The RN-XV is set up to connect to your home's WiFi network as soon as power is connected, and it will remain connected so long as there is power.

Step 2: Hook up the Shinyei PPD-42 particulate sensor


When you order the Shinyei sensor, it will come packaged with a connector to interface with the Seeedstudio Grove Shield. Instead of purchasing a whole new shield just to attach a single sensor, I recommend simply sticking either jumper wires, or stripped 22AWG solid core wire into the end of the Grove connector.

The black wire on the Grove cable corresponds to ground, so that wire should be connected to GND on the Arduino Wireless Shield. The red wire on the Grove cable will be connected to 5V on the Wireless Shield, while the remaining white wire will be plugged into the digital "8" pin on the Shield.


There's another issue with using the included Grove connector: it doesn't make use of all the sensor's available channels. The included connector will only make use of the Shinyei's P1 channel, which is for counting particles between 1 and 10 microns. But the PPD-42 also has a P2 channel, which counts particles between 2.5 and 10 microns.

By measuring both P1 and P2 channels, it's possible for the DustDuino to differentiate between the PM2.5 and PM10, which are the two major ranges of particles recognized by the EPA and similar agencies. The smaller particulates that measure 2.5 microns and under are of special concern, since those have the potential to enter the blood stream and cause the most harm [5].

To measure the P2 channel, strip a solid core 22AWG wire and solder the end of the wire to the second pin on the PPD-42. This is the pin located between GND and 5V. It might be a good idea to use a little hot glue to insulate the connection and provide a little strength.

Your new P2 channel will be connected to the digital "9" pin on the Wireless Shield.

Step 3: Set up a Xively account


All that data being produced by the DustDuino will have to go somewhere, and it might as well go somewhere you can easily access. Xively is a service that markets itself as a "public cloud specifically for the internet of things," which allows you to view your sensor data from home computer, tablet, or smartphone.

That service can get quite expensive, but you can sign up for a free developer account, which can store up to 30 channels of data across five devices (a channel is a single stream of data -- like temperature, or humidity, or PM2.5 or PM10). With a free Xively account, any data older than 30 days will be deleted.

Xively can walk you through the process of setting up an account, but there are some specific things you'll need to do to make sure it's set up to receive DustDuino data.

You will need to create a device with four channels, named:

PM10
PM10count
PM25
PM25count

PM10count and PM25count channels will store the number of PM10 and PM2.5 particles counted by the Shinyei PPD-42 sensor, while PM10 and PM25 channels will store mass concentration as calculated by the DustDuino code.

Record the Feed ID for this device, which you'll need to insert into the Arduino code later. Also save the name of the device, which you'll also need for the Arduino code.

The last thing you'll need to do here is to create an API key which will give your DustDuino permission to store data on your Xively account. Every time the DustDuino sends data to Xively, it needs send along this unique key. To make a new API key, or find an existing key, go to "settings," and then click "Master Keys."

Copy and paste this API key somewhere easy to find, as you'll need to manually insert it into the Arduino code in our next step.

Step 4: Code the Arduino


The Arduino is fairly capable "out of the box," but for more complicated tasks like getting the RN-XV to connect to the Xively server, it's helpful to have blocks of code already written out. Those blocks of code are known as libraries.

Fortunately there's only one library you'll need for the DustDuino, and that's the WiFlyHQ library. The Arduino website has instructions on how to install Arduino libraries.

After installing the WiFlyHQ library, open up the DustDuino.ino file in the Arduino IDE. Find the #define APIKEY code and replace the hash signs with your API Key.

Find the very next line, which begins #define FEEDID, and replace the hash signs with the Feed ID.

Finally, in the very next line, which begins #define USERAGENT, replace the hash signs with the device name.

Save the sketch, and with the Wireless Shield detached from the Arduino Uno, upload the sketch to the Arduino. After the sketch is uploaded, you may re-connect the Wireless Shield. Make sure the switch on the Wireless Shield is set to "Micro" before connecting your DustDuino to a power source.

You have several options for powering your DustDuino. You can purchase a separate "wall wart" style 9-volt DC adapter for the Arduino, or you can run power through the Arduino Uno's USB-B port.

If you do decide to supply power through the USB-B port, you may do so with a universal cell charging adapter that has a female USB connector. Most of these chargers supply 5 volts, but just to be sure, make sure to read any text on your cell charger. Another easy way to power the Arduino Uno is to keep it plugged in to your computer's USB port, but you have to keep your computer powered at all times.

Step 5: Keep everything together


The Shinyei PPD-42 must be placed upright to work correctly. In other words, it must be placed on a vertical surface, with the connector must be pointing down, and the chrome part of the sensor pointing up.

This placement is important to drive air into the sensor. Inside the sensor chamber, at the bottom, is a resistor that heats up when power is connected. With this resistor, the sensor creates a warm updraft of air, which is meant to circulate dust inside the chamber.

According to an email from Shinyei customer service, the sensor doesn't need any kind of fan to blow air inside the sensor chamber. But the chamber must be open to the air you wish to sense.

The container doesn't have to be elaborate. One solution is to secure the sensor to the side of a cardboard box with a pushpin (the sensor has a convenient hole at the top of its circuit board for this kind of thing). If you have a cork board or other board that can be stuck with pins, you also can mount your sensor on a wall.



At the beginning of this post is a picture of a work in progress: an acrylic cube in which to store the DustDuino. The sides of this cube were cut from an 1/8th inch acrylic sheet using a 50-watt CO2 Epilog laser engraver at the CU Community Fab Lab. The design is not yet perfected, but when finished, the pattern will be made available as a PDF for download.

Please note that if you intend to deploy this sensor in your backyard, you will need to make a waterproof housing that still allows the sensor to sample air. You must also ensure the power source to your DIY housing is waterproof, as well. Like the indoor acrylic housing, this is a work in progress.

One last word about this prototype


The DustDuino is a work in progress. I cannot make any guarantees as to whether your particular project will work. Having said that, this device has worked great for me so far. So given my personal success, and the recent WHO and IARC findings about particulate matter being carcinogenic, I felt it was time to release instructions and code into the wild.

If you put together a DustDuino have it working correctly, or have any suggestions, feel free to drop me a line at mschroyer@gmail.com.

Also, if this device has proven useful for you, please consider donating to MentalMunition.com. Funds will go to develop ready-to-deploy DustDuino devices.

Sources


[1] "IARC: Outdoor air pollution a leading environmental cause of cancer deaths," International Agency for Research on Cancer, 17 October 2013.
[2] Uva, M., Falcone, R., McClellan, A., Ostapowicz, E. "Preliminary Screening System for Ambient Air Quality in Southeast Philadelphia," Drexel University, 2009.
[3] Schroyer, M. "Understanding air pollution with a simple dust sensor," MentalMunition.com, 5 September 2013.
[4] Schroyer, M. "DustDuino: A plan to crowdsource environmental reporting with low-cost dust sensors," 30 May 2013.
[5] "What Are the Six Common Air Pollutants?" Environmental Protection Agency, 20 April 2012.