Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand All @@ -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)
```
11 changes: 11 additions & 0 deletions mhz19.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down