Author Topic: Purpleair PHP Retrieval script  (Read 2269 times)

Breezy and 1 Guest are viewing this topic.

Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #50 on: February 04, 2018, 12:33:57 AM »
I was not able to fix the bad data in channel b from Thingspeak.

I replaced the code to pull the PM1, PM2.5 and PM10 from the PurpleAir directly.

http://www.weathercat.net/wxpurpleair.php

Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #51 on: February 04, 2018, 12:43:15 AM »
I was not able to fix the bad data in channel b from Thingspeak.

I replaced the code to pull the PM1, PM2.5 and PM10 from the PurpleAir directly.

http://www.weathercat.net/wxpurpleair.php
Send me via PM the entire script, with your data filled out in it. Use the 1.4b I posted, please don't include any of your changes.

I will look and see whats going on.

Sent from my Pixel using Tapatalk


Offline weatherbee

  • Senior Contributor
  • ****
  • Posts: 163
    • Sherman Ct. Weather
Re: Purpleair PHP Retrieval script
« Reply #52 on: February 04, 2018, 10:40:26 AM »
azchrisf,
I think what you've done on the PM10 looks good.
When I pull the info on PM10 channel B I am getting -1.
Tom

Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #53 on: February 04, 2018, 11:21:29 AM »
azchrisf, I just sent you my file that will not pull PM10 channel b data and a file that simple pulls PM10 data to verify that the data is there.


Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #54 on: February 04, 2018, 11:26:06 AM »
OK I found the problem, 1.4c forthcoming.

Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #55 on: February 04, 2018, 11:52:04 AM »
Okey dokey - posted 1.4c.

// Version 1.4c
// * Fixed bug with PM10 values
// * Added experinmental PM10 AQI function
// * Tuning of script
// * Other misc. changes

Offline Toxic

  • Senior Contributor
  • ****
  • Posts: 193
  • #conligwx
    • conligwx.org
Re: Purpleair PHP Retrieval script
« Reply #56 on: February 05, 2018, 05:58:52 PM »
Okey dokey - posted 1.4c.

// Version 1.4c
// * Fixed bug with PM10 values
// * Added experinmental PM10 AQI function
// * Tuning of script
// * Other misc. changes

is the same type of aqi values available locally?  http://ip.of.purple.air/json   ??
Regards Simon


Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #57 on: February 05, 2018, 06:12:05 PM »
The PM data is there but it lacks the Running Averages.

Here is a little script that will pull data from your PurpleAir you can play with. Just change the IP in the script.

Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #58 on: February 06, 2018, 04:26:18 PM »
I noticed that the script for my cell broke when the PM reached 0.09. I did not have change to check this script before it went back over 0.1 but I used the same code on my cell page.

Will this script handle PM vales below 0.1?

Nice air quality in Northern California today. :)

Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #59 on: February 07, 2018, 03:10:11 AM »
I substitued a made up value and it displayed fine.

 [ You are not allowed to view attachments ]
« Last Edit: February 07, 2018, 07:39:05 AM by azchrisf »

Offline Toxic

  • Senior Contributor
  • ****
  • Posts: 193
  • #conligwx
    • conligwx.org
Re: Purpleair PHP Retrieval script
« Reply #60 on: February 08, 2018, 08:00:05 AM »
Small change to mine template.

changing code "m3" to m³ to show the m3 as m
Regards Simon


Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #61 on: February 12, 2018, 08:07:50 AM »
Just to let everyone know I'm working on some changes for the next iteration. It's becoming "all it can be", so development will be slowing to, well, nothing, unless someone finds a bug or wants a feature.

// Version 1.5
// * Fixed bug where if decimal point was turned off decimal point numbers would still show - now display 0 as originally intended
// * Added option to cache results for x seconds - this is useful if you have a high traffic site. PA doesn't like you doing many calls to it.
// * Removed the site up checking, it slows the script and is redundant since the script will return an error anyways if it fails.
// * Changed m/3 to proper HTML entity (thanks Toxic)
// * Added all the variables from other sensor items (PM 1.0, ug/m3 for 0.3mm, 5mm, etc. - these can be used as you like but won't appear in the script HTML)
// * Added "Very Low" value to GetPMMessage for values < 1.0

Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #62 on: February 14, 2018, 12:11:04 PM »
Has version 1.5 been released or are the changes listed being worked on still?

Offline azchrisf

  • Cobra Weather Dominator Operator
  • Senior Contributor
  • ****
  • Posts: 191
    • Copperwood WX
Re: Purpleair PHP Retrieval script
« Reply #63 on: February 14, 2018, 01:13:09 PM »
Still working on it.

Sent from my Pixel using Tapatalk


Offline JupiterJoe

  • Senior Member
  • **
  • Posts: 63
  • JupiterWX.com
    • Live Jupiter, FL Weather
Re: Purpleair PHP Retrieval script
« Reply #64 on: February 15, 2018, 12:33:33 PM »
Thank you for your script, it's nice being able to get the data visualized on my website. http://www.joe4speed.com/purple.php

I was wondering if you would perhaps know any way to use this data to control the AQI on the front page of the Alt. Dashboard? Currently, I am only able to display the AirNow.gov data from West Palm Beach, and their AQI is totally different than our local AQI. www.jupiterwx.com

Thank you for any advice. It may not be possible, but I thought there would be no harm in asking. :)

Offline Forever

  • Contributor
  • ***
  • Posts: 111
Re: Purpleair PHP Retrieval script
« Reply #65 on: February 15, 2018, 06:00:06 PM »
Sure you can include the AQI from your PurpleAir if you know what code to change.

I'm not familiar with the dashboard you're using so I'll show you what I did for the one on my cell page and you should be able to see what is being done.

http://www.weathercat.net/cell.php

I have attached the file I changed to pull data directly from my PurpleAir. This will probably not work for you but it should get you pointed in the correct direction.

Offline JupiterJoe

  • Senior Member
  • **
  • Posts: 63
  • JupiterWX.com
    • Live Jupiter, FL Weather
Re: Purpleair PHP Retrieval script
« Reply #66 on: February 15, 2018, 06:46:49 PM »

Hi Forever,
Thank you for that code. I use the Alt Ajax dashboard built off of the Saratoga template. It looks very similar to yours and uses the aqirss.php script similar to yours.
I will definitely check it out though. Thank you for your reply.

Sure you can include the AQI from your PurpleAir if you know what code to change.

I'm not familiar with the dashboard you're using so I'll show you what I did for the one on my cell page and you should be able to see what is being done.

http://www.weathercat.net/cell.php

I have attached the file I changed to pull data directly from my PurpleAir. This will probably not work for you but it should get you pointed in the correct direction.