Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_SGP30_mbed mbed CCS811 mbed-rtos ALPHASENSE Adafruit_ADS1015_ BME680
PMS7003.cpp
00001 #include "PMS7003.h" 00002 00003 PMS7003::PMS7003(Serial* serial) 00004 { 00005 this->serial = serial; 00006 serial->baud(9600); 00007 pm10_count = 0; 00008 pm2_5_count = 0; 00009 } 00010 00011 float PMS7003::getPM10() 00012 { 00013 return pm10_count; 00014 } 00015 00016 float PMS7003::getPM2_5() 00017 { 00018 return pm2_5_count; 00019 } 00020 00021 float PMS7003::getPM1() 00022 { 00023 return pm1_count; 00024 } 00025 00026 void PMS7003::read() 00027 { 00028 serial->read(buffer, PACKET_SIZE, NULL); 00029 if(buffer[1]==0x42){ 00030 if(buffer[2]==0x4d){ 00031 pm10_count = ((buffer[9] << 8) + buffer[10]); 00032 pm2_5_count = ((buffer[7] << 8) + buffer[8]); 00033 pm1_count = ((buffer[5] << 8) + buffer[6]); 00034 } 00035 } 00036 }
Generated on Wed Jul 13 2022 01:47:14 by
1.7.2