MH_Z19B CO2 Sensor Serial interface 
This package is ment to be used to read data from MH_Z19B CO2 Sensor via serial. Sensor can be bought on AliExpress for around 18€ (Jan 2019)
It is recommended to disable Auto calibration and set measuring range to 5000 to get adequate readings after first day of use.
Requirements:
You need a USB to TTL adapter to read data from the sensor. I use Prolific Technology PL2303 adapter plugged into my router. Router runs a python script with this library that reads metrics periodically and sends it via MQTT.
Python 3.5+
Installation:
pip3 install pymh-z19b-serial
Library Usage examples:
It is possible to use sync and async way to read from the sensor
Sync
Uses pyserial
from mh_z19b.sync import Sensor
sensor = Sensor(port='/dev/cu.usbserial', baudrate=9600)
print(sensor.read_metric())
Async
Uses asyncio and pyserial-asyncio
import asyncio
from mh_z19b.async import Sensor
async def run(loop):
sensor = Sensor(loop)
await sensor.open_serial(url='/dev/cu.usbserial', baudrate=9600)
data = await sensor.read_metric()
print(data)
loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(run(loop))
loop.close()
Metadata
Release files for pymh-z19b-serial 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymh-z19b-serial-1.2.3.tar.gz | 4.2 kB | Without provenance | Details for pymh-z19b-serial-1.2.3.tar.gz |
Release files / pymh-z19b-serial-1.2.3.tar.gz
| Download URL | pymh-z19b-serial-1.2.3.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7aeab863ad49d05fff7d0a2e4657abdc1ef525fcd528073408ce7eca1b4cc3fc
|
|
BLAKE2b-256 checksum How to use checksums |
960d2d8cefa8f8f476ebe69bb8ebd754e14c83ff680ae22b4f4ff20c48c9b5ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3
|
Security for pymh-z19b-serial 1.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.