skalnik / aqi-wtf

😷 WTF is the AQI near me right now?!
https://aqi.wtf
MIT License
44 stars 12 forks source link

AQI numbers are dangerously misleading when one of the channels from the sensor is busted. #46

Closed obra closed 4 years ago

obra commented 4 years ago

A friend in Seattle reported that aqi.wtf didn't match purpleair. image image

It appears that this sensor has one "degraded" channel, so it's only getting AQI data from the B sensor. I believe aqi.wtf is doing the wrong thing when averaging the good and bad channels.

The bad sensor is at https://www.purpleair.com/map?opt=1/i/mAQI/a0/cC1&select=20759#13.18/47.5699/-122.39299

Raw sensor data from what purpleair's map is currently seeing is inline below:

{
  "mapVersion": "0.18",
  "baseVersion": "7",
  "mapVersionString": "",
  "results": [
    {
      "ID": 20759,
      "Label": "North Admiral",
      "DEVICE_LOCATIONTYPE": "outside",
      "THINGSPEAK_PRIMARY_ID": "644662",
      "THINGSPEAK_PRIMARY_ID_READ_KEY": "R3BQTJCIEGGCCLW5",
      "THINGSPEAK_SECONDARY_ID": "644665",
      "THINGSPEAK_SECONDARY_ID_READ_KEY": "C9HWY21W209QHQAF",
      "Lat": 47.586074,
      "Lon": -122.383009,
      "PM2_5Value": "0.0",
      "LastSeen": 1599604445,
      "Type": "PMS5003+PMS5003+BME280",
      "Hidden": "false",
      "DEVICE_BRIGHTNESS": "15",
      "DEVICE_HARDWAREDISCOVERED": "2.0+BME280+PMSX003-B+PMSX003-A",
      "Version": "6.01",
      "LastUpdateCheck": 1599601323,
      "Created": 1544041613,
      "Uptime": "540598",
      "RSSI": "-75",
      "Adc": "0.0",
      "p_0_3_um": "0.0",
      "p_0_5_um": "0.0",
      "p_1_0_um": "0.0",
      "p_2_5_um": "0.0",
      "p_5_0_um": "0.0",
      "p_10_0_um": "0.0",
      "pm1_0_cf_1": "0.0",
      "pm2_5_cf_1": "0.0",
      "pm10_0_cf_1": "0.0",
      "pm1_0_atm": "0.0",
      "pm2_5_atm": "0.0",
      "pm10_0_atm": "0.0",
      "isOwner": 0,
      "humidity": "17",
      "temp_f": "81",
      "pressure": "1011.24",
      "AGE": 1,
      "Stats": "{\"v\":0.0,\"v1\":0.0,\"v2\":0.0,\"v3\":0.0,\"v4\":0.0,\"v5\":0.0,\"v6\":0.0,\"pm\":0.0,\"lastModified\":1599604445640,\"timeSinceModified\":119967}"
    },
    {
      "ID": 20760,
      "ParentID": 20759,
      "Label": "North Admiral B",
      "THINGSPEAK_PRIMARY_ID": "644666",
      "THINGSPEAK_PRIMARY_ID_READ_KEY": "KQZOSQYCSX6TN5HK",
      "THINGSPEAK_SECONDARY_ID": "644667",
      "THINGSPEAK_SECONDARY_ID_READ_KEY": "TFLYCY302WYLGZHH",
      "Lat": 47.586074,
      "Lon": -122.383009,
      "PM2_5Value": "53.98",
      "LastSeen": 1599604445,
      "Hidden": "false",
      "Created": 1544041613,
      "Adc": "0.00",
      "p_0_3_um": "10503.0",
      "p_0_5_um": "3068.66",
      "p_1_0_um": "386.09",
      "p_2_5_um": "24.43",
      "p_5_0_um": "5.84",
      "p_10_0_um": "0.39",
      "pm1_0_cf_1": "61.27",
      "pm2_5_cf_1": "81.91",
      "pm10_0_cf_1": "85.59",
      "pm1_0_atm": "40.12",
      "pm2_5_atm": "53.98",
      "pm10_0_atm": "66.71",
      "isOwner": 0,
      "AGE": 1,
      "Stats": "{\"v\":53.98,\"v1\":54.53,\"v2\":54.97,\"v3\":56.62,\"v4\":55.3,\"v5\":29.27,\"v6\":9.6,\"pm\":53.98,\"lastModified\":1599604445641,\"timeSinceModified\":119967}"
    }
  ]
}
skalnik commented 4 years ago

Ooh, yeah this is definitely a problem. I reformatted that JSON a bit nicer and nothing jumps out as easy to detect as "degraded" other than all of the pm_n_n values being 0.

skalnik commented 4 years ago

Maybe it's worth ignoring the overall PM2_5 value from a sensor if it's out of a specific range or if it's 0 and the other value is more than like 3 away?

obra commented 4 years ago

I mean, I think that if one of the sensors is zeroed out and the other sensor is not, we should probably just ignore that sensor

On Sep 8, 2020, at 6:15 PM, Mike Skalnik notifications@github.com wrote:

 Ooh, yeah this is definitely a problem. I reformatted that JSON a bit nicer and nothing jumps out as easy to detect as "degraded" other than all of the pm_n_n values being 0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

obra commented 4 years ago

End-user reports that the new code appears to work. (Though comments that the color scheme doesn't seem to match PA)

skalnik commented 4 years ago

(Though comments that the color scheme doesn't seem to match PA)

Yeah I think this is tracked over in https://github.com/skalnik/aqi-wtf/issues/5. PA does a nice gradient adjustment of the color, where as we just have the one specific color per level.