kh
Dependencies: Adafruit_SGP30_mbed mbed CCS811 mbed-rtos ALPHASENSE Adafruit_ADS1015_ BME680
Diff: SDS011/NovaSDS011.cpp
- Revision:
- 0:43070b2dfc87
diff -r 000000000000 -r 43070b2dfc87 SDS011/NovaSDS011.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDS011/NovaSDS011.cpp Wed Mar 06 14:03:41 2019 +0000 @@ -0,0 +1,33 @@ +#include "NovaSDS011.h" + +NovaSDS011::NovaSDS011(Serial* serial) +{ + this->serial = serial; + serial->baud(9600); + pm10_count = 0; + pm2_5_count = 0; +} + +float NovaSDS011::getPM10() +{ + return pm10_count; +} + +float NovaSDS011::getPM2_5() +{ + return pm2_5_count; +} + +void NovaSDS011::read() +{ + while(serial->readable()==0){} + if(serial->readable()==1){ + serial->read(buffer, PACKET_SIZE, NULL); + printf("%d %d %d %d %d %d %d %d %d %d\r\n",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5],buffer[6],buffer[7],buffer[8],buffer[9]); + } + if(buffer[9] == 0xAB) { + printf("yo\r\n"); + pm10_count = ((buffer[6] << 8) + buffer[3]) / 10.0; + pm2_5_count = ((buffer[4] << 8) + buffer[3]) / 10.0; + } +} \ No newline at end of file