airgradienthq / arduino

Firmware of open-source hardware air quality monitors AirGradient ONE (indoor) and AirGradient Open Air (outdoor).
https://www.airgradient.com/documentation/
Other
220 stars 114 forks source link

Implement Correction Formula for PM2.5 on Display #182

Open airgradienthq opened 5 months ago

airgradienthq commented 5 months ago

The PM2.5 value measured by the device can be improved with a formula.

Important: Data send to server should not change because we will use that formula also on our server. So below formula should ONLY affect the PM 2.5 value on the display. It should not be send to the AirGradient server. Only the raw data from PMS module send to AirGradient server.

However, the calculated PM2.5 value should be exposed in the Local Server API as "pm02Compensated". I adjusted the documentation already: https://github.com/airgradienthq/arduino/blob/master/docs/local-server.md

This way, integrations like ESPHome, Home Assistant etc can use it.

If display is switched to display US AQI. The corrected PM2.5 value should be used for the US AQI on the display.

This correction formula splits up the algorithms in bands. Also note that negative values could come out of the formula. In this case, it is recommended to set them as 0.

AGraw <30:

PM2.5 = [0.524 x AGraw] – [0.0862 x RH] + 5.75

30≤ AGraw <50:

PM2.5 = [0.786 x (AGraw/20 - 3/2) + 0.524 x (1 -(AGraw/20 - 3/2))] x AGraw – [0.0862 x RH] + 5.75

50 ≤ AGraw <210:

PM2.5 = [0.786 x AGraw] – [0.0862 x RH] + 5.75

210 ≤ AGraw <260:

PM2.5 = [0.69 x (AGraw/50 – 21/5) + 0.786 x (1 - (AGraw/50 – 21/5))] x AGraw – [0.0862 x RH x (1 - (AGraw/50 – 21/5))] + [2.966 x (AGraw/50 –21/5)] + [5.75 x (1 - (AGraw/50 – 21/5))] + [8.84 x (10-4) x AGraw2x (AGraw/50 – 21/5)]

260 ≤ AGraw:

PM2.5 = 2.966 + [0.69 x AGraw] + [8.84 x 10-4 x AGraw2]