SuperHouse / AirQualitySensorD1Mini

Particulate Matter Sensor firmware for a Plantower PMS5003 connected to a Wemos D1 Mini
32 stars 10 forks source link

Bug in JSON output #10

Closed rhscdn closed 3 years ago

rhscdn commented 3 years ago

https://github.com/SuperHouse/AirQualitySensorD1Mini/blob/bc870f76fc23bb82215822249da9734e55eb7ff1/AirQualitySensorD1Mini.ino#L520

https://github.com/SuperHouse/AirQualitySensorD1Mini/blob/bc870f76fc23bb82215822249da9734e55eb7ff1/AirQualitySensorD1Mini.ino#L526

In writing to the mqtt buffer whenREPORT_MQTT_JSON=true, you're repeating CF1 instead of CF1, CF2.5, CF10:

sprintf(g_mqtt_message_buffer, "{\"PMS5003\":{\"CF1\":%i,\"CF1\":%i,\"CF1\":%i,...

I believe this should be:

sprintf(g_mqtt_message_buffer, "{\"PMS5003\":{\"CF1\":%i,\"CF2.5\":%i,\"CF10\":%i,...

As you've written it, CF1 is repeated 3 times which means Node-RED can't parse the data.

rhscdn commented 3 years ago

Also an error at: https://github.com/SuperHouse/AirQualitySensorD1Mini/blob/bc870f76fc23bb82215822249da9734e55eb7ff1/AirQualitySensorD1Mini.ino#L523

You've repeated g_pm0p3_ppd_value. It should read: g_pm0p3_ppd_value, g_pm0p5_ppd_value, g_pm1p0_ppd_value,

jonoxer commented 3 years ago

You're absolutely right, in fact I came across the second bug while I was filming the video about datalogging with InfluxDB and Grafana. In the video you can see I reported the PM0.3 and PM0.5 values, and the two plots on the chart are exactly the same! I fixed that bug in my local copy but I need to fix the other bug too and push the changes.

Thanks for prompting me to do it :-)