mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-28 07:57:18 +02:00
slr pm2.5 correction implementation
This commit is contained in:
@ -314,6 +314,36 @@ int PMSBase::pm25ToAQI(int pm02) {
|
||||
return 500;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief SLR correction for PM2.5
|
||||
*
|
||||
* Reference: https://www.airgradient.com/blog/low-readings-from-pms5003/
|
||||
*
|
||||
* @param pm25 PM2.5 raw value
|
||||
* @param pm003Count PM0.3 count
|
||||
* @param scalingFactor Scaling factor
|
||||
* @param intercept Intercept
|
||||
* @return float Calibrated PM2.5 value
|
||||
*/
|
||||
float PMSBase::slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept) {
|
||||
float calibrated;
|
||||
|
||||
float lowCalibrated = (scalingFactor * pm003Count) + intercept;
|
||||
if (lowCalibrated < 31) {
|
||||
calibrated = lowCalibrated;
|
||||
} else {
|
||||
calibrated = pm25;
|
||||
}
|
||||
|
||||
// No negative value for pm2.5
|
||||
if (calibrated < 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return calibrated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Correction PM2.5
|
||||
*
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
uint8_t getErrorCode(void);
|
||||
|
||||
int pm25ToAQI(int pm02);
|
||||
float slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept);
|
||||
float compensate(float pm25, float humidity);
|
||||
|
||||
private:
|
||||
|
@ -172,6 +172,10 @@ int PMS5003::getPm10ParticleCount(void) { return pms.getCount10(); }
|
||||
*/
|
||||
int PMS5003::convertPm25ToUsAqi(int pm25) { return pms.pm25ToAQI(pm25); }
|
||||
|
||||
float PMS5003::slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept) {
|
||||
return pms.slrCorrection(pm25, pm003Count, scalingFactor, intercept);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Correct PM2.5
|
||||
*
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
int getPm10ParticleCount(void);
|
||||
|
||||
int convertPm25ToUsAqi(int pm25);
|
||||
float slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept);
|
||||
float compensate(float pm25, float humidity);
|
||||
int getFirmwareVersion(void);
|
||||
uint8_t getErrorCode(void);
|
||||
|
@ -205,6 +205,10 @@ float PMS5003T::getRelativeHumidity(void) {
|
||||
return pms.getHum() / 10.0f;
|
||||
}
|
||||
|
||||
float PMS5003T::slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept) {
|
||||
return pms.slrCorrection(pm25, pm003Count, scalingFactor, intercept);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Correct PM2.5
|
||||
*
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
int convertPm25ToUsAqi(int pm25);
|
||||
float getTemperature(void);
|
||||
float getRelativeHumidity(void);
|
||||
float slrCorrection(float pm25, float pm003Count, float scalingFactor, float intercept);
|
||||
float compensate(float pm25, float humidity);
|
||||
int getFirmwareVersion(void);
|
||||
uint8_t getErrorCode(void);
|
||||
|
Reference in New Issue
Block a user