
Build an Air Quality Monitor with InfluxDB, Grafana and Docker on a Raspberry Pi - alexandros
https://www.balena.io/blog/build-an-environment-and-air-quality-monitor-with-raspberry-pi/
======
betimsl
Measuring a sensor is so complicated...Influx, Grafana and Docker is not
enough. You may want to throw in AWS, some Google API and not to forget:
Tensorflow. A pinch of opencv with GPU support might make it _real_ software.
Cross compile all this for windows that runs on RPi so corporate clients can
trust it -- because buying a license always reflects seriousness.

~~~
crispyambulance

        > Measuring a sensor is so complicated...
    

I get the sarcasm, but sometimes it is useful to exercise "big boy" tools for
projects that don't need it.

What better way is there to learn/explore these things than with a very simple
project that does something remotely interesting or useful?

~~~
tarsinge
I think on the contrary we need to seriously reconsider these tools that don't
make sense at the scale of the vast majority of projects. It's sad we've gone
full circle to the 00's, didn't miss those Java EE days of real big boy tools.

Edit: current real-life example: I am currently developing a core tool for
helping business users of a big industrial group. Client is amazed I was able
to quickly develop a custom tool to answer their business needs. Code repo: 3
files: one HTML page, one vanilla JS file (less than a thousand lines), one
lib to open XLSX files in JS.

~~~
crispyambulance
Yeah, I remember the bad old days. The most spectacular P.O.S. from those
days, for me, was SOAP. It makes me clench just thinking about it and it's
wildly ironic name "SIMPLE object access protocol." What, like there are even
more complicated protocols to transfer data? FML!

That said, sometimes you need/want to pick up some skills. I think it's good
to do these on tractable problems that one can imagine scaling up smoothly,
like this one. It's better than overly simple "hello world" and also better
than trying to learn from a project where the technology is appropriately
scaled and it would take weeks just to figure out what's going on.

------
zensavona
Probably want to add a PM (particulate matter) sensor to the mix.

I've built a few similar devices using ESP chips and various laser dust
sensors, highly recommend the Plantower PMS5003 - laser defraction, PM1-PM10
accuracy, ~$20 and there are good libraries available on GitHub for
interacting with it.

Edit:
[https://twitter.com/zensavona/status/1091949965306257409](https://twitter.com/zensavona/status/1091949965306257409)

~~~
luma
I'm using a very similar stack! I've built 20 devices using the PMS5003, Spec
Sensors O3 digital gas sensor, and a cheap GPS module connected to an ESP32. 6
have been mounted in the field (more coming soon!). They report sensor
readings via LoRaWAN to a public-facing dashboard visible here:
[https://graqm.org](https://graqm.org)

Devices being tested at an EPA air quality monitoring station:
[https://imgur.com/a/joQvj](https://imgur.com/a/joQvj)

Desktop version: [https://imgur.com/a/yT1IK](https://imgur.com/a/yT1IK)

------
Animats
What's impressive is that you can get a sensor for temperature, air pressure,
"air quality", and humidity for $12.80 in quantity 1. "Air quality" is
strange. It measures volatile organic components, not CO, CO2, or
particulates. Sensors for those cost much more. So this is measuring what's
easy to measure, not what's useful for, say, HVAC control.

8GB and Docker, plus a "cloud" server, seems a bit much.

~~~
TheSpiceIsLife
Assuming I have no idea about these things, which is true—I don’t—how much is
a decent CO2 sensor that can be connected to a Pi or similar setup?

I recently upgraded to double glazed windows in half the house, including all
the bedrooms, and put a heat pump in each of the two used bedrooms. So I want
to keep the windows closed for heat retention, but also want to keep them
slightly open to reduce CO2 build up.

I sleep in my small bedroom with my two 16kg dogs, so it seems reason the CO2
level may rise to suboptimal during the night if the window is shut.

What I would like to do is make a DIY ventilation system that can move fresh,
HEPA filtered, air from outside, in to the room.

Or am I over complicating things? Could I just use a small fan, something
sized to replace, say, half the volume of the room every few hours, and just
leave it constantly on? Or should I put a larger fan on a timer so it runs for
a few minutes every hour?

Does any of this really matter?

Edit to add: any good resources to lose myself down a rabbit hole?

~~~
joshvm
A good CO2 sensor that uses infrared absorption to measure concentration costs
about $100.

[https://www.co2meter.com/collections/co2-sensors](https://www.co2meter.com/collections/co2-sensors)

~~~
TheSpiceIsLife
Thank you

------
wuyishan
A similar, yet completely different project: [https://luftdaten.info/en/home-
en/](https://luftdaten.info/en/home-en/) Can be seen as a "worldwide crowd
sourced air quality measurement projects using cheap DIY sensor/data
collector"

------
Uhhrrr
The Docker part seems thoroughly unnecessary.

~~~
tylerflick
I can't understand why they would add anymore overhead on such a low powered
device.

~~~
Gigablah
What overhead?

"Docker induces no significant overhead on CPU nor memory usage, compared to a
native execution (worse observation: -4%; 0% on all others)" [1]

[1]: [https://roudier.io/2015/08/docker-vs-kvm-vs-native-
performan...](https://roudier.io/2015/08/docker-vs-kvm-vs-native-performance-
comparison/)

~~~
krageon
Think about how the stack works. I'm not saying this measurement is definitely
wrong, but if you're finding exactly 0 overhead then you have to suspect there
is something weird going on with how you're measuring it.

~~~
Gigablah
The processes are still running natively. The most common overheads would be
due to network and storage driver and those can be mitigated with some simple
settings. The Docker daemon is more or less a process supervisor at this
point.

~~~
krageon
I think we have a fundamentally different view of what "natively" means and
what it means to be "more or less a process supervisor". That's fine, but it
also means we won't get to an agreement that we are both at peace with in this
case.

~~~
tinco
What feature of Docker makes you consider it significantly more than a process
supervisor?

------
TheSpiceIsLife
I'm curious to hear from anyone who runs air quality monitors at home: how has
knowledge of the quality of the air in your house affected your behaviour?

My house is 56 years old. I'm guessing the kitchen upgrade is at least 5 years
old. The carpet is probably at least a 5 years old. There isn't much fresh
paint in here.

Am I about right to assume I probably don't have much in the way off off-
gassing from anything in here, or does carpet / furniture / melamine
continually off-gas for it's entire life?

Anyway, I've got some idea that CO2 buildup is a thing, and humidity, and off-
gassing, so... I tend to ventilate the house frequently even during winter.
Even when it's -5 outside, I'll occasionally open one or more windows / doors
and turn the kitchen exhaust fan on in order to draw fresh air in and across
the house. I'll also occasionally open multiple doors / windows for 10 minutes
or so in an effort to replace the majority of the air in the house.

I tend to eschew yet-another-device that needs maintenance / power / charging
/ monitoring / fiddling because I tend to do a lot of that at work and would
rather just come home and not-have-to-maintain-another-97-machines.

So I'm interested in the _on average / sort of good enough / sometimes over-
shoot-the-mark_ behavioural changes that would result _if I did have air
quality monitors_.

~~~
msisk6
We have a new house--about a year old now--here in Texas with all the
efficiency and insulation stuff. I noticed after working in my office with the
door and windows closed I didn't feel so good after awhile.

I got one of those trendy Awair monitors and stuck it on my desk and hooked up
the iPhone app. And sure enough, when I started not feeling well it was
because the CO2 was over 1500 ppm.

I don't know about the accuracy of the actual CO2 measurement, but I figure
the delta is at least good enough to spot trends. And yeah, those times I
don't feel well is always associated with a rise of CO2. I "fix" it by either
opening the door and/or window or running the fan of the central air system.
Our system also has a "bleed air" adjustment for outside air. I turned that up
a bit, too.

The Awair also does "chemicals" and PM2.5. I'm surprised our new house doesn't
an issues with those, but I do see PM2.5 go up when the window in my office is
open and "chemicals" fluctuates throughout the day but at a low level. I'm not
exactly sure what "chemicals" means in this context; I haven't really looked
into it yet.

You might consider the Awair; I've been happy with it. I have several thousand
systems that need tending at work and, same as you, I don't need to come home
and do more. My wife's Windows gaming rig needs enough of that as it is...

------
pookieinc
We've been on the hunt for the most accurate Air Quality Monitor since we've
just moved to the Middle East and have had a really tough time finding
something accurate. Aside from building one and having it receive questionable
ratings, does anyone have any suggestions on a super reliable machine they've
been happy with that has proven its accuracy in some way?

~~~
mike_h
Here’s a lab writeup comparing a few models from about a year ago:

[https://smartairfilters.com/en/blog/are-cheap-particle-
count...](https://smartairfilters.com/en/blog/are-cheap-particle-counters-
accurate/)

Depending on which part of the Middle East you’re in, you may need a PM10
(dust) monitor. The devices here just do PM2.5 (smog).

------
djhworld
Has anyone been running this in the field for a few months/weeks.

I'm wondering how the SD card gets on with the constant writes into InfluxDB
(assuming the samplesa are taken frequently)

~~~
Already__Taken
SD cards fail but they're not a house of cards. I've logged into couch dB
every minute for nearly 5 years. only about a million entries bit since it's
replicated to other nodes a failed card is ok.

------
shawnps
If you're interested in purchasing an air quality monitor, Awair is nice:

[https://getawair.com/](https://getawair.com/)

I learned about it from DHH's talk on air quality:

[https://www.youtube.com/watch?v=MRqh8oLY7Ik](https://www.youtube.com/watch?v=MRqh8oLY7Ik)

~~~
borumpilot
Unfortunately, only shipping to the US & Canada.

~~~
Luc
Did you try [https://getawair.co.uk/](https://getawair.co.uk/) ?

------
bayesian_horse
I'm working on similar things, and at the moment I prefer Redis and Postgres.
Redis just got streams, a bit like Kafka, and Postgres has extensions for
timeseries.

------
gpm
What do people think about the recommended sensor?

Is it reasonably accurate? Are there better alternatives?

~~~
peferron
The sensor doesn't appear to measure particulate matter, so I'd take the air
quality reading with a large grain of salt.

~~~
flo123456
To add on that, if you want to measure particulate matter take an SDS11 and
have a look at [https://luftdaten.info](https://luftdaten.info)

------
bugsense
Ditch Grafana+Influx for Netdata and you are golden :)

~~~
tpxl
Real question, why?

I'm running grafana + influx and it's doing the job well. The netdata git repo
is full of marketing fluff and fails to convince me it's any better.

