Dust Sesnsor PMS5003
Dependencies: DustSenzor NetServices ThingSpeakEthernet mbed
Fork of PMS5003 by
main.cpp@12:df83e01db08e, 2017-06-08 (annotated)
- Committer:
- mpuric
- Date:
- Thu Jun 08 18:28:54 2017 +0000
- Revision:
- 12:df83e01db08e
- Parent:
- 9:07f9279c30f7
- Child:
- 13:5c98f1d10e70
Init commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
segundo | 0:2419d81ee03d | 1 | #include "mbed.h" |
tsoic | 6:ebbde59c5a1d | 2 | #include "ThingSpeak.h" |
mpuric | 9:07f9279c30f7 | 3 | #include "TextLCD.h" |
mpuric | 9:07f9279c30f7 | 4 | #include "DustSenzor.h" |
mpuric | 9:07f9279c30f7 | 5 | |
segundo | 0:2419d81ee03d | 6 | |
segundo | 2:16857d9ab50d | 7 | |
segundo | 2:16857d9ab50d | 8 | |
mpuric | 9:07f9279c30f7 | 9 | ThingSpeak ts("FI2NZGSOB8LSR8YX"); |
mpuric | 9:07f9279c30f7 | 10 | DustSenzor ds(p5, p9, p10); |
segundo | 0:2419d81ee03d | 11 | |
segundo | 0:2419d81ee03d | 12 | int main() { |
mpuric | 9:07f9279c30f7 | 13 | ds.stop(); |
mpuric | 9:07f9279c30f7 | 14 | float *ptr; |
segundo | 2:16857d9ab50d | 15 | |
mpuric | 9:07f9279c30f7 | 16 | ts.connect(); |
mpuric | 9:07f9279c30f7 | 17 | wait(1); |
mpuric | 9:07f9279c30f7 | 18 | while(1){ |
mpuric | 9:07f9279c30f7 | 19 | float res = ts.pull(282724, 1); |
mpuric | 9:07f9279c30f7 | 20 | if(res == 1){ |
mpuric | 9:07f9279c30f7 | 21 | ds.start(); |
mpuric | 9:07f9279c30f7 | 22 | } |
mpuric | 9:07f9279c30f7 | 23 | while( res == 1){ |
mpuric | 9:07f9279c30f7 | 24 | ptr = ds.read(); |
mpuric | 9:07f9279c30f7 | 25 | for( int i = 0; i < 6; i++) { |
mpuric | 9:07f9279c30f7 | 26 | ts.setField(*(ptr + i), i+1); |
mpuric | 9:07f9279c30f7 | 27 | } |
mpuric | 9:07f9279c30f7 | 28 | ts.putUp(); |
mpuric | 9:07f9279c30f7 | 29 | wait(15); |
mpuric | 9:07f9279c30f7 | 30 | res = ts.pull(282724, 1); |
mpuric | 9:07f9279c30f7 | 31 | } |
mpuric | 9:07f9279c30f7 | 32 | ds.stop(); |
mpuric | 9:07f9279c30f7 | 33 | } |
mpuric | 9:07f9279c30f7 | 34 | } |
tsoic | 6:ebbde59c5a1d | 35 |