kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.94k stars 492 forks source link

Solution to Issue #1234 #1236

Closed gngenius02 closed 1 year ago

gngenius02 commented 1 year ago

Change argument passed to force_calibration method from float to int. The library is expecting an int as can be seen here: https://github.com/adafruit/Adafruit_CircuitPython_SCD4X/blob/a9ae07d8c30c45e7a36d5308bdaaa2887c3c7e31/adafruit_scd4x.py#L161

This fix restarts the device so that it automatically starts working without needing to deactivate and activate after force calibrating CO2.

NOTE: The adafruit library calls sensor.stop_periodic_measurement() at the begining of the function but never calls sensor.start_periodic_measurement() after it submits the calibration.

kizniche commented 1 year ago

Thanks for the PR. Perhaps also add that the sensor needs to be active for at least 3 minutes prior to calibrating, per:

https://github.com/adafruit/Adafruit_CircuitPython_SCD4X/blob/a9ae07d8c30c45e7a36d5308bdaaa2887c3c7e31/adafruit_scd4x.py#L169-L172