Hi all. Just after some advice/opinions on whether the below process is valid when you don't have access to a calibrated reference dust detector.
I'm using a Jaycar dust sensor module:
It uses a sharp GP2Y1014AU sensor, looking at the datasheets for this and similar sensors, they max out around 0.5mg/m3. Having looked around for some example sketches, I found several that "Work out of the box", IEG:
https://wiki.dfrobot.com/Sharp_GP2Y1010AU
I used the above links code, and got a steady stream of results, all a bit higher than expected (~100 ug/m3)
Code in full below:
/*
Standalone Sketch to use with a Arduino UNO and a
Sharp Optical Dust Sensor GP2Y1010AU0F
*/
int measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2; //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
}
void loop(){
digitalWrite(ledPower,LOW); // power on the LED
delayMicroseconds(samplingTime);
voMeasured = analogRead(measurePin); // read the dust value
delayMicroseconds(deltaTime);
digitalWrite(ledPower,HIGH); // turn the LED off
delayMicroseconds(sleepTime);
// 0 - 5V mapped to 0 - 1023 integer values
// recover voltage
calcVoltage = voMeasured * (5.0 / 1024.0);
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
// Chris Nafis (c) 2012
dustDensity = 0.17 * calcVoltage - 0.1;
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print(" - Dust Density: ");
Serial.println(dustDensity); // unit: mg/m3
delay(1000);
}
This example and a bunch of others reference the following line, to calculate the dust density:
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
// Chris Nafis (c) 2012
dustDensity = 0.17 * calcVoltage - 0.1;
I figured for inter-unit variation I should really try and recalculate that equation for my own setup. Not being very good at algebra, I came up with a solution, as follows:
Having run my unit for a while I determined that the baseline voltage of the sensor in clean air is approximately 1.1v. (I shoved the whole thing in a sealed box and waited for it to stabilise). Even in this clean air I was getting elevated results, so I knew I needed to do something....
I then figured I could simulate an approximate max value by putting a pen into the sensor hole. This could max out the voltage. In doing so I determined a max voltage of 3.55v.
So I had my two points:
1.1v = 0
3.55v = 0.5 (approximate upper range of the sensor)
I plugged this into an online equation generator (told you I wasn't good at maths) and got the following:
y= 0.20491803278689x +-0.22745901639344
I plugged that into the code:
dustDensity = 0.20 * calcVoltage - 0.23;
And now I get 0 values when in a sealed box, small values when I open it...and values of about 0.48 mg/m3 when I shove a pencil in the hole.
The question is, is this method closer to the "truth" than just using those default values provided on the internet? I'm assuming those values were determined in a similar way, but hopefully using a calibrated reference sensor.