davidkreidler / OpenCO2_Sensor

Arduino Repository for an E-Ink CO2 Sensor using ESP32 and SCD4X
https://www.tindie.com/products/davidkreidler/open-co2-sensor/
MIT License
96 stars 5 forks source link

Sensor calibration #9

Closed crener closed 1 year ago

crener commented 1 year ago

Hello, Found this on Tindie and am extremely interested as this is something that I've wanted to build myself.

As I was looking at the sensor documentation to figure out what I would have todo to make it myself (was looking at the SCD41) I saw that there was an api for set_sensor_altitude (datasheet section 3.6.3) and set_ambient_pressure (section 3.6.5) each which calibrates the sensor so that it can perform higher accuracy measurements.

Is this something that is taken into account?

I was looking at the board and didn't see any pressure measurement sensors, for my project I was planning on using BMP384 to get this information... if this is something thats taken into account I would just buy yours on Tindie :)

davidkreidler commented 1 year ago

Hey @crener thanks for reaching out. I take the sensor altitude into account here https://github.com/davidkreidler/OpenCO2_Sensor/blob/main/OpenCO2_Sensor.ino#L200 . By default, it is set to 50 m above NN (because I'm from Berlin). This can be simply changed by you in the code and programmed into the sensor.

Air pressure is an interesting additional point! I I would highly encourage you to build a DIY version with a esp32 development board, a Waveshare 1.54" display, a SCD41 dev board and an air pressure sensor to find out potential benefits of this additional measurement.

In general, the accuracy of the SCD40 is ±(50 ppm + 5% MV) @400-2000 ppm wich is more than enough to determine indoor air Quality (when to open a window). The Open CO2 Sensor also uses automatic self calibration by default to prevent potential long term drift. For this the Sensor needs ambient air exposure once peer week to automatically calibrate itself.

It would also be possible to by the Open CO2 Sensor on Tindie and add an external pressure sensor to the i2c bus here: image

I hope this helps! David

crener commented 1 year ago

I guess it depends how much of an impact this has.

I think if it's noticeable people who use this in a tall building might have issues if the floor they are in is more than X meters above the ground (assuming that the setting is changed in their OpenCO2 unit).

Easy test might be to put two next to each other one with a 50m setting and another with 250m and see if the values are the same over the course of a day? I don't have any hardware on hand to build this (more of a software guy) so would take me a while to get an answer...

ThomasWaldmann commented 1 year ago

Related article: https://gaslab.com/blogs/articles/altitude-compensation-co2-sensors

So it seems like a sensor calibrated at sea level (0m altitude) would display about 1% CO2 too much per additional 100m of altitude at measurement time.

crener commented 1 year ago

Hmm interesting read, for me that level of accuracy is fine with the default but would make this unsuitable for people in mountains who aren't comfortable changing code and compiling to get a better base configuration for their location.

If you live in the Alps your village could be 1500m in elevation which would make all readings quite inaccurate.

Though i don't think anyone expects absolute accuracy from something like this, maybe the buttons on the back could be repurposed for some basic configuration?

davidkreidler commented 1 year ago

Thanks for jumping on this discussion. The tall building measurement idea would be defeated be the accuracy of the scd40 Sensor itself ±(50 ppm + 5% MV). At a 200m Height difference the difference would be 2% according to ThomasWaldmanns commend.

If you live in the Alps the automatic self calibration (ASC) of the SCD40 Sensor by Sensirion (a Swiss company) would do a great job in slowly adjusting to the Height. It needs to be exposed to ambient air. This mode is enabled by default on my OpenCO2 Sensor.

From the Datasheet: "Field Calibration To realize high initial and long-term accuracy, the SCD4x includes two field calibration features. [...] Automatic self-calibration (ASC) ensures highest long-term stability of the SCD4x without the need of manual action steps from the user. The automatic selfcalibration algorithm assumes that the sensor is exposed to the atmospheric CO2 concentration of 400 ppm at least once per week."

ThomasWaldmann commented 3 months ago

Is there a way to calibrate to 430ppm instead of 400ppm?

davidkreidler commented 3 months ago

@ThomasWaldmann currently the calibration via the Menu ->Calibrate is defining the Environment to have 420ppm https://github.com/davidkreidler/OpenCO2_Sensor/blob/v4.4/OpenCO2_Sensor.ino#L435 It can be changed there and then flashed onto the OpenCO2 Sensor.

For the automatic self calibration I sadly don't have the insides to know how the target is changed.

ThomasWaldmann commented 3 months ago

Interesting that it is 420, my devices showed 400 after the calibration process with v4.4 (that's why I asked). Thanks for the pointer to where it can be adjusted.