A measure of PM2.5 with the Weatherduino -
zitoune - 27-08-2016
Hello everyone,
Throughout the years, Werk_AG has been developing a powerful weather station, with advanced capabilities and always more variables to measure.
In an attempt to add my little stone to this already great project, I’d like to propose to measure something I experience from time to time where I live.
I live in Singapore for a few years already, and at certain periods of the years, the city and its whereabouts are surrounded by an unpleasant smell coming from the forests on fire mainly from Indonesia. This phenomenon is named the “
haze”.
What is the haze? Well, imagine you are caught in the middle of a big fire (or simply at the back of your garden) and you smell this strong odor of burnt wood; well, this is what the haze is about..
A more comprehensive definition
here
Where is it coming from? Well, transboundary haze in Southeast Asia has been recorded since 1972. The haze is largely caused by illegal agricultural fires due to industrial-scale slash-and-burn practices in Indonesia, especially from the provinces of South Sumatra and Riau in Indonesia's Sumatra island, and Kalimantan on Indonesian Borneo.
So every year, Singapore “swims” in the haze. It’s of course not healthy and prevents outdoor activities.
What can we do about it? Mmm though this is illegal, every year seems to repeat itself, and farmers in Indonesia keep burning their plantations. When it happens, better closing doors and windows. After, this is a political matter too..
Anyway, the National Environment Agency (NEA) maintains information (
http://www.haze.gov.sg) on the quality of the air in the city and offers a full range of measures – the most popular being the
PSI index.
The PSI reflects a total of
six pollutants - sulphur dioxide (SO2), particulate matter (PM10) and fine particulate matter (PM2.5), nitrogen dioxide (NO2), carbon monoxide (CO) and ozone (O3).
What is a matter of interest is actually the
1-hr PM2.5. Particulate matter, or PM, is the term for particles found in the air, including dust, dirt, soot, smoke, and liquid droplets. The problem is that particles less than 10 micrometers in diameter (PM10) pose a health concern due to possible inhalation and accumulation in the respiratory system. Particles less than 2.5 micrometers in diameter (PM2.5) are referred to as "fine" particles and can lodge deeply into the lungs.
So I have decided to also measure the PM2.5. I had bought this sensor a long time ago but never really found the time to do so. Now that my Weatherduino Pro2 upgrade is done, I finally did it!
The theory
There are a few sensors on the market capable of measuring PM2.5; I eventually decided to get the
Sharp DN7C3CA006 module (
full specs here). Note that it also exists the Sharp GP2Y1010AU0F, but this one does not incorporate a fan (more on this later).
It is equipped with a particle separator, which uses the air pressure of a fan and passes micro particulate matters (PM2.5) to the dust sensor that detects micro particulate matters.
The bloc diagram is as follows:
Driving the sensor is simple and needs a PWM signal to power on the internal LED. Later, we need to measure the sensor output.
This module outputs a voltage that changes with the particle volume concentration (μm/m3) of dusts in the atmosphere. It won’t measure the
mass concentration (μg/m3) that is what we are interested in. However, with a simple formula, it is possible to approximate the mass concentration.
The measurement range is 25-500μm/m3 and is good enough.
To convert the volume to a
mass concentration, there are two steps:
1. We need to get a
reference voltage.
This can be obtained either by storing a reference voltage (Vs) in an environment with less dust (a clean box for instance) or by storing a reference voltage (Vs) corresponding to state where particles fall by gravity (using a fan). We are going to use the second method here.
Note: that's why I did not opt for the Sharp GP2Y1010AU0F as it does not have a fan.
2. Measure the Δ voltage[mV] (Vo[mV] – Vs[mV])
between the reference voltage(Vs) and the output voltage (Vo) when the fan is turned on.
Then it is possible to approximate the PM2.5 level by use following conversion formula:
PM2.5 level (μg/m3) = α × β ×(Vo[mV] – Vs[mV])
Where:
α: Conversion factor in the true environment. Recommendation : 0.6
β is the humidity factor(h=humidity(%)) given by:
β =
{1-0.01467 * (h-50)} if h>50
or
β=
1 if h≦50
So you see me coming; we are now all set to measure the PM2.5 with an arduino and a few components!
The practice
I have setup a working prototype using an arduino nano and a breadboard.
The prototype looks like this:
The corresponding code is here below.
Code:
/***********************************************************************************
2.5ppm Sensor Reader
Version: : 1.0
Version Release date : 26/08/2016
Last revision date : 27/08/2016
This program uses a Sharp DN7C3CA006 module to measure the volume concentration of
2.5ppm particules using a light scattering method. The module irradiates atmospheric
dust going along the sensor with a LED and detects the borrowed light.
The voltage changes by reflected light. The output voltage change as a particle
volume concentration (μm/m3) of dusts in the atmosphere. It is necessary to convert
the volume concentration toobtain the mass concentration (μg/m3).
**************************************************************************************/
// --------------------------------------------------------------------------------------
// Hardware input/output pins
// --------------------------------------------------------------------------------------
int SensorPin = 0; // Seonsor output connected to A0
int PowerLEDPin = 12; // LED power connected to D12
int PowerFanPin = 8; // Fan power connected to D8
// --------------------------------------------------------------------------------------
// General global variables
// --------------------------------------------------------------------------------------
// Pulse sampling timing caracteristics: Pw = 320ms; T=10ms
int RisingTime = 280; // Pulselenght of 0.28ms to power the LED
int deltaTime = 40; // time left after pouwer up to read the value
int sleepTime = 9680; // T = 10000ms-320ms=9680ms
int countReading = 30; //reading counter
float countMeasure = 100; //number of sensor measures
float VsRead = 0;
float humidity = 80; //humidity level (coming from WeatherDuino Pro2)
float alpha = 0.6; //alpha factor (recommended value) to derive teh mass concentration
float beta = 0; //beta factor, humidity dependant, to measure the mass concentration
float VsOutput = 0;
float VsFinal = 0;
float V0 = 0; // Stores measured output (0-1023) from sensor
float SensorOut = 0; // actual voltage output from sensor
float V0Sensor = 0;
float V0SensorFinal = 0;
float DustDensity = 0; // dust density [ug/m3]
float Vs = 0; // Vs reference value
// --------------------------------------------------------------------------------------
// Sensor calibration function to compute a reference for Vs when fan is OFF
// Vs reference will be computed upon startup by averaging countReading measures
// --------------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
pinMode(PowerLEDPin, OUTPUT); //declare LED output
pinMode(PowerFanPin, OUTPUT); //declare Fan output
digitalWrite(PowerFanPin, LOW); // power off Fan to begin measurement
delay(2000);
for (int i = 0; i <= countReading; i++) {
delay(1000);
digitalWrite(PowerLEDPin, LOW); // power on the LED
delayMicroseconds(RisingTime); //Wait RisingTime before reading V0output
VsRead = analogRead(SensorPin); // read the sensor output
delayMicroseconds(deltaTime); //Wait deltaTime before powering off the LED
digitalWrite(PowerLEDPin, HIGH); // power off the LED
VsOutput = VsRead * 5.0 / 1024.0; // Calculate actual voltage [V]
VsFinal = VsFinal + VsOutput; //Adding up all read voltages
Serial.print(" Vs Output [mV]: "); // Print Vs Output to see progress
Serial.print(VsOutput*1000); // print mV
Serial.print(" VsTotal [mV]: "); // Print Vs Total to see progress
Serial.println(VsFinal*1000);
}
Vs = VsFinal / (countReading) * 1000.0; //Calculate reference value (Vs)
digitalWrite(PowerFanPin, HIGH); // power on Fan
delay(2000);
Serial.print(" VsFinal [mV]: ");
Serial.print(Vs);
}
// --------------------------------------------------------------------------------------
// Main Program
// --------------------------------------------------------------------------------------
void loop() {
measurement();
}
// --------------------------------------------------------------------------------------
// Measurement Function
// V0 is computed and compared to Vs to compute the mass concentration
// --------------------------------------------------------------------------------------
void measurement() {
V0Sensor = 0;
V0SensorFinal = 0;
for (int i = 0; i < countMeasure; i++) {
delay(100);
digitalWrite(PowerLEDPin, LOW); // power on the LED
delayMicroseconds(RisingTime); //Wait RisingTime before reading V0output
V0Sensor = analogRead(SensorPin); // read the sensor output
delayMicroseconds(deltaTime); //Wait deltaTime before powering off the LED
digitalWrite(PowerLEDPin, HIGH); // power off the LED
V0SensorFinal = V0SensorFinal + V0Sensor;
}
SensorOut = V0SensorFinal / countMeasure; // measure the average on countMeasure
V0 = SensorOut * (5.0 / 1024.0) * 1000.0; // Output voltage V0 converted
if (humidity < 50) { // We take into account the humidity level to compute beta factor
beta = 1;
} else {
beta = 1 - 0.01467 * (humidity - 50);
}
if (V0 > Vs) {
DustDensity = alpha * beta * ((V0 - Vs)) * 5.0 * 1000.0 / 1024.0;
} else {
DustDensity = 0;
}
Serial.print(" | Dust density [μg/m3]:");
Serial.println(DustDensity);
delay(2000); // Delay before next reading
}
Results:
Today the haze was about 50μg/m3 according to the NEA. The measures taken with the prototype must be averaged over an hour to be comparable with the NEA figures.
However I do not expect a perfect match – this matter being very sensitive in Singapore (and how much the governement does to fights against the haze), that’s exactly why I wanted to build this prototype!!
I tried to catch some air outside with a plastic bag and exposed it to the sensor.
Results are not bad!
So, on average 20μg/m3, but it would be worth repeating the exercise outside when the haze is higher, over an hour and taking the average.
What about the Weatherduino Pro2?
Now I need to incorporate this measures into my existing setup. I was thinking using the Leaf/Soil Interface inputs or the extra sensors?
I have not yet figured out yet how but I'm open to any suggestion!
I hope this was interesting

I tried to show how we can improve the Weatherduino capabilities with some cool sensor.
Regards,
Zitoune
RE: A measure of PM2.5 with the Weatherduino -
werk_ag - 27-08-2016
Hi Zitoune,
Thanks for sharing your work on this matter. I'm very interested on it. Measuring the quality of the air is something that I would like to integrate on the WeatherDuino Pro2 system.
I'm quite busy on the next two days, but after we will talk about this, here or by PM.
Congratulations for your work.
Cheers
RE: A measure of PM2.5 with the Weatherduino -
werk_ag - 30-08-2016
Hi Zitoune,
Just to start settling things in my mind, I have some questions:
- Are you driving the fan directly from an Arduino pin?
"PM2.5, particulate matter with a diameter of 2.5 microns or less, has emerged as a pressing environmental concern, notably in China. Sharp Corp. has developed a PM2.5 sensor device, DN7C3CA006, which it claims is not only the smallest such device of its type but also the fastest, with a detection speed of 10 seconds"
- What is that "detection speed of 10 seconds" really means?
It's all, for now...
RE: A measure of PM2.5 with the Weatherduino -
zitoune - 30-08-2016
(30-08-2016, 00:34)Werk_AG Wrote: - Are you driving the fan directly from an Arduino pin?
Ont he breadboard in the picture yes - but you can see a resistor at the base of a transistor 2N2222 to actually drive the fan. I have connected the fan directly to the arduino but I believe using the transistor is better.
(30-08-2016, 00:34)Werk_AG Wrote: "PM2.5, particulate matter with a diameter of 2.5 microns or less, has emerged as a pressing environmental concern, notably in China. Sharp Corp. has developed a PM2.5 sensor device, DN7C3CA006, which it claims is not only the smallest such device of its type but also the fastest, with a detection speed of 10 seconds"
- What is that "detection speed of 10 seconds" really means?
In the data sheet, it is mentioned to only power the fan intermittently in order to increase its life span.
A such, they do recommend to power it ON for at least 10 seconds every time - I believe below this time the measure might not be significant?
In my example it's powered for more than 30 sec to get the Vs reference.
--------
Another thing to note when measuring small particles: it does not really make sense to have "instantaneous" measures, but rather to take an average (like what you have implemented for the wind speed) over an hour.
Typical measures are given by national agencies over 1-hour or 3-hours. The most common for 2.5PPM is 1-hour. It would be easy to add in the program.
Regards.
RE: A measure of PM2.5 with the Weatherduino -
werk_ag - 03-09-2016
Quote:Ont he breadboard in the picture yes - but you can see a resistor at the base of a transistor 2N2222 to actually drive the fan. I have connected the fan directly to the arduino but I believe using the transistor is better
Wise decision. According to the sensor datasheet the fan consumption is 140mA and the maximum current you can drain from an Arduino nano pin is 20mA.
I'm thinking in ordering one DN7C3CA006 for myself, I found some sellers on eBay. Do you bought yours on eBay?
I still haven't fully figured in my mind how to integrate it. The better and more efficient way will be create a dedicated RF unit, sending a new sensor ID info. Integrate the sensor on the existing TX units, may not be as easy as it seems at first sight.
With time, something will come out...
RE: A measure of PM2.5 with the Weatherduino -
zitoune - 03-09-2016
(03-09-2016, 02:44)Werk_AG Wrote: Wise decision. According to the sensor datasheet the fan consumption is 140mA and the maximum current you can drain from an Arduino nano pin is 20mA.
Yes indeed
Quote:I'm thinking in ordering one DN7C3CA006 for myself, I found some sellers on eBay. Do you bought yours on eBay?
I found mine at
digikey - it seems cheaper (30 USD) than those I found on eBay (and it's very fast shipping). However you will need to order for a certain minimum to get free shipping. In Singapore it's about 130 USD so a fair amount to spend, but ebay would do for sure.
Quote:I still haven't fully figured in my mind how to integrate it. The better and more efficient way will be create a dedicated RF unit, sending a new sensor ID info. Integrate the sensor on the existing TX units, may not be as easy as it seems at first sight.
With time, something will come out...
I tries also to figure out a few possibilities:
I looked a bit at the code and was wondering if there was still some byte available in the radio transmitted signal from the TX to the RX? Or if it was fully used by other sensors? As first sight seems like we cannot do that.
Would it be a possibility to use the Leaf/Soil Interface? I thought we could build the same amplifier unit as for the solar/UV to amplify the signal from a theoretical maximum of around 0.8V (according to the term sheet) to 5V (or 1.1V)?
Last idea, suggested by uncle_bob: use one LCD to display the value and have it running autonomously from the weatherduino.
In my case I can see the RX enclosure without going outside, so would not be a problem, but for most it would mean a different enclosure. Also it would mean no integration to weatherduino - what a pity
Regards.
RE: A measure of PM2.5 with the Weatherduino -
werk_ag - 15-10-2016
Just an update to all that have interest on this matter:
We (I and some of the testers/developers) are actively working on this project.
Quote:Last idea, suggested by uncle_bob: use one LCD to display the value and have it running autonomously from the weatherduino.
In my case I can see the RX enclosure without going outside, so would not be a problem, but for most it would mean a different enclosure. Also it would mean no integration to weatherduino - what a pity 
Most likely it will be an autonomous unit, with the possibility to send the data wirelessly to a WeatherDuino receiver. Currently everything is at an early development state, and everything could change.
RE: A measure of PM2.5 with the Weatherduino -
qldbureau - 16-10-2016
Very interesting development for WeatherDuino and something I would like to implement in the system if all works out.
Not being a programmer (unfortunately) could I offer a suggestion to consider: Prototypes are running stand alone now from WeatherDuino with their own Arduino. Is it feasible to turn it into a 'mini' Tx with a Nano which does all the number crunching work and sends the final values to the existing Rx to store, upload to websites etc. Or is the Rx critically low in memory now to receive anymore information. Is there a limit on Tx I.D numbers?
Powering it should not be too difficult, whether joined to existing outdoor unit supplies or small solar panel & battery.
RE: A measure of PM2.5 with the Weatherduino -
werk_ag - 16-10-2016
(16-10-2016, 11:03)qldbureau Wrote: ... Prototypes are running stand alone now from WeatherDuino with their own Arduino. Is it feasible to turn it into a 'mini' Tx with a Nano which does all the number crunching work and sends the final values to the existing Rx to store, upload to websites etc.~
It's really early to say something definitive about this, but the goal is trying to make the Air Quality Monitor, not only an autonomous unit, but also act as a "mini" TX unit, capable to send data to the main WeatherDuino receiver.
(16-10-2016, 11:03)qldbureau Wrote: Or is the Rx critically low in memory now to receive anymore information.
This is the million dollars question. Really don't know yet!
(16-10-2016, 11:03)qldbureau Wrote: Is there a limit on Tx I.D numbers?
Currently the WeatherDuino Pro2 system supports up to four TX units (three if used together with any Auriol wireless sensor), however the way the Air Quality Monitor unit will work, doesn't affect the total amount of TX units allowed, because for the system this unit will be as an extension of one of the existing units.
RE: A measure of PM2.5 with the Weatherduino -
Barrow4491 - 21-01-2017
Hi guys,
Any further developments on this, with the release of the new Pro plus RX?
Jim