The sys admin's daily grind – Airsensor
Exactly How Smelly?
If the air in a room smells stale, somebody will get up and open the window to let in some fresh air. Charly, however, wanted to measure its exact staleness, so he set off to find out armed with USB hardware and Linux.
Stale air results from the accumulation of various gases in an enclosed room. Carbon dioxide is the classic case – just imagine 16 people in a small, windowless conference room. Add to this, a mixture of volatile organic compounds, known to the world of science as VOCs. Among other things VOCs are alcohols, volatile deodorant components, aldehydes from furniture, detergent fumes, nicotine, briefly: carbon-based emissions of all kinds.
You could use human noses to sniff VOCs, but sensors in the form of a USB stick are not only more suitable but also immune to attacks of nausea. The Rehau sniffer [1], for example, uses an LED with a color changer to indicate the state of the air in the room.
Pure Air
A tool helps me to read the measured values from the stick. Before you build the software [2], you first need to install the libusb-dev and build-essential packages. After unpacking the zip file to /usr/local/
, the change directory to usb-sensors-linux/trunk/airsensor/
. When you get there, do this:
gcc -o airsensor airsensor.c -lusb
which will compile the small C program, creating an airsensor
binary. When launched, the sensor gives you a new air reading approximately every 10 seconds:
2016-12-09 11:27:26, VOC: 557, RESULT: OK 2016-12-09 11:27:37, VOC: 540, RESULT: OK 2016-12-09 11:27:48 AM, VOC: 542, RESULT: OK 2016-12-09 11:27:59 AM, VOC: 563, RESULT: OK 2016-12-09 11:28:11 AM, VOC: 515, RESULT: OK 2016-12-09 11:28:22 AM, VOC: 505, RESULT: OK
The unit of measurement for the VOC concentration is parts per million (ppm); my sensor is specified for values between 450 and 2000 ppm. It delivers even higher values, but an algorithm has probably interpolated these. For values below 1000 ppm, the built-in LED lights up green, yellow between 1001 and 1500 ppm, and red above that.
Using the -o
parameter, I told the software to output a measured value and then terminate. That makes it easy to write the values to a database as datapoints and draw history graphs. Figure 1 shows what happens when you cook ham and eggs for breakfast.
Charly Kühnast
Charly Kühnast manages Unix systems in the data center in the Lower Rhine region of Germany. His responsibilities include ensuring the security and availability of firewalls and the DMZ.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.