-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of reading and writing baseline #22
Comments
I remembered that I added that code upon request, and that somebody tested it and said it worked. I looked up who said that, it's you 😉. I don't have code, but indeed it would be good to have it in some example. Volunteers? |
Yes, I remember that. Maybe someone did it and share their code. |
I found some time and made an example based on https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/blob/master/examples/Example4_SetBaseline/Example4_SetBaseline.ino To make it work, I changed the
My example code for ESP32 (I did not test it on ESP8266!) for loading, saving and deleting a baseline: https://pastebin.com/KGigYPr6 |
Hello,
|
Can you post a valid code for ESP8266? And more precisely what needs to be changed in the library to work because the above example gives error. |
I'm not sure what you want to see. This is how a main program could be structured
Then you would need two helpers handle_baseline_for_power_on/off.
This code is not even tested on syntax ... |
I had the impression baseline register can't be written, thats why Google brought me here. If you restore a baseline calibration value which would lead to no detection of TVOC internal calibration method adjusts baseline calibration register and so it seems your write to the baseline calibration was unsuccessful. I hope the automatic baseline calibration won't change or adjust this value that after 24 hours the lowest measured TVOC measurement is set as baseline for 0 TVOC / 400 ppm eCO2. Reading the section about automatic calibration could mean this. If so you have to monitor baseline register and write back your value from clean outside air. If you don't write the baseline calibration register CCS811 adjusts its internal correction after each startup to 0 TVOC / 400 ppm eCO2. For long running sensors after the first 500 hours manual recommends saving baseline every 5-7 days. So to get a tradeoff between reliable values and comfort I would put it to fresh outside air once month. Please note that just opening a window can take hours to have really fresh like outside air inside. I've seen this with CO2 sensors. This strongly depends on the position of the sensor inside the room and how wide you open the window. But at cold temperatures outside you lose significant amount of energy until air has really outside quality. Update: Sensor also adjusts baseline if measured TVOC get too high. So it doesn't just clip and show maximum value until TVOC went down again but instead it adjusts baseline calibration to show again a TVOC value. However because of baseline adjustment you can't compare it with previous values. |
I'm experimenting with this library and sensor's baseline for quite a while now. I'm getting some problems setting the correct baseline. This leads me to the main question - how to properly get the baseline? Do I need to wait for warmer weather and then take it outside to get proper baseline? Should I somehow get clean air indoors at room tempertures? Are there any general guidelines to get proper baseline? |
The MoX sensor has a resistance depending on the gases in the air. The cleaner the air the lower the resistance. Unfortunately, this relation is not stable in time (resistance changes due to what happened in the past). So what the firmware of a MoX sensor does is record the lowest resistance it has seen - the cleanest air. Let's call this R0. When you perform a measurement, the sensor measures the current resistance, let's call it Rc, and it roughly outputs Rc/R0; this is called eqTVOC. The problem is, that the sensor resistance for clean air changes in time, so the sensor needs to adapt R0. The firmware has algorithms to adapt R0 on a daily basis (24 hour cycle). The R0 is called the "baseline". As noted above, R0 is maintained by the sensor as long as it is powered. Once the sensor is switched off, R0 is lost. After a new power on, it takes some time before a good R0 is determined by the sensor. What the chip supports is baseline backup and restore. You can execute x=get_baseline () before you switch off, and set_baseline(x) after you switch on. Make sure that the x=get_baseline() is executed when the chip actually has a good baseline, so it must have run long enough. Also, execute set_baseline(x) after power on and a delay to wait that the sensor is stable otherwise the written baseline might be overwritten by not-yet-correct Rc (unstable MoX) by the firmware. Read the datasheet (and separate app note https://www.sciosense.com/wp-content/uploads/documents/Application-Note-Baseline-Save-and-Restore-on-CCS811.pdf) for details on when to do this exactly Putting it outside does not seem wise: 1) the baseline is constantly adjusted, 2) R0 is now for outside and Rc for inside, so Rc/R0 has a mismatch, 3) ccs811 is in indoor air quality sensor. Yes humidity and temperature are relevant, so measure them and feed them (use the appropriate function, and take care of the units). |
Hi, is there an example of a code with read and write baseline somewhere?
The text was updated successfully, but these errors were encountered: