Monitoring air quality using Airthings Wave+, InfluxDB and Grafana

Tamas Føldesi
6 min readFeb 24, 2021

For some time, I have been working on my own environment monitoring setup — which was already capable of tracking temperature and humidity across all rooms, as well as controlling the heating to save energy & money.

While I enjoyed checking the metrics from time to time, there was still at least one missing piece of the puzzle — air quality. Since I had no idea what that word actually meant, I did some research about the topic, including the available sensors on the market.

As it turned out, there are multiple quality metrics that one could monitor — beyond the ones that I already had (temperature and humidity) there were three additional ones that seemed interesting:

  • CO₂ concentration— no surprise here, high level of CO₂ is bad, leads to headaches, etc.
  • PM2.5 concentration — PM stands for Particulate Matter, 2.5 means particles that are equal to, or smaller than 2.5 μm in aerodynamic diameter. These have higher impact on human health (than PM10 for example), so tracking their level is important in closed spaces.
  • VOC concentration — Volatile Organic Compounds are various chemicals that contain carbon (except CO and CO₂). These can come from paint, glue, photocopiers, baking oven, children’s toys, and so on — you name it.

Finding the right device was, as always, the main challenge. It had to be relatively small, had to have an interface I can use to download data, and it had to be available in my country.

Finally I decided to buy an Airthings Wave+ device.
It was not capable of measuring PM2.5 concentration, but in exchange I got (another) humidity, temperature, as well as pressure and radon measurements.

Radon concentration is important in areas where the ground contains specific types of stones that emit radon, which in itself is radioactive, and higher concentrations have negative effect on health.
The radon level in my apartment suggested that I don’t have this problem, so at this moment those numbers aren’t so useful after all — but who knows what the future brings…

This device has a bluetooth interface, so as a very first step I could use my phone to connect to it, and see the data:

But, since I had InfluxDB and Grafana from before, I wanted to have these numbers recorded & shown there.

First attempt

The Airthings Wave+ is a device that’s typically used in office & home environments. The keywords was home, so first I tried the designated software I had for smart home control & monitoring — OpenHAB.

Luckily, I thought, OpenHAB had support for this specific device, so it should have been a breeze to configure. In addition, the Raspberry PI running OpenHAB was two meters away from the Airthings device, so no obstacles for this to work, right?

Well, it didn’t work.

OpenHAB wouldn’t recognize my device for what it was. Each time I managed to find it in the Inbox of OpenHAB, it was added as a generic bluetooth device — i.e without channels for any of the metrics.
So perhaps a bit too early, but I stopped trying.

Second attempt

Somehow I suspected that I will need a backup plan.
Part of the reason I chose Airthings was that they seemed developer friendly — on GitHub, they even have a public Python script that reads from Wave+ devices!

It was time to change that script a bit so that it writes to my database, instead of the terminal, or a file. For this, I set up a Python virtual environment — this way I could avoid polluting the system’s Python installation.

Why not Docker?
Well, I tried. However, I could not get it to work with the on-board bluetooth module. There are many articles on the internet that describe how this should work, and I followed all the instructions — but then the script inside the container would just freeze, and would not return.
So then I gave up — virtual environments for Python seemed good enough, especially when you have the requirements saved in a file.

After some trial and error, I found out which packages I would need, so here’s the process to set up the virtual environment, as well as to install the required packages:

Later I created a requirements.txt for the package list.

The original script had the option to write the data to the console, as well as to a file. Also, it was operating in a loop, so it would output the data periodically.
This wasn’t exactly what I needed — since I planned on using Cron to execute the script, it was enough for me to get one reading.

Looking at the logic, it was trying to optimize a bit by querying for available devices only once, and saving some information between two data queries. Those optimizations got thrown out of window by doing only one reading — but premature optimization is the root of all evil, so I didn’t worry about this just yet.

Here’s a snippet showing the updated main logic:

The full code is here.
Finally, this script had to be scheduled via Cron:

At the end I decided to run all this on my home server, instead of the Raspberry PI that was running OpenHAB.
The server is relatively far from the sensor device, with several walls in between, but it works regardless. Impressive performance from Airthings!

Graphs

It was time to find out how the apartment was doing in terms of air quality, so I added a chart that shows the main details from the Airthings Wave+ device:

Measurements from an interesting day reflect quite a lot…

As you can see, the data clearly indicates the level of ventilation (relative to the number of people in the apartment).
This is exactly what I was after!

But what is the normal value for closed spaces, when do I know that I have to open the windows?

Outside air usually has around 400ppm CO₂, so indoors it will be more (as breathing generates CO₂). According to multiple sources, having 1000ppm indoors is adequate air quality; around and above 1500ppm headaches begin.

Here’s another, long-term plot for CO₂:

This shows that the average concentration had been around 600ppm until 7th February, then it jumped up to ~900ppm.
It’s below 1000ppm, so it’s still fine, but what’s up with that jump?

Well, 7th February marks an important milestone (finish line, actually) of the adventure I have been through for the past 4 years — you can read about it here and here.
I still smile when I think about the fact that I had almost open-space air quality, inside an apartment (including winters…).

I had temperature and humidity measurements in the living room from my past projects (this one and this one), so why not add a third one?

The red and purple lines are the new measurements from Airthings. The new sensor is a few meters apart from the other two, so some difference between the readings is expected.

As for the VOC concentration — sometimes I understand why there’s a jump, sometimes I don’t. In average, it seemed okay, as it was under 250ppb:

Short & long term plots. Can you tell when we started making fried fish?

Summary

Airthings Wave+ proved to be a quality device as well as developer-friendly. The only thing I missed was the PM2.5 measurement — although I have no idea how relevant that might be for me (radon, at least, turned out to be irrelevant).

After I had temperature, humidity, pressure, VOC and CO₂ concentration, I was wondering, what else could I measure?

Any suggestions? Let me know!

--

--