diff --git a/README.md b/README.md index 20c246e..0f970fa 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ __License MIT__ Some hints taken from: https://github.com/nara256/mhz19_uart/blob/master/src/MHZ19_uart.cpp +https://emariete.com/en/sensor-co2-mh-z19b/#El_sensor_de_CO2_MH-Z19C @@ -49,3 +50,13 @@ print('ppm:', sensor.ppm) print('temp:', sensor.temp) print('status:', sensor.co2status) ``` + +CALIBRATE IF NEEDED: +``` +#perform a manual zero point calibration (let it sit at 400pm for 20mins first) +sensor.calibrate_zero() + +#enable/disable automatic zero point calibration, which depends on a daily drop +#to 400ppm to work +sensor.set_auto_calibrate_zero(True) +``` diff --git a/mhz19.py b/mhz19.py index 31ba0ed..5842caf 100644 --- a/mhz19.py +++ b/mhz19.py @@ -69,6 +69,17 @@ def get_data(self): self.co2status = ord(chr(s[5])) return 1 + def set_auto_calibrate_zero(self, enable): + if enable: + msg = b'\xff\x01\x79\xa0\x00\x00\x00\x00\xe6' + else: + msg = b'\xff\x01\x79\x00\x00\x00\x00\x00\x86' + self.uart.write(msg) + + def calibrate_zero(self): + msg = b'\xff\x01\x87\x00\x00\x00\x00\x00\x78' + self.uart.write(msg) + def crc8(self, a): crc = 0x00 count = 1