PDA

View Full Version : Air Quality sensor for $30 (Raspberry Pi)



Bryce Walter
06-29-2020, 1:18 PM
A while back I posted on a temperature/humidity sensor and logging solution I built using a Raspberry Pi.

Since then, I've added a air quality sensor for particulate matter (sawdust) in the shop. Every 3 minutes a sample is taken and is charted. Logging and visualization of the data is here (https://thingspeak.com/channels/905684).

The sensor (https://www.amazon.com/gp/product/B07M9TP393)was $30. I was skeptical about the accuracy of something so cheap. The research (https://pdfs.semanticscholar.org/8dbd/245e7045693aa4858b3638466f17bb946aff.pdf) indicates there is some variation from more expensive air quality monitors, but is good enough for non-scientific use.

On my original temperature/humidity post, a couple folks asked for step-by-steps on getting it configured. My linux skills are pretty basic. I have to go through about 10 trial and errors to get something to work, not really sure of the exact combination of what was necessary. As a result, I won't be able to give step-by-steps, but am happy to answer questions in a bit more detail about what/how I did things.

The sensor is rated for 1 year of active measurement taking. I have it taking measurements once every 3 minutes. It takes about 10 seconds to turn on, measure, and turn-off. With the sensor sleeping the other 170 seconds, my math suggests this will give 18 years of life for the sensor. If I get even 1/10th of that, it will be $30 well spent.


A few of the resources I used:

https://www.raspberrypi.org/blog/monitor-air-quality-with-a-raspberry-pi/
Google: 'sds011 raspberry pi'
Google: 'sds011 pmtwofive'
https://github.com/crotwell/airQuality/blob/master/airquality.py - A starting place for python script for polling the data. Will need to modify it to the right sleep/measurement cycle times as well as what is done with the data (I dump mine to MQTT).



The basics of the solution:

The sensor is plugged in via USB directly to the Raspberry Pi
pmtwofive library to grab the data. Scheduled & executed using shell commands (startup or cron jobs)
python - see sample/starting script above
Data is dumped into MQTT (I was already running a local MQTT --> NodeRed instance locally from the temp/humidity project. The NodeRed does de-deplication and publishes to Thingspeak for visualization)
Thinkspeak for logging, visualization, and access-from-anywhere


Biggest issue I ran into was incompatibility between Python version and the libraries being used due expected data types. I had to be explicit about invoking the right Python version. I think I was accidentally calling python2 when it needed python3.

Again, I'm FAR from being proficient in linux. If you have basic skills, or want to learn, this might be a good project to take on. A raspberry pi runs ~$35-50 if you need to buy one for this. All said, I'm extremely pleased with what I was able to do for < $100, plus some time learning something new (technology).

Larry Frank
06-29-2020, 7:46 PM
I have the cheap sensor and use it at times in my shop. It would be great if someone sold the logging part. I am glad you were able to do this but you completely lost me with the raspberry pi.

Dan Friedrichs
06-29-2020, 10:15 PM
That's really cool! I had no idea such sensors were available, but what a great idea!

David L Morse
06-30-2020, 4:38 AM
Another sensor that is often used is the Plantower PMSx003 series. Larry's unit uses the PMS5003. They're readily available from ebay, Aliexpress, Bangood, etc. The sensor send three channels of PM data and six channels of particle counts. It's accuracy has also been well studied and is good. I have a big collection of sensor reports if anyone is interested. Here's one (https://www.researchgate.net/publication/333891464_PM25_low-cost_sensors_and_calibration_data_for_SDS011_and_P MS7003) that looks at both the PMS7003 and SDS011.

There's a newer version (https://www.aliexpress.com/item/4001030636867.html?spm=a2g0o.productlist.0.0.2bc73 9edW5jGzX&algo_pvid=b950140a-2688-4462-95aa-b8f9bab5812a&algo_expid=b950140a-2688-4462-95aa-b8f9bab5812a-40&btsid=0ab6f82315934238750267835e2644&ws_ab_test=searchweb0_0,searchweb201602_,searchweb 201603_) of Larry's unit that appears to have data logging capability but I don't know much about it.

I have the PMS7003 connected to a NodeMCU which sends data via WiFi.

435937

I really need to put that in a box!

Bryce Walter
06-30-2020, 11:32 AM
David - What do you currently do with the data via Wifi?

I'm considering some different/additional options. One thing I'm leaning towards is after I build/buy an air filter, have it automatically controlled on/off based on air quality readings.

Curious what other people are doing with the data they are pulling...

Thomas Crawford
06-30-2020, 11:38 AM
This is pretty awesome. I think I'll jump into this later this summer. One my daughters has been wanting a programming project to work on with me and this would do it. I'm happy to share code on this if anyone else would be interested.

David L Morse
06-30-2020, 12:40 PM
David - What do you currently do with the data via Wifi?

I'm considering some different/additional options. One thing I'm leaning towards is after I build/buy an air filter, have it automatically controlled on/off based on air quality readings.

Curious what other people are doing with the data they are pulling...

With the NodeMCU controller all I'm doing now is sending the data to a tablet using the Virtuino app. Mostly I just use it as a real time monitor, although the app has primitive data logging capability. I have another version that uses a Particle Photon controller. That one sends data to a Google spreadsheet via the Particle cloud. I don't use that very much right now. When (if?) I come up with a project that needs lots of data stored I'll do some more work with the NodeMCU and send the data to a web server, probably using a GET request.

Controlling an air cleaner would be easy. It certainly wouldn't need the power of a pi. A low end Arduino clone would do fine.

The Virtuino display:

435960

Frank Pratt
06-30-2020, 1:36 PM
So, pardon my stupidness, but will that Zeast sensor you linked to work as a standalone air quality meter with just adding a USB power supply?

David L Morse
06-30-2020, 2:18 PM
Yes, sorry for the confusion. That link is for a complete unit (less power supply). Larry has posted about his nearly identical one several times. You are correct about it only needing a USB power supply for standalone operation.

Other than that though, the rest of the thread is about the sensors only, so, yes, it's a bit more interesting trying to make use of those.

Here's a link to the bare sensor (https://www.aliexpress.com/item/4001039451614.html?spm=a2g0o.productlist.0.0.3d85a e02TGaxZq&algo_pvid=ead470c7-049f-4011-84b9-5db6049f1c9f&algo_expid=ead470c7-049f-4011-84b9-5db6049f1c9f-0&btsid=0be3769015935409130417146ec24d&ws_ab_test=searchweb0_0,searchweb201602_,searchweb 201603_).

Frank Pratt
06-30-2020, 7:16 PM
Yes, sorry for the confusion. That link is for a complete unit (less power supply). Larry has posted about his nearly identical one several times. You are correct about it only needing a USB power supply for standalone operation.

Other than that though, the rest of the thread is about the sensors only, so, yes, it's a bit more interesting trying to make use of those.

Here's a link to the bare sensor (https://www.aliexpress.com/item/4001039451614.html?spm=a2g0o.productlist.0.0.3d85a e02TGaxZq&algo_pvid=ead470c7-049f-4011-84b9-5db6049f1c9f&algo_expid=ead470c7-049f-4011-84b9-5db6049f1c9f-0&btsid=0be3769015935409130417146ec24d&ws_ab_test=searchweb0_0,searchweb201602_,searchweb 201603_).

Thanks for the info David. It sure is an attractive alternative to the Dylos.