Dust Sesnsor PMS5003

Dependencies:   DustSenzor NetServices ThingSpeakEthernet mbed

Fork of PMS5003 by marko puric

main.cpp

Committer:
mpuric
Date:
2017-06-13
Revision:
13:5c98f1d10e70
Parent:
12:df83e01db08e
Child:
14:48368d18a793

File content as of revision 13:5c98f1d10e70:

#include "mbed.h"
#include "ThingSpeak.h"
#include "TextLCD.h"
#include "DustSenzor.h"




ThingSpeak ts("FI2NZGSOB8LSR8YX"); 
DustSenzor ds(p5, p9, p10);

int main() {
    ds.stop();
    float *ptr;
    float values [6];
    ts.connect();
    wait(1);
    while(1){     
        float res = ts.pull(282724, 1);
        if(res == 1){
            ds.start();
            }
        while( res == 1){
                ptr = ds.read();
                for( int i = 0; i < 6; i++) {
                    values[i] = *(ptr + i) ;
                    ts.setField ( values[i]*10000, i+1 );
                }
                ts.putUp();
                wait(15);
                res = ts.pull(282724, 1);
            }
            ds.stop();           
    }
}