Dust Sesnsor PMS5003
Dependencies: NetServices ThingSpeakEthernet mbed
main.cpp@11:8e2829f54314, 2017-06-05 (annotated)
- Committer:
- mpuric
- Date:
- Mon Jun 05 08:20:36 2017 +0000
- Revision:
- 11:8e2829f54314
- Parent:
- 9:07f9279c30f7
ThingSpeak converted to library;
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 | |
mpuric | 9:07f9279c30f7 | 36 | |
mpuric | 9:07f9279c30f7 | 37 | |
mpuric | 9:07f9279c30f7 | 38 | /* void DustSenzor::modeSet(){ |
mpuric | 9:07f9279c30f7 | 39 | if(debounce.read_ms() > 250 && provjera==false) { |
mpuric | 9:07f9279c30f7 | 40 | set=1; |
mpuric | 9:07f9279c30f7 | 41 | debounce.reset(); |
mpuric | 9:07f9279c30f7 | 42 | provjera=true; |
mpuric | 9:07f9279c30f7 | 43 | } |
mpuric | 9:07f9279c30f7 | 44 | else if(debounce.read_ms() > 250 && provjera==true){ |
mpuric | 9:07f9279c30f7 | 45 | set=0; |
mpuric | 9:07f9279c30f7 | 46 | debounce.reset(); |
mpuric | 9:07f9279c30f7 | 47 | provjera=false; |
mpuric | 9:07f9279c30f7 | 48 | } |
mpuric | 9:07f9279c30f7 | 49 | } */ |