![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dust Sesnsor PMS5003
Dependencies: DustSenzor NetServices ThingSpeakEthernet mbed
Fork of PMS5003 by
Diff: main.cpp
- Revision:
- 14:48368d18a793
- Parent:
- 13:5c98f1d10e70
--- a/main.cpp Tue Jun 13 19:15:58 2017 +0000 +++ b/main.cpp Wed Jun 28 18:36:09 2017 +0000 @@ -3,16 +3,14 @@ #include "TextLCD.h" #include "DustSenzor.h" - - - ThingSpeak ts("FI2NZGSOB8LSR8YX"); -DustSenzor ds(p5, p9, p10); +DustSenzor ds(p5, p9, p10); // set pin, uartTx pin, Rx pin +float value[6]; +float finValue[3]; +TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD16x2); int main() { - ds.stop(); float *ptr; - float values [6]; ts.connect(); wait(1); while(1){ @@ -22,15 +20,22 @@ } while( res == 1){ ptr = ds.read(); - for( int i = 0; i < 6; i++) { - values[i] = *(ptr + i) ; - ts.setField ( values[i]*10000, i+1 ); - } + + for( int i = 0; i < 6; i++) + value[i] = *(ptr + i); + + finValue[0] = ( value[0] - value[2] ); // 0.3 - 1 um / m3 + finValue[1] = ( value[2] - value[4] ); // 1 - 5 um / m3 + finValue[2] = ( value[4] - value[5] ); // 5 - 10 um / m3 + + for ( int j = 0; j < 3; j++ ) + ts.setField( finValue[j], j+1); + ts.putUp(); wait(15); res = ts.pull(282724, 1); } - ds.stop(); + ds.stop(); } }