Hey everyone, I wanted to share my recent experience with setting up a PM2.5 sensor and automating air quality alerts in my home. It’s been a bit of a journey, but I’ve learned a lot along the way!
The Setup
I recently acquired a Seeed Grove Laser PM2.5 sensor to monitor air quality in my living room. The sensor was working perfectly for months, providing accurate readings that I could track in my openHAB setup. However, after a few bumps and some harsh treatment, the sensor started acting up. Instead of giving consistent readings, it would show values like 0, 1, or 2 for PM1.0, PM2.5, and PM10.0, even when there was smoke nearby. I knew something was wrong, but I wasn’t sure where to start troubleshooting.
The Investigation
I started by checking the connections. The sensor was soldered onto a Grove base shield, so I resoldered all the connections to ensure a solid electrical connection. I also tried switching the power supply from 3.3V to 5V, as sometimes voltage fluctuations can cause issues. Unfortunately, the problem persisted.
Next, I looked into the configuration. I had the sensor set up with the seeed_xiao_esp32c3 board config, but I wasn’t sure if that was the right choice. I tried switching to a different board config, but that didn’t help either. I also checked the digital pins to ensure they were correctly assigned, but everything seemed fine on that front.
The Solution
After some research, I discovered that the sensor’s firmware might need updating. I wasn’t sure how to do that, but I found a helpful guide on the Seeed Studio forums that walked me through the process. I used the Arduino IDE to upload the latest firmware to the sensor, and after a few restarts, it started working again!
Automating Alerts
Now that the sensor is working, I wanted to take it a step further by automating air quality alerts. I set up a simple JavaScript rule in openHAB that triggers when the PM2.5 levels exceed a certain threshold. Here’s the code I used:
javascript
import { rules, triggers } = require(‘openhab’);
rules.JSRule({
name: “AirQualityAlert”,
description: “Sends an alert when PM2.5 levels are too high”,
triggers: [
triggers.GenericCronTrigger(“0/5 * * * * ? *”)
],
execute: function(event) {
var pm25 = parseFloat(openhab.getState(‘sensor.pm25’).state);
if (pm25 > 50) {
openhab.sendCommand(‘notification.alert’, ‘Air Quality Warning: PM2.5 levels are above 50!’);
}
}
});
This rule checks the PM2.5 levels every 5 minutes and sends a notification if they exceed 50. It’s been working perfectly, and I feel much more confident about the air quality in my home now.
Tips for Others
If you’re having trouble with your PM2.5 sensor, here are a few tips:
- Check the connections and resolder if necessary.
- Ensure the sensor is running on the correct voltage.
- Update the firmware if possible.
- Test the sensor in a different environment to rule out external factors.
I hope this helps someone else who’s struggling with a similar issue. Happy automating! ![]()