Go Down

Topic: [Project] Air Quality Logger: CO2, Fine Dust, Temperature & Humidity (Read 2005 times) previous topic - next topic

drsnugglesja

Feb 07, 2020, 07:01 pm Last Edit: May 23, 2020, 09:06 pm by drsnugglesja Reason: Added fine dust sensor
How good is the air quality? Is there enough ventilation in my living room, bedroom or car?

These were the questions I had. Especially regarding the carbon dioxide (CO2) level at home. It could effect my sleeping comfort. A commercial device for just measuring CO2 costs around 300 euro/dollar, so I decided to make my own. This post is to share my experience, setup and code, since I used a lot of free libraries as well. In v2 I added a pms7003 fine dust sensor, to see if the air is polluted.

Learning goals: learn about the ESP8266, wifi and networking, FTP, Oled, I2C, Uart, webservers, 3D design and 3D printing and get up to date again with the Arduino IDE, which has improved quite a lot!

This is it:














Features:
  • CO2 measurement, up to 10,000ppm and automatic range scaling
  • Temperature, humidity and pressure measurments.
  • Fine dust measurements, both PM2.5 and PM10 ug/m3.
  • OLED display, to present results
  • Wifi connection
  • Automatic time set for each measurements, from NTP server.
  • Webserver, to see results in one single graph, optimized for normal and dark theme browers.
  • CSV file with results uploaded to FTP server


My experience developing this device was very nice. I had lots of fun finding a good library, try out the examples and putting it all together, both hard- and software. Some things took me a bit more time to figure out: I2C noise from the display wires does influence the Uart wires of the CO2 sensor, resulting in bad reading sometimes: a re-read fixes it, but proper cables with shielding should fix it as well. Getting a proper FTP library took me some time as well, so I included all libraries I used below. Included is a link to the enclosure I designed as well. It's a simple one with lots of air vents. You can 3D print it or modify it to your needs.

Use case:
  • Use at home, connect to regular wifi and upload results to FTP. Check results by phone browser.
  • Use in the car or in the office, connect to wifi hotspot of phone. No FTP upload, but results can be checked in the browser.


Hardware


Sources


Libraries used:

Thanks to everyone who created all these great examples and libraries!

On a side note: this project can also be done in microPython. I tried it after finishing the c++ implementation. I was positively surprised by the design speed. There is only one catch so far: you need to rewrite an existing MH-Z19 library from python or C++ to micropython. All other libraries can easily be found online.

I hope I inspired someone with this device. Thanks for reading :).


richa1510

Nice project.
Have a look at the sensirion SCD30 sensor. I used a lolin d1 mini pro too. I used the ESP8266 DeepSleep function to but the board to sleep to preserve battery power and woke it up every 20 minutes to take a reading.


drsnugglesja

Nice project.
Have a look at the sensirion SCD30 sensor. I used a lolin d1 mini pro too. I used the ESP8266 DeepSleep function to but the board to sleep to preserve battery power and woke it up every 20 minutes to take a reading.
Sounds good! Lets share some experiences: how does the SCD30 sensor perform? Is it accurate and precise enough to check indoor CO2?

And what did you use it for: check CO2 indoors as well?

authgabor

How good is the air quality? Is there enough ventilation in my living room, bedroom or car?
Similar project here! With dust sensor and VOC gas sensor, without CO2 and display... :)



Open source everything: https://github.com/IoTGuruLive/dust_box
Live example: https://iotguru.cloud/field/srcPlk78rcpgCgCgKWcR6g/gas
Details: https://www.facebook.com/IoTGuruLive/posts/1072809553055971
https://iotguru.cloud - the IoT backend company

authgabor

Sounds good! Lets share some experiences: how does the SCD30 sensor perform? Is it accurate and precise enough to check indoor CO2? And what did you use it for: check CO2 indoors as well?
I am more interested in how this can be done?

"Sensirion recommends 7 days of continuous readings with at least 1 hour a day of 'fresh air' for self-calibration to complete."
https://iotguru.cloud - the IoT backend company

drsnugglesja

#5
Feb 13, 2020, 09:59 pm Last Edit: Feb 13, 2020, 10:02 pm by drsnugglesja
Similar project here! With dust sensor and VOC gas sensor, without CO2 and display... :)



Open source everything: https://github.com/IoTGuruLive/dust_box
Live example: https://iotguru.cloud/field/srcPlk78rcpgCgCgKWcR6g/gas
Details: https://www.facebook.com/IoTGuruLive/posts/1072809553055971
That looks like a proper project for measuring polution. I am looking for a dust sensor as well to measure PM2.5 from cars, if I manage to fit it in the box. Why did you choose the SDS011?

A nice sensor overview is given here: http://aqicn.org/sensor/ but cant see any conclusion.

authgabor

That looks like a proper project for measuring polution.
It is. :)

I am looking for a dust sensor as well to measure PM2.5 from cars, if I manage to fit it in the box. Why did you choose the SDS011?
Based on the LuftDaten project R&D: https://luftdaten.info/messgenauigkeit/

A nice sensor overview is given here: http://aqicn.org/sensor/ but cant see any conclusion.
It is an interesting page, thank you! :)
https://iotguru.cloud - the IoT backend company

drsnugglesja

#7
Feb 14, 2020, 10:43 pm Last Edit: Feb 14, 2020, 11:45 pm by drsnugglesja
Based on the LuftDaten project R&D: https://luftdaten.info/messgenauigkeit/
Wow, didn't know there was that much research already done for these sensors. Thanks to website you mentioned, I got to this github site, and this comparison. The SDS11 seems to be a really good one, if you correct for humidity like you do in your code.

I'll go for the PMS7003, since it seems to have less issues with humidity (70 to 90% where I live!). I'll use the correction y(ppm reality) = a⁎x(ppm measured) + b, where a = 0.29 as mentioned in the comparison. The sensor is also a bit smaller, so I might be able to sneek it in the box I already made :).

Talking about humidity correction: what was the reason you use this formula if I may ask?
Code: [Select]
pm.pm25 = pm.pm25 / (1.0 + 0.48756 * pow((humidity / 100.0), 8.60068));
The document describing the comparison found this correction:
Quote
Data: RH ≤ 80% (n = 1824)
Fitted curve: y = a⁎x + b (a = 0.47; b = 5.08)
Data: 80% < RH ≤ 90% (n = 1482)
Fitted curve: y = a⁎x + b (a = 0.41; b = 3.32)
Data: RH > 90% (n = 425)
Fitted curve: y = a⁎x + b (a = 0.37; b = 2.63)
Another annoying thing I see is the effect of a self-heating BME280. Apparently it is normal to have an offset of around 2 degrees Celcius, even if you put the sensor to sleep and run it in Force mode. But the offset will be bigger if it is colder.

drsnugglesja

#8
May 23, 2020, 08:55 pm Last Edit: May 23, 2020, 09:04 pm by drsnugglesja
Finished V2 with an additional fine dust sensor. I used it on the highway to see how the air quality is. It was pretty ok in the car, the worst was actually the BBQ pollution before entering the car!

Below are some photos and screenshots of the results.

In the beginning you see the effect on the dust levels (purple and light blue) of the BBQ. During the trip you see the effect of the air-conditioning on the humidity (yellow), which I turn off at the end. Surprisingly the CO2 level (dark blue) is perfect during the whole drive.



Air intake for the fine dust sensor.


Added to version 2 is also the ability to correct the temperature due to self heat (now 4 degrees Celsius) and the humidity which was too low due to the incorrect temperature. For correct measurements I would suggest a fan on the BME280.

I didn't correct the results of the PMS7003. I read scientific reports it underreported dust levels, overreported dust levels and that it results were similar to a high end measurement system. My conclusion: it depends a lot on the fine dust reference device and type of fine dust (sea salt or carbon dust). I use it as a precise but inaccurate device. Feel free to add your own correction.

AmphenolSensors

Nice project, could have saved a bit of time and used our sensor evaluation kit (AAS-AQS-UNO-RH-CO2), does dust, CO2, Hum & Temp, albeit doesn't do the FTP and web publishing you've achieved on your project.

Dust measurement in principle is easy, in practice quite difficult. The main reason behind this is the methodology used to measure the dust, mie light scattering; as dust particle refract light differently dependent upon their respective make up, type, and moisture content. The effect of humidity largely effects organic, rather than mineral based dust. And just to add to problems the reference sensors dry the dust. Add to the fact no two manufacturers use the same algorithms to translate the pulse counts, and you begin to see why dust sensors from diferent manufacturers rarely agree!

CO2 sensors should use Non-dispersive infra red (NDIR) principles, the VOC based values are estimates based on the VOC level, and commercial modules are more than good enough to measure residential variances.

Most ASIC based sensors self heat, we calibrate ours based on use type and voltage to overcome the offset, however we can't compensate for pick up within an enclosure. There is a reason most humidity sensors are thermally isolated from main PCBs! 1°C difference = 2.5~3% of humidity offset.

In all such projects we must remember that although the sensor looks like a chip, it isn't, and it has physical needs not just electronic ones, we come across the phenomena regularly in the professional world too where developers forget!


gerrikoio

You should add your project to the Arduino Project Hub.

drsnugglesja

Nice project, could have saved a bit of time and used our sensor evaluation kit (AAS-AQS-UNO-RH-CO2), does dust, CO2, Hum & Temp, albeit doesn't do the FTP and web publishing you've achieved on your project.
Thanks, this kit looks very interesting. This kit plus an esp8266/esp32 would make the FTP + webserver working as well. The price is perfect for companies, but quite a lot for home brew though.

Dust measurement in principle is easy, in practice quite difficult. The main reason behind this is the methodology used to measure the dust, mie light scattering; as dust particle refract light differently dependent upon their respective make up, type, and moisture content. The effect of humidity largely effects organic, rather than mineral based dust. And just to add to problems the reference sensors dry the dust. Add to the fact no two manufacturers use the same algorithms to translate the pulse counts, and you begin to see why dust sensors from diferent manufacturers rarely agree!
That explains the contradictory papers you can find about sensor comparison. I found it a bit weird to see researchers find linear fits in their data, after which they claim an R^2 of 0.97 for their fit. If I understand your explaination properly, the fit might be correct, for a certain sensor, a certain humidity and a certain type of dust.

CO2 sensors should use Non-dispersive infra red (NDIR) principles, the VOC based values are estimates based on the VOC level, and commercial modules are more than good enough to measure residential variances.
That means the MH-Z19B is using the correct technique. I quite like the results coming from it, as long as you disable the autocalibration.

Most ASIC based sensors self heat, we calibrate ours based on use type and voltage to overcome the offset, however we can't compensate for pick up within an enclosure. There is a reason most humidity sensors are thermally isolated from main PCBs! 1°C difference = 2.5~3% of humidity offset.
Makes a lot of sense. I actually used the emperical fit of the saturated vapor density vs temperature, to correct the humidity. 4 degrees offset from room temperature gives around 20% less relative humidity than there is in reality using this formula. It matches the humidity of the nearby weather stations. Would you recommend another formula?

In all such projects we must remember that although the sensor looks like a chip, it isn't, and it has physical needs not just electronic ones, we come across the phenomena regularly in the professional world too where developers forget!
Very true. Thanks for your elaborate reply! Very nice to get this in-depth feedback.

drsnugglesja

You should add your project to the Arduino Project Hub.
Good idea. I might do that if I find some spare time. Thanks.

Go Up