diff --git a/packages/airgradient_d1_mini_board.yaml b/packages/airgradient_d1_mini_board.yaml index 62c2323..5a7c079 100644 --- a/packages/airgradient_d1_mini_board.yaml +++ b/packages/airgradient_d1_mini_board.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.6 + config_version: 4.0.7 esphome: name: "${name}" diff --git a/packages/airgradient_esp32-c3_board.yaml b/packages/airgradient_esp32-c3_board.yaml index ba23264..90aa20a 100644 --- a/packages/airgradient_esp32-c3_board.yaml +++ b/packages/airgradient_esp32-c3_board.yaml @@ -1,5 +1,5 @@ substitutions: - config_version: 4.0.6 + config_version: 4.0.7 esphome: name: "${name}" diff --git a/packages/sensor_pms5003.yaml b/packages/sensor_pms5003.yaml index 5e6bf71..03961f2 100644 --- a/packages/sensor_pms5003.yaml +++ b/packages/sensor_pms5003.yaml @@ -18,13 +18,13 @@ sensor: if (x == 0.0) { result = 0.0; } else if (x < 30.0) { - result = (0.524 * x) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * x) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 50.0) { - result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 210.0) { - result = (0.786 * x) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * x) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 260.0) { - result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); + result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity_raw).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); } else { result = 2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2)); } diff --git a/packages/sensor_pms5003_extended_life.yaml b/packages/sensor_pms5003_extended_life.yaml index 25b71ac..e7d51b7 100644 --- a/packages/sensor_pms5003_extended_life.yaml +++ b/packages/sensor_pms5003_extended_life.yaml @@ -1,6 +1,9 @@ substitutions: pm_update_interval: "2min" +# Impliments PM2.5 correction algorithm supported by AirGradient from EPA +# https://www.airgradient.com/documentation/correction-algorithms/ +# https://document.airnow.gov/airnow-fire-and-smoke-map-questions-and-answers.pdf sensor: - platform: pmsx003 # PMS5003 https://esphome.io/components/sensor/pmsx003.html @@ -16,13 +19,13 @@ sensor: if (x == 0.0) { result = 0.0; } else if (x < 30.0) { - result = (0.524 * x) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * x) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 50.0) { - result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (x / 20 - 3/2) + 0.524 * (1 - (x / 20 - 3/2))) * x - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 210.0) { - result = (0.786 * x) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * x) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (x < 260.0) { - result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); + result = (0.69 * (x / 50 - 21/5) + 0.786 * (1 - (x / 50 - 21/5))) * x - (0.0862 * id(humidity_raw).state * (1 - (x / 50 - 21/5))) + (2.966 * (x / 50 - 21/5)) + (5.75 * (1 - (x / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(x,2) * (x / 50 - 21/5)); } else { result = 2.966 + (0.69 * x) + (8.84 * pow(10,-4) * pow(x,2)); } diff --git a/packages/sensor_pms5003t.yaml b/packages/sensor_pms5003t.yaml index 4e8cbee..34680d0 100644 --- a/packages/sensor_pms5003t.yaml +++ b/packages/sensor_pms5003t.yaml @@ -71,13 +71,13 @@ sensor: if (id(pm_2_5_raw).state == 0.0) { result = 0.0; } else if (id(pm_2_5_raw).state < 30.0) { - result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 50.0) { - result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 210.0) { - result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 260.0) { - result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); + result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity_raw).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); } else { result = 2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2)); } diff --git a/packages/sensor_pms5003t_2.yaml b/packages/sensor_pms5003t_2.yaml index 93e1c99..94610e6 100644 --- a/packages/sensor_pms5003t_2.yaml +++ b/packages/sensor_pms5003t_2.yaml @@ -72,13 +72,13 @@ sensor: if (id(pm_2_5_2_raw).state == 0.0) { result = 0.0; } else if (id(pm_2_5_2_raw).state < 30.0) { - result = (0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 50.0) { - result = (0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 210.0) { - result = (0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 260.0) { - result = (0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5)); + result = (0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity_raw).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5)); } else { result = 2.966 + (0.69 * id(pm_2_5_2_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2)); } @@ -161,7 +161,7 @@ sensor: - platform: template id: humidity_avg name: "Humidity (Average)" - lambda: return (id(humidity).state + id(humidity_2).state) / 2.0; + lambda: return (id(humidity_raw).state + id(humidity_2).state) / 2.0; unit_of_measurement: '%' accuracy_decimals: 1 device_class: humidity diff --git a/packages/sensor_pms5003t_2_extended_life.yaml b/packages/sensor_pms5003t_2_extended_life.yaml index c92d54e..0b5c678 100644 --- a/packages/sensor_pms5003t_2_extended_life.yaml +++ b/packages/sensor_pms5003t_2_extended_life.yaml @@ -75,13 +75,13 @@ sensor: if (id(pm_2_5_2_raw).state == 0.0) { result = 0.0; } else if (id(pm_2_5_2_raw).state < 30.0) { - result = (0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 50.0) { - result = (0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (id(pm_2_5_2_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_2_raw).state / 20 - 3/2))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 210.0) { - result = (0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * id(pm_2_5_2_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_2_raw).state < 260.0) { - result = (0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5)); + result = (0.69 * (id(pm_2_5_2_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) * id(pm_2_5_2_raw).state - (0.0862 * id(humidity_raw).state * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_2_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_2_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2) * (id(pm_2_5_2_raw).state / 50 - 21/5)); } else { result = 2.966 + (0.69 * id(pm_2_5_2_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_2_raw).state,2)); } @@ -149,7 +149,7 @@ sensor: - platform: template id: humidity_avg name: "Humidity (Average)" - lambda: return (id(humidity).state + id(humidity_2).state) / 2.0; + lambda: return (id(humidity_raw).state + id(humidity_2).state) / 2.0; unit_of_measurement: '%' accuracy_decimals: 1 device_class: humidity diff --git a/packages/sensor_pms5003t_extended_life.yaml b/packages/sensor_pms5003t_extended_life.yaml index 9ab53f5..1f90885 100644 --- a/packages/sensor_pms5003t_extended_life.yaml +++ b/packages/sensor_pms5003t_extended_life.yaml @@ -74,13 +74,13 @@ sensor: if (id(pm_2_5_raw).state == 0.0) { result = 0.0; } else if (id(pm_2_5_raw).state < 30.0) { - result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.524 * id(pm_2_5_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 50.0) { - result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * (id(pm_2_5_raw).state / 20 - 3/2) + 0.524 * (1 - (id(pm_2_5_raw).state / 20 - 3/2))) * id(pm_2_5_raw).state - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 210.0) { - result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity).state) + 5.75; + result = (0.786 * id(pm_2_5_raw).state) - (0.0862 * id(humidity_raw).state) + 5.75; } else if (id(pm_2_5_raw).state < 260.0) { - result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); + result = (0.69 * (id(pm_2_5_raw).state / 50 - 21/5) + 0.786 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) * id(pm_2_5_raw).state - (0.0862 * id(humidity_raw).state * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (2.966 * (id(pm_2_5_raw).state / 50 - 21/5)) + (5.75 * (1 - (id(pm_2_5_raw).state / 50 - 21/5))) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2) * (id(pm_2_5_raw).state / 50 - 21/5)); } else { result = 2.966 + (0.69 * id(pm_2_5_raw).state) + (8.84 * pow(10,-4) * pow(id(pm_2_5_raw).state,2)); }