|0.2.2||Feb 17, 2023|
|0.2.1||Sep 24, 2022|
|0.1.4||Oct 28, 2021|
|0.1.3||Apr 22, 2021|
#272 in Embedded development
34 downloads per month
Export CO₂ readings from a Winsen MH-Z19C CO₂ sensor connected to a Raspberry Pi to Prometheus. The sensor needs to be connected via the UART interface.
The following metrics will be provided at the
co2_ppm: Measured CO₂ concentration in parts per million (ppm).
Mnemonic for the port: 12 is C in hexadecimal and 0 = O, thus 1202 = CO2.
The exporter is implemented with asynchronously Tokio using
a single thread. A request to the
/metrics endpoint will trigger reading a
new measurement from the sensor. Multiple concurrent requests will only trigger
a single measurement wait for that one to complete.
- Download the binary from GitHub or compile one yourself.
- Place it on your Raspberry Pi, e.g. in
/usr/local/bin/rpi-mh-z19c-exporterand ensure the the executable permission is set.
- Use the Ansible role provided in the
rolesdirectory to setup a service user and add a systemd service. (Or do this manually if you prefer.)
The exporter is configured with environment variables:
RPI_MHZ19C_UART_PATH: Path to UART device that the sensor is connected to. Default:
RPI_MHZ19C_EXPORTER_LISTEN_ADDRS: Addresses (separated by space) to listen on. Default: