Self-configuring sensors self-configure, and that’s a problem

Posted by on Dec 7, 2021 in Design, Environmental | No Comments

Little backstory on the sensorBox project.  Things were going well until early in the Summer when the sensors threw out what I’d call garbage data.  CO2 levels so high I should have headaches on a day whet the windows were all open is when I thought, “maybe I’m getting exactly what I’m paying for: sensors where the low price reflects that are disposable/replaceable”.

I worked on some other projects, did a little more research, and learned something about the CCS811, not well documented, if at all:

It continually self-configures.

The docs are pretty spare, but it’s clear that you calibrate by reading the baseline in a stable, normal CO2 environment; store it somewhere permanent; then use that value to set the baseline when you launch your code.  That works pretty good when you’re launching the code at least once a day or several times a week — you’re repeatedly resetting the baseline.

What if you let it run for weeks without resetting?  It can reset the baseline in an high CO2 environment and now all the readings are off.

Here’s how I started figuring things out — I started doing a get_baseline() every hour and logging it in the events file.  Here’s the event log for one night when I baked a potato in a gas oven using my sensorBox in the kitchen.  Entries starting with a comment (“#”) are automatic, the rest I did using the tool.  The baseline is clearly wandering in a kitchen where I’m not doing anything, then gets worse when I start using my gas oven in convection mode.

$ more kitchen-events-2021-11-12.log
#boot time 2021-10-31 14:25:09
#description of event
1636693203,#baseline at day rollover 48713
1636693203,#baseline 60 min read 48713
1636696812,#baseline 60 min read 48713
1636700421,#baseline 60 min read 48713
1636704031,#baseline 60 min read 48713
1636707640,#baseline 60 min read 48713
1636711250,#baseline 60 min read 48713
1636714859,#baseline 60 min read 48713
1636718408,#baseline 60 min read 48691
1636722017,#baseline 60 min read 48670
1636725627,#baseline 60 min read 48670
1636729236,#baseline 60 min read 48670
1636732845,#baseline 60 min read 48655
1636736455,#baseline 60 min read 48655
1636740004,#baseline 60 min read 48655
1636743613,#baseline 60 min read 48630
1636747223,#baseline 60 min read 48572
1636750831,#baseline 60 min read 48572
1636754438,#baseline 60 min read 48572
1636758046,#baseline 60 min read 48572
1636761654,#baseline 60 min read 48572
1636763990,set oven to 350F
1636764253,turned on kitchen exhaust fan
1636764904,oven to 350 convection
1636765162,added potato
1636765201,#baseline 60 min read 48531
1636768811,#baseline 60 min read 48416
1636769479,remove potato from oven, turn off oven
1636772420,#baseline 60 min read 48416
1636772792,CO2 and tVOC aren’t dropping, forcing a restart
1636772797, started at 2021-11-12 22:06:37.084918
#boot time 2021-10-31 14:25:09
#description of event
1636772798,#baseline at day rollover 48713
1636772985,turned off exhaust fan
1636776046,#baseline 60 min read 48717

Here’s a simple graph, you can see at the end where things go wonky as the self-configured baseline self-configures in a high CO2 environment:

kitchen log with sensor errors

It took some iterations and checking the baseline and it turns out it’s best to reset it every ten minutes.

Here’s me baking another potato but resetting it every ten minutes:

kitchen log with baseline fix

Here’s a clip from the event log with debug logging and how often the baseline changes while I’m using the oven.  It changes once while the oven is preheating, then nine more times while the potato is baking.  Each of those times is a self-calibration *changing* the baseline.  Since I can only read the sensors once a minute, resetting every ten minutes seems like a decent adjustment.

1638830503,set oven to 350F convection
1638831035,#baseline 10 min read 48635
1638831035,#baseline 48635 does not match baseValue 48713, resetting
1638831132,put potato in oven
1638831637,#baseline 10 min read 48654
1638831637,#baseline 48654 does not match baseValue 48713, resetting
1638832238,#baseline 10 min read 48452
1638832238,#baseline 48452 does not match baseValue 48713, resetting
1638832840,#baseline 10 min read 48324
1638832840,#baseline 48324 does not match baseValue 48713, resetting
1638833441,#baseline 10 min read 48226
1638833441,#baseline 48226 does not match baseValue 48713, resetting
1638834042,#baseline 10 min read 48168
1638834042,#baseline 48168 does not match baseValue 48713, resetting
1638834644,#baseline 10 min read 48093
1638834644,#baseline 48093 does not match baseValue 48713, resetting
1638835246,#baseline 10 min read 48072
1638835246,#baseline 48072 does not match baseValue 48713, resetting
1638835623,turned on exhaust fan in kitchen
1638835686,opened oven to check potato temp
1638835847,#baseline 10 min read 48062
1638835847,#baseline 48062 does not match baseValue 48713, resetting
1638836142,opened oven to check potato temp
1638836449,#baseline 10 min read 48098
1638836449,#baseline 48098 does not match baseValue 48713, resetting
1638836509,opened oven to check potato temp
1638836556,0ven off
1638836565,took potato out of oven
1638837050,#baseline 10 min read 48260
1638837050,#baseline 48260 does not match baseValue 48713, resetting
1638837651,#baseline 10 min read 48713
1638838253,#baseline 10 min read 48713


« | »

Leave a Reply