Author Topic: Support of "Leuven" Air Quality scripts  (Read 829 times)

0 Members and 1 Guest are viewing this topic.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Support of "Leuven" Air Quality scripts
« on: March 28, 2019, 12:10:11 PM »
I coded the Purpleair (PA-II)  and the Luftdaten scripts in a similar way. Probably most questions/problems are similar, so both scripts will be supported in this topic.

PurpleAir  NEW VERSION as of 2019-11-22
Demo: https://weather-template.nl/purpleair/index.html 
Download: https://leuven-template.eu/leuven_download2019.php?id=purpleair
Readme: You will find the read-me pdf in the download, but you can read it here in a new window also.
Known issues:
For extended version2: upload to own website fails nearly always
==> added a fall-back in sensor script by downloading from the purpleair website

Luftdaten
Demo: https://leuven-template.eu/luftdaten/index.html
Download: https://leuven-template.eu/leuven_download2019.php?id=luftdaten
Readme: You will find the read-me pdf in the download, but you can read it here in a new window also.
Known issues: link will be added when needed

There are two versions of these scripts which both can be accessed and studied from the demo-page.   The "basic version" reads your data form the suppliers database.  A more "extensive version" expects the sensor to upload the row measurements to your own web-server.  This will need more knowledge about http-bypass in your webserver-htaccess file.

Support:
When you post questions about the scripts, please always include the URL (=correct link)  to the script on your website. That reduces the time for answering your questions.

Wim
« Last Edit: Today at 06:53:56 AM by wvdkuil »
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 7500
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Support of "Leuven" Air Quality scripts
« Reply #1 on: March 28, 2019, 01:50:59 PM »
Thanks, Wim!
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline txweather.org

  • Forecaster
  • *****
  • Posts: 1526
    • Texas Weather
Re: Support of "Leuven" Air Quality scripts
« Reply #2 on: March 28, 2019, 03:17:02 PM »
Thanks again! YAY! :D

----
Davis Vantage Pro2 Plus +FARS|Meteobridge Nano SD|Meteohub|Meteobridge MR-3020|WU KTXSPRIN75/PWS JRARGWX75/CWOP EW2972/WBB TXWDVUE75/Blitzortung ID: 1142|AWEKAS: 12095
Donations are welcome: https://paypal.me/ffuentesb

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #3 on: November 18, 2019, 11:55:10 AM »
Hi wim 
The test1 is working perfect test2 has an Error
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test2.php
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test1.php
with your Sensor ID work test2 with mine not why

Stefan

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #4 on: November 18, 2019, 12:31:22 PM »
Hi wim 
The test1 is working perfect test2 has an Error
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test2.php
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test1.php
with your Sensor ID work test2 with mine not why

Stefan
The test2 works when you upload the data from your purpleair sensor. You have to instruct the sensor to do that.
More info; https://www.wetterstation-johanngeorgenstadt.de/purpleair/_readme%20FIRST.pdf => 4. Upload our data

There were / are/ often problems when  the data/ folder to upload into is on an https server

Succes, Wim
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #5 on: Yesterday at 05:17:21 AM »
Hi Wim,
 
Have do this new and also again, test2 not work
4. Upload our data -> Step by Step
https://www.wetterstation-johanngeorgenstadt.de/sensorpurple2.php -> ok
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test2.php -> Error, not found the File
it's a Cache thing? I have all do as described,nothing else changed.

Stefan
« Last Edit: Yesterday at 05:19:41 AM by Stegrie »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #6 on: Yesterday at 05:52:24 AM »
Hi Wim,
 
Have do this new and also again, test2 not work
4. Upload our data -> Step by Step
https://www.wetterstation-johanngeorgenstadt.de/sensorpurple2.php -> ok
https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test2.php -> Error, not found the File
it's a Cache thing? I have all do as described,nothing else changed.

Stefan
I have no idea.
But
1. you should create a data/ folder on your server
2. set line 12 in sensorpurple2.php to comment
Code: [Select]
$save_last_mes  = true;
#$save_last_mes  = false;
3. check if there is anything arriving in the data folder.

The purpleair sensor sends the data to
=> sensorpurple2.php 
==> that script
===> stores the received measurements in an array in the data/ folder 
 and
===> optionally writes the received data into a text file to inspect:   data/last_purple_data_ 14151.json

Also important, did you add https://  before the www in the link in your purpleair sensor?

Success,
Wim
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #7 on: Yesterday at 06:15:32 AM »
Hi
Thanks have set the new Data Folder now in these Folder: see Attachment
Test2 not work have these also to the Attachment
last_purple_data_14151.json, Ds Store, and purple_24data_14151.arr cannot attach, but there is in the new data Folder

$save_last_mes  = true; -> have set
#$save_last_mes  = false; -> have set

test2 will not work

Stefan

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #8 on: Yesterday at 06:28:05 AM »
Hi in the json stands :false
array is in attach

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #9 on: Yesterday at 06:28:22 AM »
Hi
Thanks have set the new Data Folder now in these Folder: see Attachment
Test2 not work have these also to the Attachment
last_purple_data_14151.json, Ds Store, and purple_24data_14151.arr cannot attach, but there is in the new data Folder

$save_last_mes  = true; -> have set
#$save_last_mes  = false; -> have set

test2 will not work

Stefan
https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json
==> is there but it has got no or no good data last time is was accessed
===> check if the date /time of that file changes according  to the uploads from purpleair
https://www.wetterstation-johanngeorgenstadt.de/data/purple_24data_14151.arr
==> is there and seems  a correct PHP-array
===> but it can not be accessed by the script https://www.wetterstation-johanngeorgenstadt.de/purpleair/_test2.php
====> so probably the permissions are not correct.

Could you please set the permissions for the data/ folder and alll its contents to #0777 or read/write by world?

Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #10 on: Yesterday at 06:35:41 AM »
set to 0777 no luck

see:https://www.purpleair.com/data.json?show=14151&key=XRBTRTSYC512PMRC

yes it changed Date+ Time when run sensorpurple2.php
« Last Edit: Yesterday at 06:43:27 AM by Stegrie »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #11 on: Yesterday at 06:53:56 AM »
set to 0777 no luck

see:https://www.purpleair.com/data.json?show=14151&key=XRBTRTSYC512PMRC

yes it changed Date+ Time when run sensorpurple2.php
https://www.wetterstation-johanngeorgenstadt.de/data/  gives a 403 error, so the permissions are (to) low.
https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json  always contains false, so the data is not (correct) sent by the sensor or other error

Question: did you set https://  or http:// before www.wetterstation. . .   in the purpleair sensor

TODO:
You did put the scripts in purpleair/ws_purpleair2.php  in their own folder.
You then have to change  line 7 in ws_purpleair2.php   from
Code: [Select]
$useOwnDir      = './data/';  to
Code: [Select]
$useOwnDir      = '../data/';  There should be TWO points to tell the script the data folder is 1 level below its own folder.

Wim

« Last Edit: Yesterday at 06:55:29 AM by wvdkuil »
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php



Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #14 on: Yesterday at 08:45:15 AM »
hi Wim
it works but all Data is 0 in there json

https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json
https://www.wetterstation-johanngeorgenstadt.de/purpleair/ws_purpleair2.php

The receiving script sets the value 'false"  so that means no data or no correct data received on your webserver..
https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json

Some setting in the purpleair is wrong
or
some communication problem between purpleair and the receiving script.
There were often problems when using https:// servers in the past also.

I have to think how we can test that.

Wim


Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #15 on: Yesterday at 09:10:31 AM »
hi Wim
it works but all Data is 0 in there json

https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json
https://www.wetterstation-johanngeorgenstadt.de/purpleair/ws_purpleair2.php

The receiving script sets the value 'false"  so that means no data or no correct data received on your webserver..
https://www.wetterstation-johanngeorgenstadt.de/data/last_purple_data_14151.json

Some setting in the purpleair is wrong
or
some communication problem between purpleair and the receiving script.
There were often problems when using https:// servers in the past also.

I have to think how we can test that.

Wim

Why is there user:password in the settings in purpleair  header?
Wim
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #16 on: Yesterday at 09:16:48 AM »
as in the Instruction say:
At the Key 3 field you enter the exact URL http://www.website.com/sensorpurple2.php
Key4 you type user:password
and Method you leave “Post” as it is

Data Provider #2: Custom
Data Provider #2 URL: http://www.website.com/sensorpurple2.php Data Provider
#2 HEADERS: user:password
Data Provider #2 METHOD: POST

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #17 on: Yesterday at 09:19:51 AM »
you need the Link to change these settings  per PM?
or give the email to forwarding the Mail from purple air to you
find in pm to you
« Last Edit: Yesterday at 09:25:21 AM by Stegrie »

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #18 on: Yesterday at 09:47:52 AM »
message (mail) sent to you from here

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #19 on: Yesterday at 10:56:32 AM »
you need the Link to change these settings  per PM?
or give the email to forwarding the Mail from purple air to you
find in pm to you
I have my own Purpleair sensor but it failed uploading to my own server in June, no big problem as I always used the type-1 output on my site. Uploading was only needed when there was a user-problem as you have.

My current purpelair, which is a few years old, shows at the bottom of the sensor page
NTPLOCUPDPAATSATSS3RDTSBTSS3RD
V4.11 2.0+OPENLOG+15833 MB+DS3231+BME280+PMSX003-B+PMSX003-A

I tried all settings possible on the registration page.
With my version it is impossible to sent information to an https or an http site using post, get or put.

The messages arrive, but there is no data in the message, as it was until June this year.
Using $_REQUEST, GET , POST  or 'php://input' returns no data at all.

Maybe your sensor has the same problem,

Wim
« Last Edit: Yesterday at 11:12:19 AM by wvdkuil »
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1482
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #20 on: Today at 06:55:57 AM »
First message is adapted for a new version of the PurpleAir script.

The upload to ones own website seems to fail at 99% of the user-sites
I added a "fall-back" so, when there is no sensor data arriving directly, the sensor script reads the latest sensor-data from the PurpleAir database.

Wim
« Last Edit: Today at 07:10:21 AM by wvdkuil »
Support for Leuven-Template & Scripts  at this forum
Support for the PWS_Dashboard (HWS-template) for WD a.o.  http://pwsdashboard.com/
Script sponsors https://support.leuven-template.eu/userlistScripts.php
Template sponsors https://support.leuven-template.eu/userlist.php

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #21 on: Today at 10:16:55 AM »
First message is adapted for a new version of the PurpleAir script.

The upload to ones own website seems to fail at 99% of the user-sites
I added a "fall-back" so, when there is no sensor data arriving directly, the sensor script reads the latest sensor-data from the PurpleAir database.

Wim

Now works with Version 2 many thanks Wim

 

anything