Hello!

Since the air quality is only shown as the resistance from the sensor, would it be possible to combine the sensor readings of humidity and resistance to calculate the AQI?

On another forum someone has posted you can calculate it through this function:

log(resistance) + 0.04*log(resistance) / humidity * humidity

According to the docs you can add functions through math when creating a query and it does support logarithmic calculations and combining different sources and queries.

I just have no clue how to do it…

Even if this is just a rough estimate for the AQI it would still be better than just the raw resistance reading!

Thanks for helping!

Mathias

Hello Mathias, indeed you should be able to add that function to one of the Grafana dashboards in balenaSense. The easiest way would likely be to make a copy of the existing default dashboard and then modify the copy’s SQL to include your function. If you check out our blog at Balena.io Blog for the post “balenaSense v2: Updated temperature, pressure, and humidity monitoring for Raspberry Pi” You’ll see a section called “Aggregate your data from multiple devices and sensors” that includes the steps for copying and modifying a dashboard. You’ll need to experiment a bit with the Grafana math functions but this should get you started. Let us know how it goes!

Unfortunately I just can’t get it to work. I can set it up to show data from different sensors in one graph, I just can’t get the math function to work.

I think my problem is proper syntax.

Starting in a more simple way, how would I go about making a graph that shows something like humidity + resistance? So simply adding the values from the two sensors and showing that as a graph. What would be the proper syntax for that? If I can figure that out I could go from there.

To add humidity and resistance, I would use the following syntax: `SELECT "humidity" + "resistance" FROM "mqtt_consumer" WHERE $timeFilter`

and for the AQI function you mentioned, I would use: `SELECT log("resistance", 10) + 0.04 * log("resistance", 10) / "humidity" FROM "mqtt_consumer" WHERE $timeFilter`

(assuming you want the common logarithm base 10.) Let us know if you get accurate air quality readings with this method!

Sorry for the late reply, I was occupied with something else for the last few weeks.

But that did the trick. It’s working now. Thank you very much!

Glad to hear that worked for you @mathiasa