diff --git a/AHT20_sensor_control/AHT20_sensor_wrapper.py b/AHT20_sensor_control/AHT20_sensor_wrapper.py index d2cba50..47e2a5b 100644 --- a/AHT20_sensor_control/AHT20_sensor_wrapper.py +++ b/AHT20_sensor_control/AHT20_sensor_wrapper.py @@ -73,6 +73,8 @@ def triggerAndMeasureAndCRCcheck(AHT20_sensor): raise NotImplementedError("Should be a AHT20_wrapper") temperature, humidity = triggerAndMeasure(AHT20_sensor) CRCStatus = AHT20_sensor.CheckCRC() + if (CRCStatus == AHT20Status.AHT20_CRCNOTOK): + AHT20_logger.warning("CRC8 check fail") return temperature, humidity, CRCStatus diff --git a/AHT20_sensor_control/__main__.py b/AHT20_sensor_control/__main__.py index 510087d..c002fa5 100644 --- a/AHT20_sensor_control/__main__.py +++ b/AHT20_sensor_control/__main__.py @@ -40,7 +40,9 @@ temperature, humidity = triggerAndMeasure(my_wrapper) mylogger.info("{0:.2f} C\t{1:.2f} %RH".format(temperature, humidity * 100)) else: - temerature, humidity, CRC8_check = triggerAndMeasureAndCRCcheck(my_wrapper) + CRC8_check = AHT20Status.AHT20_CRCNOTOK + while (CRC8_check == AHT20Status.AHT20_CRCNOTOK): + temerature, humidity, CRC8_check = triggerAndMeasureAndCRCcheck(my_wrapper) mylogger.info("{0:.2f} C\t{1:.2f} %RH\t{2}".format(temperature, humidity * 100, str(CRC8_check))) time.sleep(MEASURE_INTERVAL) except KeyboardInterrupt: diff --git a/pyproject.toml b/pyproject.toml index a5b841c..3442267 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "sensors-control-gpio-xzf8971" -version = "1.2.0" +version = "2.0.0" authors = [ { name="Zifeng", email="zifeng.xu@foxmail.com" }, ]