Weather Underground’s Next Frontier: Air Quality

yup, i got some code working (see the post you replied to)

latest effort


Coincidentally we got an Air Quality alert for the county this afternoon, driven by smoke from the multiple fires we have going. We have three air quality monitoring stations in the valley spaced about 15 mi apart. Interestingly only one has particulates (and ozone) and the other two are only ozone.

The station causing the alert has:

Particulates:
Unhealthy for Sensitive Groups
119 AQI (PM2.5-24hr)

Ozone:
Moderate
71 AQI (O3-8hr)

We have too many high ozone days and the state would like us to fix that but a conspiracy of climate and geography leaves us few options :frowning:

Brian, first and foremost, I would like to sincerely thank you for incorporating the PurpleAir sensor into Weather Display - thank you very much.

I do not know why you did all that work, since, it appears, I am the only one with a PurpleAir sensor - I would never have asked for the PurpleAir sensor to be added to Weather Display as I am quite displeased with the lack of technical support the designer/reseller of the PurpleAir sensor has shown me - the designer/reseller of the PurpleAir sensor certainly DOES NOT deserve to have his PurpleAir sensor supported by anyone!

With that said…

Brian, the test version of Weather Display (with the PurpleAir sensor code added) is working properly - four new tags are being produced every one and a half minutes. The line for the AQI is also properly displayed on the Weather Display graph.

I also noticed under ‘View → Air Quality → Purple Air Sensor’ a new AQI gauge and a new AQI graphic. Unfortunately, it appear that neither the new gauge nor the new graphic is saved as an image - is it possible for both to be save as either GIF or JPEG or PNG images?

It is my understanding that, with the latest test version of Weather Display, the little utility software ‘cronairquality.exe’ is not used anymore as the code of the software seems to now be part of Weather Display.

Now, Brian, the following is just a suggestion, it is certainly not a request…

Would it be possible to make the utility software ‘cronairquality.exe’ available with future version of Weather Display, but with a small modification: That the name of the external file where the data is saved be selectable as an option (rather than be the default ‘airquality.txt’).

It would be a nice idea if the software ‘cronairquality.exe’ could be run under a task scheduler - to get different data. For that to be possible, both the IP address and the name of the data file would need to be permanently saved into a small configuration. The software ‘cronairquality.exe’ could then be called with the configuration file name, such as:


cronairquality.exe configurationfile.txt

When called with the configuration file, the software ‘cronairquality.exe’ could automatically contact the PurpleAir sensor, download and save the data into the selected file. Different configuration files could also be used to access different data - such as the data from the Thingspeak cloud storage.

As I wrote above, this is just a suggestion to add on what you have already done for the PurpleAir sensor.

the cron program is used
it is run every minute to get the raw file
it is not used when clicking on the test button

Unfortunately, it appear that neither the new gauge nor the new graphic is saved as an image
I just have not added that support yet
That the name of the external file where the data is saved be selectable as an option (rather than be the default 'airquality.txt').
why?

anyway, what I have added currently (and a bit more) is now in the latest full install

Brian, please do not be offended as my suggestion was just that, a suggestion, in order to improve and add some additional functionalities to the software ‘cronairquality.exe’.

OK, here is why I suggest adding some options to the software ‘cronairquality.exe’.

As you might be aware (or maybe not) the PurpleAir unit is made up of two identical particulate matter sensors (dual laser sensor - two sensors identified as PMSX003A and PMSX003B) - thus two slightly different data produced by the PourpleAir unit and uploaded to the Thingspeak cloud storage.

When the software ‘cronairquality.exe’ contact the PurpleAir unit (using for example the URL ‘http://192.168.0.1/json’), it is accessing only the first sensor (of the dual laser sensor) on channel #1 (or sensor PMSX003A). Unfortunately, because of the poor technical support (communication) I have been having with the PurpleAir company, I do not know how to access directly (through the local URL) the second sensor (of the dual laser sensor) on channel #2 (or sensor PMSX003B).

Why, you may ask, is there a need to access the data of channel #2 when the data of channel #1 is perfectly usable. Well, two weeks ago, when my area was covered with thick smokes from the numerous provincial forest fires and the AQI levels were reaching the ‘very unhealthy’ level (AQI greater than 225), for some unknown reasons, channel #1 started reporting 9000

For the DIY’ers, if you are interested in tinkering with this type of sensor a number of reasonably priced laser PM sensors suitable for this application can be found by searching ebay for “Plantower”. Prices start around $20.

More info here.

Will that be available also in the updated ZIP version?
yes, of course as for
https://map.purpleair.org/json?show=SENSOR_ID'
what is say your sensor ID, to see if that works? (there is a sensor ID in the airquality.txt file, but where and how do you use that in the above url?) ah, nevermind, you just need to have "" around the ID

but that still does not seem to show the other channel data?

Niko, thank you for providing the link to the ‘Worldwide Air Quality’ site - quite interesting, very informative. Just wish my dexterity, my sight and my brain cells were a bit younger … I would certainly get involved into building my own air quality sensor… :oops:

Brian, the ID found in the ‘airquality.txt’ data file is not the sensor ID. To view the data uploaded by my PurpleAir unit to the Thingspeak cloud storage, use the following link:

https://map.purpleair.org/json?show=1256

Using the above link in a browser will display a JSON data file. Using the above link as the IP Address in the software ‘cronairquality.exe’ will download the JSON data file (and overwrite the previously saved data file). :wink:

ing the above link in a browser will display a JSON data file. Using the above link as the IP Address in the software 'cronairquality.exe' will download the JSON data file (and overwrite the previously saved data file)
yes of course, but that is not what would happen instead the cronairquality.exe program would get both lots of data (local IP and then from the purple air site, to 2 different file names) where /how does the owner get the ID? (e.g 1256

also I see that json data has two
“PM2_5Value”:
values, I assume the first is one channel the other is the other channel?

Indeed. The software ‘cronairquality.exe’ by itself (without an external additional configuration file) could download the data from the local PurpleAir unit (channel #1) to the file ‘airquality.txt’ (as it does presently).

The software ‘cronairquality.exe’ with (using) an external additional configuration file could download the data from:

  • either the local PurpleAir unit (channel #2) to a file with a different name (a name other than ‘airquality.txt’ to prevent overwriting)
  • or from the Thingspeak cloud storage (channels #1 and #2), again, to a file with a different name (a name other than ‘airquality.txt’ to prevent overwriting)

The unit ID number is supplied with the unit when it is sold.

Indeed, again, the two ‘PM2_5Value’ values represent the two channels.

I am attaching the PDF file ‘Using PurpleAir Data’ that will identify the parameters found in the file downloaded from the Thingspeak cloud storage.


Using PurpleAir Data.pdf (85.4 KB)

I am thinking though currently its not known how to get the second channel data from the local json data?
I can make so that in the setup in WD the user enters their sensor ID so that the data can be downloaded from the cloud data to make sure the channel A (local) is OK (i,e compares OK)…if one is much too high (different), then the lesser is used, yes?

Brian, to make things a bit more simple, and since getting any data other than for the PM2.5 is unnecessary (such as PM1.0 and PM10.0), it might be more useful to only get the data for both channels from the Thingspeak cloud storage (using the PurpleAir unit ID).

This is what I have been doing with one of my PHP script, I download the data, extract the data from the first ‘PM2_5Value’ (channel #1), extract the data from the second ‘PM2_5Value’ (channel #2), ensure that the values do not exceed 500, compare the value from channel #1 to the value of channel #2 and use the value of channel #1 if it is within the range of the value from channel #2 (range would be

that sounds like a good idea
then people do not need to worry about finding the IP address of their local device and needing to make that a fixed IP etc

one thing, using the cloud data
which one of these data points is the other micron sizes?
{"v":5.44,"v1":5.582239810294803,"v2":6.025010763633549,"v3":5.927219052577544,"v4":6.145393002971199,"v5":5.514878692977332,"v6":21.797971012049327,"pm":5.44,"lastModified":1503286165055,"timeSinceModified":80241}"}]}
maybe v1 is the 1.0?

None of them - only the data for the PM2.5 is available from the link - for both channel #1 and channel #2.

Brian, if you have a look at the ‘Using PurpleAir Data.pdf’ file I mentioned above, you will have your answer to the purpose of the other parameters.

As I mentioned in the previous message, after reading more about the air quality index (on other sites), of the different particulate matter (PM) values, only the 2.5 (PM2.5) appears to be used for the calculation, the PM1.0 and PM10.0 seem to be ignored or unused.

As I have suggested many times, there is probably more data that can be downloaded, both from the local network (such as the data from channel #2) and from the Thingspeak cloud storage - it is my understanding that there is a lot, a lot more data on that Thingspeak cloud storage, enough to create hourly, daily, weekly and yearly graphics … but it appears that the designer/reseller behind the PurpleAir unit does not want to share the information on how to access that data (certainly not with me, even after multiple messages/requests :x ).

I could still use both sources then…local IP and cloud data (the cloud data to get the other channel 2.5 reading, for use as a back up)
so as to get the other micron data from the local IP data

Indeed, Brian, you could use both URL. But…

I still think that the data from the Thingspeak cloud storage (ie: ‘https://map.purpleair.org/json?show=SENSOR_ID’) should be the default procedure (option) and, true, we would obtain the data for PM2.5 (only), but the data for both channels - we would have a backup channel.

There could be an option to also download a single channel with the data for all three PM (PM2.5, PM1.0 and PM10.0).

That is why in a previous message I was suggesting that the software ‘cronairquality.exe’ had the flexibility to possibly use an external setting file so that the software ‘cronairquality.exe’ could download data from multiple locations/sites without overwriting the saved data file (thanks to its external configuration file).

I do like the idea of not having to mess around with a local IP address and just use the sensor ID that is provided with the sensor
and since it looks like the PM 2.5 value is the important one, and only one needed or the air quality index, then we can get that value (for both channels) via the purpleair.com cloud data

one other advantage of using the cloud data is I could make it where another sensor ID could be monitored (e.g via custom tags)

I do have others interested in this feature in WD (via email and via the WD Facebook page ) :slight_smile:

maybe have it optional to get the data data via the local sensor IP address

this update
http://www.weather-display.com/downloadfiles/weatherdisplaytest.zip

allows to set the sensor ID

and so the PM2.5 value is used from the cloud site (I still need to compare the 2nd channel data and use that if the first channel data is out of range)

and you can set to use the local IP to get the other data (1.0 and 10.0)

also you can set to upload the gauge and graph to your web site (see in the misc setup)
(aqi.gif and aqigraph.gif)