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

0 Members and 1 Guest are viewing this topic.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • 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: November 22, 2019, 06:53:56 AM by wvdkuil »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • 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, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline txweather.org

  • Forecaster
  • *****
  • Posts: 1597
    • 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: 1986
    • 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

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #5 on: November 21, 2019, 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: November 21, 2019, 05:19:41 AM by Stegrie »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #6 on: November 21, 2019, 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

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #7 on: November 21, 2019, 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: November 21, 2019, 06:28:05 AM »
Hi in the json stands :false
array is in attach

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #9 on: November 21, 2019, 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?


Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #10 on: November 21, 2019, 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: November 21, 2019, 06:43:27 AM by Stegrie »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #11 on: November 21, 2019, 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: November 21, 2019, 06:55:29 AM by wvdkuil »



Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #14 on: November 21, 2019, 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



Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #15 on: November 21, 2019, 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

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #16 on: November 21, 2019, 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: November 21, 2019, 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: November 21, 2019, 09:25:21 AM by Stegrie »

Offline Stegrie

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

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #19 on: November 21, 2019, 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: November 21, 2019, 11:12:19 AM by wvdkuil »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #20 on: November 22, 2019, 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: November 22, 2019, 07:10:21 AM by wvdkuil »

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Support of "Leuven" Air Quality scripts
« Reply #21 on: November 22, 2019, 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

Offline marko30

  • Member
  • *
  • Posts: 12
Re: Support of "Leuven" Air Quality scripts
« Reply #22 on: January 26, 2020, 03:15:25 PM »
For me _test2 is working ok, but saratoga page not.

https://okroglovreme.com/wxAqLuft.php
https://okroglovreme.com/luftdaten/ws_luftdaten2.php

what is correct record in setting?

$userSensor     = 'esp8266-XXXXXX'
or
$userSensor     = 'XXXXXX'


any toughts?
thx.
« Last Edit: January 26, 2020, 03:21:35 PM by marko30 »

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Support of "Leuven" Air Quality scripts
« Reply #23 on: January 27, 2020, 01:17:33 PM »
For me _test2 is working ok, but saratoga page not.
https://okroglovreme.com/wxAqLuft.php
https://okroglovreme.com/luftdaten/ws_luftdaten2.php
what is correct record in setting?
$userSensor     = 'esp8266-XXXXXX'
or
$userSensor     = 'XXXXXX'
any toughts?
thx.
I am on vacation with insufficient internet. The sensor in your case is the displayed in the test2 page, I think 38115

I will check it when I am back Feb 1/2 depending on some strikes.

Wim

Edited Febr 1: Seems working correctly now.  Wim
« Last Edit: February 01, 2020, 12:06:41 PM by wvdkuil »

Offline plex

  • Contributor
  • ***
  • Posts: 102
Re: Support of "Leuven" Air Quality scripts
« Reply #24 on: February 23, 2020, 05:40:44 AM »
Thanks for yet a great script from Leuven [tup] =D>

I've got everything working, except the "Luftdaten map" inside the "my_AqhiLuft2Page.php". I've found other Leuven templates, where it's actually working, so I suspect I didn't do everything correct #-o Anyways there are only 4 Luftdaten users visible on the map in Denmark.

Could it be a path related problem? I've copied the files to weather28/_my_scripts dir, and kept the data dir in weather28/luftdaten/data. The graphs didn't work before changing the path to:
# ----------  we load our own sensor to our site
$useOwnDir      = './luftdaten/data/'; 

As I understand from the readme file, I shouldn't be necessary, to change path if I use weather28/ for the template?

https://www.vejrstationen.dk/weather28/index.php?p=mnu_aqhi_luft&wp=MB&lang=en

 

anything