Air Quality (Purple Air)

Could an App be created to see Air quality via Purple Air

1 Like

I want to add the ability to select a specific purple air sensor.

Perhaps using the API for ACICN ??? http://aqicn.org/api/

I created a PurpleAir app for the Tidbyt! Itā€™s available from the Tidbyt app. Search for ā€˜purpleā€™. It will list air sensors close by and you can also specify a sensor ID. You can get the sensor ID from the PurpleAir map if you donā€™t know it already.

5 Likes

Looks great!! Thanks for the app

How do you get the sensor ID from the purple air map? I donā€™t see it. The one it gave me by default is on the other side of the world.

Go to https://map.purpleair.com and find your location on the map. Choose a nearby sensor by clicking on it and then use your mouse to hover over the ā€˜Get this Widgetā€™ text. The tooltip will show the sensor id in the id.

Iā€™m surprised youā€™re getting a sensor on the other side of the world. I havenā€™t seen that yet. I wonder if the Purple Air API Iā€™m using to find nearby sensors isnā€™t returning the correct data, or if I have a bug in the app?

Thank you for your quick reply, posburn. I did that and I put in the number for the closest sensor, but it has the temperature at 120 degrees F! We are hot here today, but not that hot! Also the number it shows for air quality isnā€™t what it shows on the map. When I loaded the app, it setup Alcatraz Dock as the closest sensor. Iā€™m not sure where this is, but I live in Ukiah, California and have multiple sensors near me (within 5 miles) so this certainly isnā€™t the closest one. When I put Alcatraz Dock into Google Maps it gave me somewhere in Italy.

I noticed too that I couldnā€™t change the sensor only the sensor ID. I can click on the sensor, but it brings up my address and something called ā€œAlcatraz Dockā€ which doesnā€™t exist as far as I can tell on the PurpleAir map and a little locator icon where it says powered by Google above it.

Alcatraz Dock (in S.F. Bay) is what I use as the default list of sensors before I try getting a list of sensors near your location. So my guess is that getting sensors for your location is failing, so the only one in the list is the default Alcatraz Dock. If you want to send the sensor ID to me that you are using, I can check it out. A couple of things ā€¦ the number I calculate in the app may differ a little bit from what is on the map. Itā€™s also possible they have updated their formula and method of calculating that value so that it differs a little bit from the Tidbyt app. Also, when a sensor is in direct sunlight it really heats up which would explain the high temperature reading.

That makes a lot of sense. Here are some sensors that are close to me:

78583
85097
56849
91911
17835

The top few are closer to me. The bottom ones are slightly farther away. When I plug these numbers in, they all give me readings but they all are off. Most come in with air quality readings 30 points low and the last one is about 30 points high.

Thank you for the help posburn!

After taking a look at the map and looking at the sensor IDs you listed, it looks like you may be looking at numbers with no conversion method applied. The Tidbyt PurpleAir app uses the US EPA conversion. Itā€™s possible I need to update it since the numbers are still a bit off, but they are much closer when using that conversion.

In the upper, left-hand corner of the map there is a white rectangle. Click that and then choose ā€˜US EPAā€™ in the ā€˜Apply Conversionā€™ dropdown and youā€™ll notice that the numbers are closer.

I need to check the latest EPA formulas being used.

I see what you mean. I didnā€™t realize about the conversion method. They are closer now, but like you said, still a bit off.

Thank you.

@posburn is it possible to add the ability to select which channel it uses (A vs B)? My sensor has a borked channel B and the reading is like 2k. On PurpleAir map, it shows the value from A it seems like (normal reading), but in Tidbyt it is displaying the 2k value.

Hi @skurvy_pirate - the Tidbyt app averages the A and B sensors as PurpleAir recommends. I bet they check both values first to make sure they are valid before using them. I should add that to the Tidbyt app. I could check both and if one is not valid, I donā€™t use that one and use the other. Iā€™ll see about adding that. Thanks for letting me know.

Also, itā€™s possible one of your sensors needs to be cleaned - have you read this before?

@skurvy_pirate @whoster - Iā€™m working on an update to the PurpleAir app that fixes a few bugs Iā€™ve found when calculating the AQI and adds a config option to select the sensor to use in the calculation. Thanks for that suggestion @skurvy_pirate!

@whoster Iā€™ve also discovered that my code does not handle the case where a PurpleAir device only has one sensor. It always assumes an A and a B sensor are present, which can greatly affect the AQI I calculate in this case. Iā€™m addressing that as well.

Finally, Iā€™m looking into using the confidence score that the API returns for the device. On the PurpleAir map you can see sensors that have a low confidence value easily as they are shown with transparency. The lower the confidence, the less opaque the circle is. I thought that might help @skurvy_pirate as you could check your sensor on the map and see if it is more transparent or not.

If anyone has any feature requests or suggestions now is a good time to let me know. :slight_smile:

1 Like

Thatā€™s great information, posburn! Thank you so much for the update! Let us know when you have it in place and Iā€™ll be glad to test it for you and tell you how accurate it is for the sensors Iā€™m using.

Thanks @posburn! Yeah it appears PurpleAir map is discarding the bad value. I guess you could do something similar but might be interesting/tricky to determine when you are getting bad data from one of the sensors as you might not know if the lower or higher value is the bad value. PurpleAir might be looking at nearby sensors to help make this decision to decide which sensor is bad? My sensor has a confidence of 0 lol (rightfully so, one channel is completely off the charts). I tried blowing it out with pressurized air already but plan to open it up to try and blow it out a little better when I get a chance. Otherwise will be looking to buy a new sensor to replace.

Makes sense. I read on the PurpleAir forums somewhere they have a sensor replacement you can buy. I think it was $49 and replaces both A and B sensors and you can do it yourself. Much cheaper than buying a new PurpleAir device.

The updates for the PurpleAir app are live now. The app now handles devices with low confidence PM sensors and devices with only 1 sensor. You can also choose which PM sensor to use in the configuration options. The default is the average of the A & B sensors if both are working correctly.

A different EPA AQI formula is used and I discovered I was not using the PM values with a correction factor applied. Now the app uses the corrected values.

So, with all of that, I hope youā€™ll find that the AQI value the Tidbyt app shows is closer to what you might find on the PurpleAir map.

Let me know if you have any other suggestions or feedback. Thanks for your help!

1 Like

Itā€™s possible the update to the PurpleAir app isnā€™t live yet. Let me know when you see the new Particle Sensor option.