Relative to the previous post (Particulate meter - PPD42NS) now I can show the real results (effective datas) measured in my room in an period of 233 mins(3 hours and 53 mins).
To do this I had to modify the Arduino code in this way:
To do this I had to modify the Arduino code in this way:
/*
Interface to Shinyei Model PPD42NS Particle Sensor
Program by Christopher Nafis
Modified to convert 0.01 cf to liters by Remo Tomasi
Written April 2012
Re-written November 2018
http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
http://www.sca-shinyei.com/pdf/PPD42NS.pdf
JST Pin 1 (Black Wire) => Arduino GND
JST Pin 3 (Red wire) => Arduino 5VDC
JST Pin 4 (Yellow wire) => Arduino Digital Pin 8
*/
int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 60000; // 60 sec
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
void setup() {
Serial.begin(9600);
pinMode(8,INPUT);
starttime = millis();
}
void loop() {
duration = pulseIn(pin, LOW);
lowpulseoccupancy = lowpulseoccupancy+duration;
if ((millis()-starttime) >= sampletime_ms)
{
ratio = lowpulseoccupancy/(sampletime_ms*10.0);
concentration = (1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62)*3.534; // * 3.534 to liters
Serial.print("Concentration = ");
Serial.print(concentration);
Serial.println(" pcs/l");
lowpulseoccupancy = 0;
starttime = millis();
}
}
Therefore, I introduced the conversion from cf (cube feet) to l (liters) and then I increased the sampling time from 2000 ms (= 2 secs) to 60000 (= 60 secs = 1 min).
Our unite measurement is, exactly, 0.01 cf = 283 ml = 0.283 l
So,
I multiply the formula of concentration for this last number.
Once I started the acquisition by arduino I had to redirection datas from the output device (on Ubuntu) which was COM3 that correspond to the device ttyACM0. To do this I simply wrote the following command on the command line (bash on Ubuntu 18.10):
cat /dev/ttyACM0 > log.txt
cat show to the monitor datas from COM3, but using '>' we redirect this information to a file called "log.txt" updated every 60 secs (the same time datas arrive). In this way we obtain a list of values like this:
98726.26 pcs/l
35037.72 pcs/l
38756.15 pcs/l
27820.51 pcs/l
14590.92 pcs/l
17182.41 pcs/l
13278.62 pcs/l
8403.57 pcs/l
31862.78 pcs/l
...
Please Note: I had to launch this commmand before the capture:
ttylog -b 9600 -d /dev/ttyACM0
Why? Beacause the capture command seems doesn't work well and the previous command it's like a configuration of the channel. If you don't find this command you can install through this:
sudo apt-get install ttylog
I opened the log file into a spreadsheet software to manipulate the datas...and finally I've plotted the values obtaining the following graph:
Values of pcs/l plotted. |
No comments:
Post a Comment