https://github.com/eightsq/mqtt-co2
A script to connect a mh-z19 sensor on a raspberry pi to a mqtt broker.
https://github.com/eightsq/mqtt-co2
Last synced: about 1 year ago
JSON representation
A script to connect a mh-z19 sensor on a raspberry pi to a mqtt broker.
- Host: GitHub
- URL: https://github.com/eightsq/mqtt-co2
- Owner: EightSQ
- Created: 2020-03-01T15:07:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-01T15:10:43.000Z (over 6 years ago)
- Last Synced: 2025-02-15T00:45:18.220Z (over 1 year ago)
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MQTT-connected MH-Z19B co2 & temperature sensor
## Requirements
- Raspberry Pi 1+ B or compatible
- MH-Z19B sensor (you can find them for less than 20$ on [aliexpress](https://www.aliexpress.com/wholesale?SearchText=mh+z19b))
- python 3 with pip
## Setup
- Enable the serial port hardware. (guides for [raspbian](https://github.com/UedaTakeyuki/mh-z19/wiki/How-to-Enable-Serial-Port-hardware-on-the-Raspberry-Pi) and [arch](https://logicalgenetics.com/serial-on-raspberry-pi-arch-linux/))
- Hook up the sensor according to the [mh-z19 library readme](https://github.com/UedaTakeyuki/mh-z19#cabling).
- `pip install -r requirements.txt`
- Run `bp_sensor.py` priviledged (for serial communication). Use `BROKER_HOST`, `BROKER_PORT`, `BROKER_USER` and `BROKER_PASS` environment variables to set up.
- Modify the topics to publish to inside the main function to fit your needs.
## Running as daemon
- Install and enable the `co2.service` in systemd. Modify it to match your installation path.