luftdaten.info - sensor.community air quality data to weewx

393 views
Skip to first unread message

misk...@gmail.com

unread,
Nov 15, 2020, 3:46:20 PM11/15/20
to weewx-user
Hello,
has anybody integrated the air quality API to WeeWX?

It should be probably something easy, as the sensor firmware has API with custom server, path, port, username/password to entry.

or there is also api for sensor.community service


thanks for info,
Michal, SVK

misk...@gmail.com

unread,
Nov 15, 2020, 4:10:50 PM11/15/20
to weewx-user
just for info, this is an opensource project, everyone can build:


I made 2 sensors myself, I consider myself as an ordinary guy with almost zero programming experience.
You can see my data here:
or here:
or...
but weewx is missing!

Dátum: nedeľa 15. novembra 2020, čas: 21:46:20 UTC+1, odosielateľ: misk...@gmail.com

steeple ian

unread,
Nov 16, 2020, 3:41:36 AM11/16/20
to weewx...@googlegroups.com
Google weewx-sds011. There is an extension for that sensor. 

In my case I rsync data to my main server and then use weewx-filepile extension to insert data into the new extended database. I then use a custom .tmpl to aggregate the data for a rolling 24hr AQI.

Ian

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/0171755b-7bd6-49f8-bc18-39261c278466n%40googlegroups.com.

misk...@gmail.com

unread,
Nov 17, 2020, 2:36:36 AM11/17/20
to weewx-user
thanks for guiding me!

1. I am able to install weewx-sds011, but i am not able to repeat all your steps.
2. how can i rsync data? just throught API in the web interface of luftdaten sensor?

3. how filepile works? it saves data to a plain text document? 
filename = /var/tmp/pond.txt
Or are you able to store it in the  new SDB database?

4. I will be probably able to create .tmpl and integrate it to my webpage. Only how the $parameters and formating looks like is the question

thanks for your help!

 
Dátum: pondelok 16. novembra 2020, čas: 9:41:36 UTC+1, odosielateľ: steep...@gmail.com

steeple ian

unread,
Nov 17, 2020, 3:11:31 AM11/17/20
to weewx...@googlegroups.com
Morning,
I am just doing some work on the weather34 skin at the moment. Give a little time and I will write this up more fully for you.
Ian

miso

unread,
Nov 19, 2020, 10:10:23 PM11/19/20
to weewx...@googlegroups.com
Hi Ian,
Just a kindly reminder, if you will have little time.

I am desperate to provide PM info to my neighbors, which are using wood for heating!

Thanks,
Michal

Dňa ut 17. 11. 2020, 9:11 steeple ian <steep...@gmail.com> napísal(a):
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/UJhz34G5r8s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CADASSaTpGmhGVTTVjxdvnufG2AgUmOq7bS2RKYUrOsHuGyknCA%40mail.gmail.com.

steep...@gmail.com

unread,
Nov 20, 2020, 3:35:16 AM11/20/20
to weewx-user
Michal,
I have emailed you directly.
Ian

Calo Geyer

unread,
Nov 27, 2020, 6:10:01 AM11/27/20
to weewx-user
Hi, I now made some php call using the setting "send to own API" and do get the data into a log file. It basically looks like the json output when you retrieve via IPaddress/data.json directly from the sensor.
Requirements are apache (httpd) and php installed. Do not forget to start httpd (sudo systemctl start httpd on archlinux)

I initially followed this instruction


creating a folder in srv/http/weewx/feinstaub and placed the SDS011.php there. The SDS011.php contains the code which is shown in the thread above.
<?php
$json = file_get_contents("php://input");
 file_put_contents("feinstaub.log", $json);
?> 
 I then created an empty feinstaub.log file in that folder too and make sure you grant write and read access to it (chmod 666 feinstaub.log). If you then add the server and path including name of .php (in my case weewx/SDS011.php) in your sensor configuration then you should see the updated data every 145 seconds.

Since I missed the timestamp etc. I moved to this php script


?php $logURL="feinstaub.log"; $logToOrdner="feinstaublog/".date('Ymd').".log"; $itime= time();//timestamp Januar 1 1970 00:00:00 GMT $datum= date('Y-m-d'); $zeit= date('G:i:s'); $ipAddress=$_SERVER['REMOTE_ADDR']; $daten = file_get_contents('php://input'); if(isset($daten) && !empty($daten)){//wenn Daten leer, nicht speichern //create oder add; aktuelles Messwert $handle=fopen($logURL,'w'); fwrite ($handle, "{" ); fwrite ($handle, '"time":'.$itime.','.chr(10)); fwrite ($handle, '"datum":"'.$datum.'",'.chr(10)); fwrite ($handle, '"zeit":"'.$zeit.'",'.chr(10)); fwrite ($handle, '"ipAddress":"'.$ipAddress.'",'.chr(10)); fwrite ($handle, '"daten":'.$daten.chr(10) ); fwrite ($handle, "}".chr(10) ); fclose ($handle); } if(isset($daten) && !empty($daten)){//wenn Daten leer, nicht speichern //als Datensätze in Ordner, $add=file_exists($logToOrdner); $handle=fopen($logToOrdner,'a'); if($add)fwrite ($handle, "," ); fwrite ($handle, "{" ); fwrite ($handle, '"time":'.$itime.','); fwrite ($handle, '"datum":"'.$datum.'",'); fwrite ($handle, '"zeit":"'.$zeit.'",'); fwrite ($handle, '"daten":'.$daten ); fwrite ($handle, "}".chr(10) ); fclose ($handle); } ?>  

This log is then in a separate folder having the date on it. I will now continue later on the next steps.

Regards,
Andreas

Calo Geyer

unread,
Nov 27, 2020, 6:18:40 AM11/27/20
to weewx-user
And this is what I am going to do this night or later when I got time; changing the script to fill the database directly.

miso

unread,
Nov 27, 2020, 7:14:25 AM11/27/20
to weewx...@googlegroups.com
Hello,
I have this answer from sensor developer:

this feature exists in this firmware. Just look for "Send data to custom API". There you can configure a server and a path to a script on i.e. a Raspberry PI. If configured the firmware will send a JSON object to this address. There is a sample script at https://github.com/opendata-stuttgart/madavi-api/blob/master/data_simple.php that will take this object and save the data to a CSV file.



Dňa pi 27. 11. 2020, 12:18 Calo Geyer <calo....@gmail.com> napísal(a):

miso k

unread,
Nov 27, 2020, 3:29:24 PM11/27/20
to weewx-user
so i added the file named data_simple.php with content as in the example above. Then I have browsed the address myRPiweewxIPaddress/data_simple.php and i got the answer:
Sensor: ok 
,but this will be also without any imput data from sensor...
No csv is produced.

rights on data_simple.php are -rw-r--r-- . is it ok?
 

Dátum: piatok 27. novembra 2020, čas: 13:14:25 UTC+1, odosielateľ: miso k

miso k

unread,
Nov 27, 2020, 3:56:07 PM11/27/20
to weewx-user
Hi again,
so I tried to do it your way, it works now.
the feinstaub.log looks like this:
{"time":1606510522,
"datum":"2020-11-27",
"zeit":"21:55:22",
"ipAddress":"192.168.1.23",
"daten":{"esp8266id": "759897", "software_version": "NRZ-2020-131", "sensordatavalues":[{"value_type":"SDS_P1","value":"465.88"},{"value_type":"SDS_P2","value":"66.15"},{"value_type":"BME280_temperature","value":"-0.09"},{"value_type":"BME280_pressure","value":"98677.09"},{"value_type":"BME280_humidity","value":"100.00"},{"value_type":"samples","value":"3565079"},{"value_type":"min_micro","value":"39"},{"value_type":"max_micro","value":"43094"},{"value_type":"interval","value":"145000"},{"value_type":"signal","value":"-62"}]}
}

now we need to save it to main database weewx.sdb I hope. Let's ask Ian how to do it with filepile.

Or let me know, when you will be further with your solutions.

Thanks,
M

Dátum: piatok 27. novembra 2020, čas: 21:29:24 UTC+1, odosielateľ: miso k

miso k

unread,
Nov 30, 2020, 1:15:18 AM11/30/20
to weewx-user
Hi,
I have successfully added inner Humidity fields and graphs to my webpage as a training (values are already measured). So only step is to fill the data from AirQual sensor to database.
Did you find a way to do it?

Michal

Dátum: piatok 27. novembra 2020, čas: 21:56:07 UTC+1, odosielateľ: miso k

steeple ian

unread,
Nov 30, 2020, 2:43:49 AM11/30/20
to weewx...@googlegroups.com
I have worked out a method but the json data file that you have is more complicated than the one I have from my process. The only data you need to extract are the pm2.5 and pm10.0 figures. It is difficult to see which is which in your file. My method uses a piece of php code to parse the json data file and insert the data into a txt file in the format that filepile requires. You must also be using the new extended WeeWX database which has additional fields for air quality.
Ian

Calo Geyer

unread,
Nov 30, 2020, 2:53:16 AM11/30/20
to weewx-user
Hi, I also worked according this link
https://tech.hamm7.de/blogs/feinstaub/feinstaubphp
and managed to get the log file recording. I also created the feinstaub.db (using myphpadmin) which I fed by the php script (from the feinstaub.log) however my issue to solve was the connection of script to database (connectdb.php). I think I can solve soon and then we would have all directly in the database.
But is good to hear that you explore the other way to get it work as well. Do you mind sharing details how to create the data file?
I will share how my log now looks like in a second as I need to pick from home network.

Calo Geyer

unread,
Nov 30, 2020, 2:58:06 AM11/30/20
to weewx-user
Screenshot_20201130-085211.jpg

Calo Geyer

unread,
Nov 30, 2020, 2:59:53 AM11/30/20
to weewx-user
See, Ian, if we managed to use this file, we got PPM10, PPM2.5, Temperature, Humitidy and Wlan.

steeple ian

unread,
Nov 30, 2020, 3:09:13 AM11/30/20
to weewx...@googlegroups.com
Yes I see. So you are using a separate database if I understand correctly? If you use the WeeWX extended database you only need the PM sensor data. I will share my method in more detail later today.
Ian

Calo Geyer

unread,
Nov 30, 2020, 3:20:37 AM11/30/20
to weewx...@googlegroups.com
Hi Ian,

I am trying to use :-)
but I am not yet sure how to use in Weewx afterwards. I also tried to import my archive.db in myphpadmin but did not work so I am afraid this is not leading me to where I want to go. If we get your file to work we can use the Weewx extended which for sure will do the job.

Andreas

steeple ian

unread,
Nov 30, 2020, 3:36:18 AM11/30/20
to weewx...@googlegroups.com
I have looked at the example json data from your process. The PM data values appear to be SDS_P1 and SDS_P2. The actual values are very high. Are these accumulated values or artificially stimulated?

steeple ian

unread,
Nov 30, 2020, 3:38:56 AM11/30/20
to weewx...@googlegroups.com
image.png

Calo Geyer

unread,
Nov 30, 2020, 3:56:33 AM11/30/20
to weewx...@googlegroups.com
Hi, not sure if you talk about my measurements? I would say it can not be accumulated. Here my latest values from the log.
Screenshot_20201130-095351.jpg

steeple ian

unread,
Nov 30, 2020, 5:03:33 AM11/30/20
to weewx...@googlegroups.com
The screen dump is from Michal’s json data. Can you post a similar data file so that I can compare with your log?

Calo Geyer

unread,
Nov 30, 2020, 6:15:36 AM11/30/20
to weewx-user
Hi, sorry, I just have the data.json output. I do not have a log file which looks like the one from Michal.
Screenshot_20201130-121354~2.jpg

steep...@gmail.com

unread,
Nov 30, 2020, 7:18:45 AM11/30/20
to weewx...@googlegroups.com

OK those values look more realistic. I assume SDS_P1 = PM10 and SDS_P2 = PM2.5

 

I will work out the code to parse that structure this evening.

Ian

 

Sent from Mail for Windows 10

 

From: Calo Geyer
Sent: 30 November 2020 11:15
To: weewx-user
Subject: Re: [weewx-user] luftdaten.info - sensor.community air quality data to weewx

 

Hi, sorry, I just have the data.json output. I do not have a log file which looks like the one from Michal.

On Monday, November 30, 2020 at 11:03:33 AM UTC+1 steep...@gmail.com wrote:

The screen dump is from Michal’s json data. Can you post a similar data file so that I can compare with your log?

 

On Mon, 30 Nov 2020 at 08:56, Calo Geyer <calo....@gmail.com> wrote:

Hi, not sure if you talk about my measurements? I would say it can not be accumulated. Here my latest values from the log.

 

On Mon, 30 Nov 2020 at 09:38, steeple ian <steep...@gmail.com> wrote:

 

 

On Mon, 30 Nov 2020 at 08:36, steeple ian <steep...@gmail.com> wrote:

I have looked at the example json data from your process. The PM data values appear to be SDS_P1 and SDS_P2. The actual values are very high. Are these accumulated values or artificially stimulated?

 

On Mon, 30 Nov 2020 at 08:20, Calo Geyer <calo....@gmail.com> wrote:

Hi Ian,

 

I am trying to use :-)

but I am not yet sure how to use in Weewx afterwards. I also tried to import my archive.db in myphpadmin but did not work so I am afraid this is not leading me to where I want to go. If we get your file to work we can use the Weewx extended which for sure will do the job.

 

Andreas

 

On Mon, 30 Nov 2020 at 09:09, steeple ian <steep...@gmail.com> wrote:

Yes I see. So you are using a separate database if I understand correctly? If you use the WeeWX extended database you only need the PM sensor data. I will share my method in more detail later today.

Ian

 

On Mon, 30 Nov 2020 at 07:59, Calo Geyer <calo....@gmail.com> wrote:

See, Ian, if we managed to use this file, we got PPM10, PPM2.5, Temperature, Humitidy and Wlan.

On Monday, November 30, 2020 at 8:58:06 AM UTC+1 Calo Geyer wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+..@googlegroups.com.








--

--

You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages