Luftdaten Air Quality Sensor

I have an SDS011 sensor and reading the values with a python script. In python, I output the values into a json:


# append new values
data = {'sensordatavalues':[{'value_type':'SDS_P1','value':str(values[1])},{'value_type':'SDS_P2','value':str(values[0])}]}

In WD, I use this json file (and the “Luftdaten” option) to log the PM2.5 and PM10. Works nicely with latest build (Nov16). However, I do occasionally (actually quite often) get zero readings in WD. To verify my data was “produced” OK, I log same values at the same time into a separate txt file with a timestamp. I do this at one minute interval. In my log file, there are no zeros.

Is there any way to detect if the json file is corrupt (hence the zero reading) or ?
I also modified my script to output integer values only but the zeros were still there.

Alternatively, is there a way that airquality2.txt could be used for the PM10 in addition to PM2.5 ?

Thanks.

Maybe WD is trying to read the file while it is being written? Are you writing it to a temp file and renaming?

No, I’m writing directly into the file… Thanks for suggestion, I’ll try to create a temp file and just rename it!

niko, you solved my problem! Thanks!

That’s good news :smiley: It’s probably not 100% guaranteed, but the chance that the file is unavailable should be greatly reduced. You could also try offsetting the file creation time some seconds from the top of the minute.

Hi Brian
Many thanks. I now have my Luftdaten running and both the 2.5 and 10 results completely agreed with the unit data. Actually I had an extreme test - the sensor is running indoors for testing (and yet to add the temp/hum sensor) and I had just lit my woodburner for the first time this year. I forgot to clear the dust out from under the top cover which then burnt off and filled the house with smoke. 2.5 and 10 were off the scale !!!
For some reason the 10 level has stopped showing as a figure but shows on the graph.
A request - any chance of having a second 10 needle on the dial ? Or an option to display the two.
Thanks again
Alan

which scale and where exactly?

Hi Brian
The scale on your dial stops at 500 but my 2.5 reading was up in the 700’s - hence off the scale.
I also realise that the 10 sensing must happen at a different time as it did show up on the view purple screen (I had just changed the config of the particle sensor which resets the sensor - I had just reset mine to 5 minute intervals).
Is there a way I can put the readings on my site in figures ?
Rather than a second needle on the dial would it be possible to create a 10 dial gif for use on the website - not necessarily shown on the view purple screen.
Regards
Alan

now sure what you mean by a 10 dial gif?

there are custom tags available for the raw data

Hi Brian
I just meant a dial gif for the PM10 levels as aqi.gif is for pm2.5
Regards
Alan

Sorry Brian
I misunderstood - the dial is AQ Index - I thought it was PM2.5.
Regards
Alan

hoping to find the spare time to add support for the temperature and humidity data soon

Hi Brian
I noticed the AQI line does not appear on the webfiles graph.gif.
Would it also be possible to add the scale to the side of the main screen graph. One small point the AQI figure just above the graph is a fraction too high and gets hidden by the wind direction graph.
Thanks a lot
Alan

can you post a screen shot of what you are seeing re the last sentence?

Hi Brian
Forget that - it just means moving the wind direction graph up a bit and the AQI is visible
Regards
Alan

Try holding the shift key and move the AQI a bit.
First go to Advanced Set up/Customize mainscreen/enable move by holding shift key and drag with the mouse…

At least that is what I think you mean and want to do.

Thanks - I tried that but could not move the labels but making the wind direction a bit smaller did it.
Regards
Alan

Should work, you waited dragging until the cross over the AQI appeared?

Doesn’t seem to work on mine but I’m happy just moving the wind dir a bit.
Another point - is there a way of assigning a static IP to the sensor - I’ve lost mine a couple of times when the router has allocated a different one.
Regards
Alan

Static IP
IP’s changed again - can’t see why.
I found this link which suggests it’s possible to set static IP but I have no idea how to use it
Help would be most welcome
https://forum.arduino.cc/index.php?topic=460595.0

Regards
Alan