Work

Air Quality Monitoring Project

Using an Inexpensive Laser Particle Counter to Measure Air Quality with a Raspberry Pi and MQTT Server.

A graph of air quality over time.

One of my Longest Running Projects

This project I built in 2018 and has been running without downtime for over 4 years. The project uses a Raspberry Pi to collect data from a SDS011 laser particle detector. A python script runs the whole operation which collects the data from the SDS011 sensor and then broadcasts this to the MQTT server. This sensor provides a real-time measurement of the particulate matter in the air. This data is recorded every minute and sent to an MQTT server that I have running on a second Raspberry Pi. Once the data is on the MQTT server, it can be accessed by any device connected to home assistant.

Automating the Data

I have set up a Node-Red flow that listens to the MQTT server and responds to the data. If the air quality is poor, I automatically toggle a smart plug that turns on an air scrubber. For the smart plug I actually found out that the plug uses an ESP8266 microcontroller, so I was able to flash the firmware with an open-source firmware called Tasmota. I did this by opening the plug and soldering wires to the TX and RX pins and shorting the reset pin to ground to get it into flash mode. This allowed me to integrate the smart plug with Home Assistant through my MQTT server.

Why MQTT?

I chose MQTT, why? There’s so many options for distributed IoT communication, but I chose MQTT because it’s lightweight, scalable, and provides low latency. It also doesn’t require me to have static IP addresses for all of my devices. There’s a lot more reasons and I really like the protocol, but I won’t go into it here. However the low latency for MQTT helped with one of my future projects, Flood Leak Sensor is a link to that project.

Software Utilized

Python Raspberry Pi MQTT Home Assistant Node-Red Linux