Weather34 Aurora template: PM2.5/10 AQI values calculation question

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

Post Reply
HighWay
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Mon Dec 20, 2021 10:24 am

Weather34 Aurora template: PM2.5/10 AQI values calculation question

Post by HighWay »

Greetings Ladies and Gentlemen,

I am still a novice in this matter, and please excuse me if I ask trivial questions. I purchased and installed my Weather equipment 3 weeks ago, and I still have a lot to experiment and learn. This is my first topic.

I installed Weather34 meteobridge version , and its time to say "Thank You" to Brian and his efforts to create this beautiful template.I am very sorry that this template will no longer be supported.

Now I would like to ask where the calculations related to PM2.5 and PM10 are located , which file ? I tried to dig in some of them , but I totally lost myself. My PHP experience is close to 0.
The value related to PM2.5 AQI appear fine, but PM10 seems not.
Meteobridge provide right values but in ug/m3 , and they somehow calculated to AQI values. I would know where this calculation is done, in order to change it.
Here are some outputs :

<logger>
<TH date="20220112103832" id="th0" temp="-1.9" hum="75" dew="-5.7" lowbat="0"/>
<THB date="20220112103759" id="thb0" temp="24.1" hum="35" dew="7.7" press="1010.5" seapress="1036.1" fc="-1" lowbat="0"/>
<WIND date="20220112103832" id="wind0" dir="337" gust="1.5" wind="1.5" chill="-3.9" lowbat="0"/>
<RAIN date="20220112103748" id="rain0" rate="0.0" total="0.0" delta="0.0" lowbat="0"/>
<SOL date="20220112103759" id="sol0" rad="81" lowbat="0"/>
<UV date="20220112103759" id="uv0" index="0.0" lowbat="0"/>
<TH date="20220112103810" id="th9" temp="23.2" hum="45" dew="10.6" lowbat="0"/>
<AIR date="20220112103748" id="air4" pm="10.2" lowbat="0"/>
<AIR date="20220112103748" id="air5" pm="9.1" lowbat="0"/>
<DATA date="20220112103748" id="data4" val="1274.00" lowbat="0"/>
</logger>

The physical sensors are properly mapped to virtual ones. But I have this output from the template :

AQI.jpg
AQI.jpg (19.99 KiB) Viewed 1141 times
Or may be PM10 is fine ? I have no idea really , so I would ask you for your opinion , and your guide how to fix it , in case it is not the correct value.
I will try to integrate also the data from "data4" , which appear to be the CO2 ppm level, when I have enough experience to do it.

Any tips are appreciated, because I don't even know where to start :)

Many thanks !

Regards,

Victor
User avatar
jasonmfarrow
Gold Boarder
Gold Boarder
Posts: 249
Joined: Mon May 25, 2020 4:21 pm
Contact:

Re: Weather34 Aurora template: PM2.5/10 AQI values calculation question

Post by jasonmfarrow »

There is a function in livedata.php that does the job of converting pm2.5(and pm10) into US AQI values. This function is used in the various PurpleAir/Davis/Lufdaten modules.

Code: Select all

//aqi index conversion to US EPA standard ..take or leave it 
function pm25_to_aqi($pm25)
{
	if ($pm25 > 500.5) {
		$aqi = 500;
	} elseif ($pm25 > 350.5 && $pm25 <= 500.5) {
		$aqi = map($pm25, 350.5, 500.5, 400, 500);
	} elseif ($pm25 > 250.5 && $pm25 <= 350.5) {
		$aqi = map($pm25, 250.5, 350.5, 300, 400);
	} elseif ($pm25 > 150.5 && $pm25 <= 250.5) {
		$aqi = map($pm25, 150.5, 250.5, 200, 300);
	} elseif ($pm25 > 55.5 && $pm25 <= 150.5) {
		$aqi = map($pm25, 55.5, 150.5, 150, 200);
	} elseif ($pm25 > 35.5 && $pm25 <= 55.5) {
		$aqi = map($pm25, 35.5, 55.5, 100, 150);
	} elseif ($pm25 > 12 && $pm25 <= 35.5) {
		$aqi = map($pm25, 12, 35.5, 50, 100);
	} elseif ($pm25 > 0 && $pm25 <= 12) {
		$aqi = map($pm25, 0, 12, 0, 50);
	}
	return $aqi;
}
If this is not suitable to yourself then you'll need to create your own modules and use the pm2.5/pm10 values as required. I have changed mine to use the UK standards which are a bit tighter than the US EPA standards. There are many other countries with their own standards.

You need to consider, before you change anything, what you want to change it to. The PHP logic for warnings and colouring is dependent on these AQI calculations. If you change the calcs to output lower numbers for higher country thresholds then you will have to change the logic to use these new thresholds in the modules you are using (davis/purpleair/luftdaten etc.).

If you can describe your intended outcome then I can help guide you to the changes you'll need to make and the challenges you'll face along the way.
Regards
Jason
https://jmfweather.uk | @jasonmfarrow
HighWay
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Mon Dec 20, 2021 10:24 am

Re: Weather34 Aurora template: PM2.5/10 AQI values calculation question

Post by HighWay »

Hi Jason,

Thank you for the fast reply.

To be honest I found this section in the code yesterday , but was unsure how to interpret it.
Basically I expected to see something like ug/m3 to AQI calculation formula, but I did not found it anywhere / where I searched so far/ .
If I am not wrong, meteobridge sending AIR-Q data as ug/m3 , and there should be a module convert it to AQI . I don't know what is behind the variable "$pm25" for example, and I don't have enough skills to visualize it somehow.
If "$pm25" actually contain the value of meteobridge id="air5" , which is PM2.5 , then it is clear for me. But anyway PM10 is missing in this section, but it is shown in the template output.
I am /currently/ too far from the option to create my own module , but I hope to be able to do it soon. Still learning.

Regards,

Victor
User avatar
jasonmfarrow
Gold Boarder
Gold Boarder
Posts: 249
Joined: Mon May 25, 2020 4:21 pm
Contact:

Re: Weather34 Aurora template: PM2.5/10 AQI values calculation question

Post by jasonmfarrow »

Victor,
The variable $pm25 will contain the input PM value (2.5 or 10) in ug/m3. The function will return the AQI equivalent.

The AQI value will be used in the modules and charts unless you write something different. My AQI uses UK ranges which are based on pm2.5 and pm10 actual values not an arbitrary AQI threshold. See https://jmfweather.uk/ and box 9 - AQI UK. The UK AQI has a 1-10 range which is explained here: https://uk-air.defra.gov.uk/air-pollution/daqi but provides ug/m3 values everywhere else.
Regards
Jason
https://jmfweather.uk | @jasonmfarrow
HighWay
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Mon Dec 20, 2021 10:24 am

Re: Weather34 Aurora template: PM2.5/10 AQI values calculation question

Post by HighWay »

Hi Jason,


Yes , I got your point, and the pm25 variable , so I realized that I was not so clear with the meaning of AQI. I was thinking that is some "linear" value , and it confused me. Thank you for the links now its much clear. I already saw your template from your signature. Looks nice.
Which is still unclear for me how the variable have both values for PM2.5 & 10 . Meteobridge providing two variables as "air4" and "air5" shown here
<AIR date="20220112103748" id="air4" pm="10.2" lowbat="0"/>
<AIR date="20220112103748" id="air5" pm="9.1" lowbat="0"/>

Until PM2.5 /air5/ AQI is correctly shown in the template then PM10 /air4/ still not.
An example : PM2.5 - 12ug/m3 meaning 51 AQI - in the template this value is shown correct. But PM10-13ug/m3 is 12 AQI , but on the template is shown as AQI 52. I need to correct this one.
AQI.jpg
AQI.jpg (20.69 KiB) Viewed 1111 times
In your template I see that values are shown in ug/m3 , but mine is AQI. In your template is much clear for me, and when it will be possible for me I will switch to UK standard , cos it is much clear.

I apologize a lot, most probably I am not able to explain it well, and would appreciate your patience to explain to a noob :)

Regards,
Victor
Post Reply