mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-28 16:07:16 +02:00
Getter to get other PMS sensor data
This commit is contained in:
@ -399,20 +399,26 @@ bool PMSBase::validate(const uint8_t *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PMSBase::parse(const uint8_t *buf) {
|
void PMSBase::parse(const uint8_t *buf) {
|
||||||
|
// Standard particle
|
||||||
pms_raw0_1 = toU16(&buf[4]);
|
pms_raw0_1 = toU16(&buf[4]);
|
||||||
pms_raw2_5 = toU16(&buf[6]);
|
pms_raw2_5 = toU16(&buf[6]);
|
||||||
pms_raw10 = toU16(&buf[8]);
|
pms_raw10 = toU16(&buf[8]);
|
||||||
|
// atmospheric
|
||||||
pms_pm0_1 = toU16(&buf[10]);
|
pms_pm0_1 = toU16(&buf[10]);
|
||||||
pms_pm2_5 = toU16(&buf[12]);
|
pms_pm2_5 = toU16(&buf[12]);
|
||||||
pms_pm10 = toU16(&buf[14]);
|
pms_pm10 = toU16(&buf[14]);
|
||||||
|
|
||||||
|
// particle count
|
||||||
pms_count0_3 = toU16(&buf[16]);
|
pms_count0_3 = toU16(&buf[16]);
|
||||||
pms_count0_5 = toU16(&buf[18]);
|
pms_count0_5 = toU16(&buf[18]);
|
||||||
pms_count1_0 = toU16(&buf[20]);
|
pms_count1_0 = toU16(&buf[20]);
|
||||||
pms_count2_5 = toU16(&buf[22]);
|
pms_count2_5 = toU16(&buf[22]);
|
||||||
pms_count5_0 = toU16(&buf[24]);
|
pms_count5_0 = toU16(&buf[24]); // PMS5003 only
|
||||||
pms_count10 = toU16(&buf[26]);
|
pms_count10 = toU16(&buf[26]); // PMS5003 only
|
||||||
pms_temp = toU16(&buf[24]);
|
|
||||||
pms_hum = toU16(&buf[26]);
|
// Others
|
||||||
|
pms_temp = toU16(&buf[24]); // PMS5003T only
|
||||||
|
pms_hum = toU16(&buf[26]); // PMS5003T only
|
||||||
pms_firmwareVersion = buf[28];
|
pms_firmwareVersion = buf[28];
|
||||||
pms_errorCode = buf[29];
|
pms_errorCode = buf[29];
|
||||||
}
|
}
|
||||||
|
@ -81,26 +81,47 @@ bool PMS5003::begin(void) {
|
|||||||
/**
|
/**
|
||||||
* @brief Read PM1.0 must call this function after @ref readData success
|
* @brief Read PM1.0 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM1.0 index
|
* @return int PM1.0 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003::getPm01Ae(void) { return pms.getPM0_1(); }
|
int PMS5003::getPm01Ae(void) { return pms.getPM0_1(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM2.5 must call this function after @ref readData success
|
* @brief Read PM2.5 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM2.5 index
|
* @return int PM2.5 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003::getPm25Ae(void) { return pms.getPM2_5(); }
|
int PMS5003::getPm25Ae(void) { return pms.getPM2_5(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM10.0 must call this function after @ref readData success
|
* @brief Read PM10.0 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM10.0 index
|
* @return int PM10.0 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003::getPm10Ae(void) { return pms.getPM10(); }
|
int PMS5003::getPm10Ae(void) { return pms.getPM10(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM0.3 must call this function after @ref readData success
|
* @brief Read PM1.0 must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int PM1.0 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm01Sp(void) { return pms.getRaw0_1(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read PM2.5 must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int PM2.5 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm25Sp(void) { return pms.getRaw2_5(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read PM10 must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int PM10 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm10Sp(void) { return pms.getRaw10(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 0.3 count must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM0.3 index
|
* @return int PM0.3 index
|
||||||
*/
|
*/
|
||||||
@ -108,6 +129,27 @@ int PMS5003::getPm03ParticleCount(void) {
|
|||||||
return pms.getCount0_3();
|
return pms.getCount0_3();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 1.0 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 1.0 count index
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm01ParticleCount(void) { return pms.getCount1_0(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 2.5 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 2.5 count index
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm25ParticleCount(void) { return pms.getCount2_5(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 10 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 10 count index
|
||||||
|
*/
|
||||||
|
int PMS5003::getPm10ParticleCount(void) { return pms.getCount10(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert PM2.5 to US AQI
|
* @brief Convert PM2.5 to US AQI
|
||||||
*
|
*
|
||||||
|
@ -25,10 +25,20 @@ public:
|
|||||||
void resetFailCount(void);
|
void resetFailCount(void);
|
||||||
int getFailCount(void);
|
int getFailCount(void);
|
||||||
int getFailCountMax(void);
|
int getFailCountMax(void);
|
||||||
|
// Atmospheric environment
|
||||||
int getPm01Ae(void);
|
int getPm01Ae(void);
|
||||||
int getPm25Ae(void);
|
int getPm25Ae(void);
|
||||||
int getPm10Ae(void);
|
int getPm10Ae(void);
|
||||||
|
// Standard particle
|
||||||
|
int getPm01Sp(void);
|
||||||
|
int getPm25Sp(void);
|
||||||
|
int getPm10Sp(void);
|
||||||
|
// Particle count
|
||||||
int getPm03ParticleCount(void);
|
int getPm03ParticleCount(void);
|
||||||
|
int getPm01ParticleCount(void);
|
||||||
|
int getPm25ParticleCount(void);
|
||||||
|
int getPm10ParticleCount(void);
|
||||||
|
|
||||||
int convertPm25ToUsAqi(int pm25);
|
int convertPm25ToUsAqi(int pm25);
|
||||||
float compensate(float pm25, float humidity);
|
float compensate(float pm25, float humidity);
|
||||||
int getFirmwareVersion(void);
|
int getFirmwareVersion(void);
|
||||||
|
@ -110,33 +110,68 @@ bool PMS5003T::begin(void) {
|
|||||||
/**
|
/**
|
||||||
* @brief Read PM1.0 must call this function after @ref readData success
|
* @brief Read PM1.0 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM1.0 index
|
* @return int PM1.0 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003T::getPm01Ae(void) { return pms.getPM0_1(); }
|
int PMS5003T::getPm01Ae(void) { return pms.getPM0_1(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM2.5 must call this function after @ref readData success
|
* @brief Read PM2.5 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM2.5 index
|
* @return int PM2.5 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003T::getPm25Ae(void) { return pms.getPM2_5(); }
|
int PMS5003T::getPm25Ae(void) { return pms.getPM2_5(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM10.0 must call this function after @ref readData success
|
* @brief Read PM10.0 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM10.0 index
|
* @return int PM10.0 index (atmospheric environment)
|
||||||
*/
|
*/
|
||||||
int PMS5003T::getPm10Ae(void) { return pms.getPM10(); }
|
int PMS5003T::getPm10Ae(void) { return pms.getPM10(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PM 0.3 Count must call this function after @ref readData success
|
* @brief Read PM1.0 must call this function after @ref readData success
|
||||||
*
|
*
|
||||||
* @return int PM 0.3 Count index
|
* @return int PM1.0 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003T::getPm01Sp(void) { return pms.getRaw0_1(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read PM2.5 must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int PM2.5 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003T::getPm25Sp(void) { return pms.getRaw2_5(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read PM10 must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int PM10 index (standard particle)
|
||||||
|
*/
|
||||||
|
int PMS5003T::getPm10Sp(void) { return pms.getRaw10(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 0.3 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 0.3 count index
|
||||||
*/
|
*/
|
||||||
int PMS5003T::getPm03ParticleCount(void) {
|
int PMS5003T::getPm03ParticleCount(void) {
|
||||||
return pms.getCount0_3();
|
return pms.getCount0_3();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 1.0 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 1.0 count index
|
||||||
|
*/
|
||||||
|
int PMS5003T::getPm01ParticleCount(void) { return pms.getCount1_0(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read particle 2.5 count must call this function after @ref readData success
|
||||||
|
*
|
||||||
|
* @return int particle 2.5 count index
|
||||||
|
*/
|
||||||
|
int PMS5003T::getPm25ParticleCount(void) { return pms.getCount2_5(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert PM2.5 to US AQI
|
* @brief Convert PM2.5 to US AQI
|
||||||
*
|
*
|
||||||
|
@ -28,10 +28,19 @@ public:
|
|||||||
void resetFailCount(void);
|
void resetFailCount(void);
|
||||||
int getFailCount(void);
|
int getFailCount(void);
|
||||||
int getFailCountMax(void);
|
int getFailCountMax(void);
|
||||||
|
// Atmospheric environment
|
||||||
int getPm01Ae(void);
|
int getPm01Ae(void);
|
||||||
int getPm25Ae(void);
|
int getPm25Ae(void);
|
||||||
int getPm10Ae(void);
|
int getPm10Ae(void);
|
||||||
|
// Standard particle
|
||||||
|
int getPm01Sp(void);
|
||||||
|
int getPm25Sp(void);
|
||||||
|
int getPm10Sp(void);
|
||||||
|
// Particle count
|
||||||
int getPm03ParticleCount(void);
|
int getPm03ParticleCount(void);
|
||||||
|
int getPm01ParticleCount(void);
|
||||||
|
int getPm25ParticleCount(void);
|
||||||
|
|
||||||
int convertPm25ToUsAqi(int pm25);
|
int convertPm25ToUsAqi(int pm25);
|
||||||
float getTemperature(void);
|
float getTemperature(void);
|
||||||
float getRelativeHumidity(void);
|
float getRelativeHumidity(void);
|
||||||
|
Reference in New Issue
Block a user