Hi @nicola.pomaro!
Really nice comments. I will try to answer all your questions step by step.
So, if I switch off the kit and then remove the battery, the latest baseline remains stored and restored when power returns.
Correct, that is the default behaviour.
But what about an abrupt power shut down, like removing the USB cable at kit ON, with battery not connected? Or, with kit ON, removing the battery? In that case, which baseline is restored?
In that case, the latest baseline that was saved, which was before the latest power off event (max 24h).
I understand from sensor datasheet that it takes as baseline the best (higher) resistance detected in a 24 hour interval. It is not clear if this process is repeated every 24 hours, discarding the previous value, or if baseline is updated only if a higher resistance is detected, so that the stored baseline is the “best ever” in the sensor life. Not clear, also, how the long term sensor drift is taken into account, as this would require to renew the baseline even if no better resistance was detected. In any case, in a polluted environment the sensor could never achieve the clean air baseline, and the measured levels would be always underestimated.
These are very good point, and the answers to that are in this application note by ams. The baseline will be calculated not only based on the resistance but also some internal corrections (according to the AN it is related with T, H, but we do not have any control over this). If the result of this is equivalent to a “cleaner” air, the baseline is updated, otherwise it’s kept. If you write the baseline by yourself, then it’s overwritten, ofc.
If one could be able to take the sensor to a clean environment, it could record a good baseline, and this could be maintained, provided that the sensor is properly switched off in clean air and on when back in standard position, or kept on all the time. This could be a way to calibrate the sensor.
Probably, a sort of “calibration procedure”, where the user is able to tell to the system “take this baseline as reference and save it” could be considered. In this case, after an on/off cycle, the restored baseline could be not the latest one but the reference one.
That would be the best. Actually, that is why the reset baseline command is in our to-do list as well. In the same AN as above, this is stated:
The baseline is safe to be read at any timeafter the conditioning period is complete, however it is recommended to read and save the baseline if the user knows the sensor has encountered clean air at any point after the conditioning period. If this is not known it is best practice to read the baseline directly before powering down the system.
Just for the record, pretty much all our knowledge about this sensor, although probably not all what we are talking is here too.
Finally: right now, the default configuration is able to cover the base user scenario, and this more advance setting is planned for more advanced understanding of the sensor. Since you have a quite advanced proposal, even if we already agree with it, why don’t you open up an issue in the firmware repository and we keep track of the implementation there?
Thanks again