weatherist34 wrote: Wed Oct 21, 2020 10:22 am
@xray77 mike I don't have time at present to dive into luftdaten issue you raised in PM, sadly I do not use luftdaten api so its always a learning curve for me, I always relied on Piet in the past to resolve and correct code but im not always seeing the PM2.5 in the same API position especially when a particular user does NOT have pm2.5 only pm 10..
Hello Brian,
Ok, I can understand that, you can't be involved in all possible scenarios.

And at some point it has to be enough to deal with the air quality data...
The sensors officially reporting to Luftdaten.info should all report PM 2.5 and PM 10 values, at least that's what I thought so far. It is a sensor kit with the Nova Fitness SDS011 sensor, which is distributed by Luftdaten.info. The "Luftdaten.info" module works, it only calculates with the PM 10 value instead of the PM 2.5 value, which is actually expected. I had found this out by using an AQI index calculator.
https://aqicn.org/calculator/en/
Extract from the "luftdaten.txt" in the directory "jsondata" from which the module obtains the data:
[{"sensordatavalues":[{"id":5013003893,"value_type":"P1","value":"8.82"},{"id":5013003894,"value_type":"P2","value":"7.78"}]
P1-Value is here the PM10 sensor value, but your module uses it to calculate the AOI for PM2.5.
P2-Value is the correct PM2.5-Sensor-Value which should be used for the calculation.
By swapping the array-values in the weather34-aqi-info-luftdaten.php this problem is solved:
Line 20:
$aqiweather["aqi"] =$weather34air dataaqi['sensordatavalues']
[0]['value'];
line 21:
$aqiweather["aqi2"] = $weather34airdataaqi['sensordatavalues']
[1]['value'];
The module only calculates with $aqiweather["aqi2"], and it get's now the correct PM2.5-Vaue.
The result is the module uses the AQI PM 2.5-sensor-value, as it should be:
$aqiweather["aqindex"]= number_format(pm25_to_aqi($aqiweather["aqi2"]), 1);
The only thing that does not work correctly yet is the graphic display, which gets the data from airquality-luftdaten.csv. In this file, the AQI-Index of the PM10-sensor is written in, not the AQ-Index from the PM2.5-Sensor as is expected. Unfortunately, I did not find the file responsible for writing the airquality-luftdaten.csv, this is the only problem that still needs to be solved.

- Bildschirmfoto 2020-10-21 um 14.48.21.png (360.39 KiB) Viewed 4855 times
Just hope that I have expressed it in a more or less understandable way, because unfortunately I am not a native speaker of English, which makes it a bit more difficult to explain...
The simplest solution is of course to leave out the luftdaten.info module and use only the Davis module, which works completely correctly.
So much from me on this topic, I will finish with this.
Best regards
Mike