Lightweight python library for interactions with MH-Z16, MH-Z19 and similar Intelligent Infrared Gas Module CO2
class CO2Sensor()
MH-Z16 and MH-Z19 CO2 sensor.
def __init__(port: str, baudrate: int = 9600, timeout: float = 0.2)
Setup CO2 sensor
Arguments:
port
: The serial port name, for example/dev/ttyUSB0
(Linux),/dev/tty.usbserial
(OS X) orCOM4
(Windows).baudrate
: Baudrate to use.timeout
: Read timeout after each command.
def read_co2() -> int
Read CO2 concentration.
def read_temperature() -> float
Read temperature.
def read_status() -> int
Read status.
def read() -> Tuple[int, float, int, int]
Read all values.
Returns:
CO2 concentration, temperature, status, co2 auto calibration point
def zero_calibration()
Zero calibration.
def span_calibration(span: int)
Span calibration.
def set_auto_calibration(state: bool)
Set auto calibration point.
def close()
Close serial port.