If you are refering to this line:

`if ($pm10 + $pm102 < "1.0") {`

$pm10val = round(($pm10 + $pm102)/2,2);

} else {

$pm10val = round(($pm10 + $pm102)/2,0);

}

} else {

...

$pm10val = round(($pm10 + $pm102)/2,0);

Then no, it is supposed to be there. The first two in the if block are for the decimal ON, deciding whether it's less than 1 or not, and the 3rd one under the else block is for when the decimal option is OFF. All the ,0 and ,2 do is tell it how many decimal places to use.

If the PM10 ug/m3 level is below 0 (ex. 0.35), it's just going to show 0 like it always did. That's why

I added the option to show the decimal place. Some people may want to see it others don't.

I'd like to know what your PM10 value is when this problem is happening from both your sensor and what it shows.

weatherbee - Consider that the sensor is providing a particle ug/m3 reading instantaneous.

From all appearances, it appears Purpleair is using the 24hr formula for an instantaneous read on the PM 2.5 AQI according to published tables for the math, and I also tested it with the EPA calculator for PM10.

If you want to, I personally am, but do not want to add it to the script because I am unsure if it is correct, here is the code I came up with:

`function aqiFromPM10 ($pm10num) {`

if (is_nan($pm10num)) {

return "-";

}

if (isset($pm10num) == false) {

return "Error: No value";

}

if ($pm10num < 0.0) {

return $pm10num;

}

if ($pm10num > 1000.0) {

return "Polluted beyond belief";

}

if ($pm10num > 505) {

return calcAQI($pm10num, 500.0, 401.0, 604.0, 505.0);

} else if ($pm10num > 425) {

return calcAQI($pm10num, 400.0, 301.0, 504.0, 425.0);

} else if ($pm10num > 355) {

return calcAQI($pm10num, 300.0, 201.0, 424.0, 355.0);

} else if ($pm10num > 255) {

return calcAQI($pm10num, 200.0, 151.0, 354.0, 255.0);

} else if ($pm10num > 155) {

return calcAQI($pm10num, 150.0, 101.0, 254.0, 155.0);

} else if ($pm10num > 55) {

return calcAQI($pm10num, 100.0, 51.0, 154.0, 55.0);

} else if ($pm10num >= 0.0) {

return calcAQI($pm10num, 50.0, 0.0, 54.0, 0.0);

} else {

return "-";

}

}

and also

`function GetPPMLevel($pmlevel, $pmtype)`

{

if ($pmtype = "PM25") {

if ($pmlevel <= 30) {

return "LOW";

} else if ($pmlevel >=30) {

return "MODERATE";

} else if ($pmlevel >=70) {

return "HIGH";

} else if ($pmlevel >=200) {

return "VERY HIGH";

} else if ($pmlevel > 500) {

return "EXTREME";

} else {

return "UNKNOWN";

}

} elseif ($pmtype = "PM10") {

if ($type = "PM10") {

if ($pmlevel <= 54) {

return "LOW";

} else if ($pmlevel >=55) {

return "MODERATE";

} else if ($pmlevel >=155) {

return "HIGH";

} else if ($pmlevel >=255) {

return "VERY HIGH";

} else if ($pmlevel >= 355) {

return "EXTREME";

} else {

return "UNKNOWN";

}

}

}

}

When using that and Purpleair's existing code, the values mirror exactly the EPA calc's. So if you think it's correct, I'll add it, otherwise I'll leave it out.