Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute US AQI and EPA AQI for PMS5003x sensors #22294

Closed
wants to merge 3 commits into from

Conversation

thomashargrove
Copy link
Contributor

@thomashargrove thomashargrove commented Oct 14, 2024

Description:

AQI is a common way to display PM2.5 data and the thresholds are easier to remember than raw pm2.5 data. This PR adds a calculation for standard US AQI and a second one that uses the US EPA adjustments which gives a more accurate AQI for places that experience wildfire smoke.

image

12:58:21.042 MQT: tele/Home_Garage_AQI/SENSOR = {"Time":"2024-10-14T12:58:21","PMS5003T":{"CF1":2,"CF2.5":2,"CF10":2,"PM1":2,"PM2.5":2,"PM10":2,"AQI":11,"PB0.3":378,"PB0.5":115,"PB1":17,"PB2.5":0,"Temperature":74.5,"Humidity":47.9,"DewPoint":53.4,"EPA_AQI":11},"TempUnit":"F"}

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.8
  • The code change is tested and works with Tasmota core ESP32 V.3.1.0.240926
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

Copy link
Collaborator

@s-hadinger s-hadinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, please apply the suggested changes to make code smaller

tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino Outdated Show resolved Hide resolved
tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino Outdated Show resolved Hide resolved
@thomashargrove
Copy link
Contributor Author

Thanks, made the requested changes

@arendst
Copy link
Owner

arendst commented Oct 14, 2024

Nice to know in Europe that their AQI is US approved.

BTW an increase of 400 bytes is not a problem considering the PMS5003 driver is optional on ESP8266.

@arendst
Copy link
Owner

arendst commented Oct 14, 2024

Any chance you're able to add the European (or Celsius based results) too?

If not I suggest to make the provision for US specific data related to the user selection of Fahrenheit and remove US specific data if user has selected Celsius.

@thomashargrove
Copy link
Contributor Author

Yeah happy to add Europe AQI

@thomashargrove
Copy link
Contributor Author

In Fahrenheit

16:29:15.928 MQT: tele/Home_Garage_AQI/SENSOR = {"Time":"2024-10-14T16:29:15","PMS5003T":{"CF1":1,"CF2.5":3,"CF10":3,"PM1":1,"PM2.5":3,"PM10":3,"US_AQI":16,"PB0.3":336,"PB0.5":99,"PB1":16,"PB2.5":5,"Temperature":68.0,"Humidity":58.9,"DewPoint":53.1,"US_EPA_AQI":11},"TempUnit":"F"}

image

and Celcius

16:30:15.915 MQT: tele/Home_Garage_AQI/SENSOR = {"Time":"2024-10-14T16:30:15","PMS5003T":{"CF1":1,"CF2.5":3,"CF10":3,"PM1":1,"PM2.5":3,"PM10":3,"EAQI":"Good","PB0.3":336,"PB0.5":99,"PB1":16,"PB2.5":5,"Temperature":20.0,"Humidity":58.9,"DewPoint":11.7},"TempUnit":"C"}

image

us_aqi = compute_us_aqi(pms_data.pm25_standard);
} else {
european_aqi = compute_european_aqi(pms_data.pm25_standard);
}

if (json) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section of code was inconsistent with trailing commas. I changed it so each new json string we append starts with a comma and does not have a trailing comma

@thomashargrove
Copy link
Contributor Author

I went with string labels for European Air Quality Index. I could not find a numeric scale like the 0-500 one in the US. Let me know if that seems correct.

@arendst
Copy link
Owner

arendst commented Oct 15, 2024

Thx.

I will have a look regarding the string labels. As it stands we need translations for all english terms shown in the GUI. I'll see how to get rid of some (Like European and US).

@arendst arendst added the on hold by dev team Result - Feature request put on hold by member of development team label Oct 15, 2024
@arendst arendst self-assigned this Oct 25, 2024
@arendst
Copy link
Owner

arendst commented Oct 25, 2024

Did some research regarding non-US AQI and as expected it's a can of worms ;-)

In short almost every country uses a different calculation of PM2.5 to get to some kind of AQI. See https://en.wikipedia.org/wiki/Air_quality_index. Considering this I strongly feel this calculation needs to be done on the front-end based on Tasmota provided data.

Therefore I'll remove the current European calculation and keep the US one based on Fahrenheit.

@arendst
Copy link
Owner

arendst commented Oct 25, 2024

Kind of merged this without the celsius part just now. Thx.

@arendst arendst closed this Oct 25, 2024
josef109 pushed a commit to josef109/Tasmota that referenced this pull request Nov 7, 2024
josef109 pushed a commit to josef109/Tasmota that referenced this pull request Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold by dev team Result - Feature request put on hold by member of development team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants