MH410D by NekoSensors
A Python library for interfacing with the MH-410D CO2 sensor via UART.
Sensor Datasheet (+ Protocol) - MH-410D.PDF
Installation
You can install the library via pip:
pip install MH410D
Usage
Here is an example of how to use the MH410D library:
from MH410D import MH410D_CO2
# Create an instance of the sensor
sensor = MH410D_CO2(port='COM3', baudrate=9600, timeout=2)
# Read gas concentration
concentration_ppm = sensor.read_gas_concentration()
if concentration_ppm is not None:
print(f"Gas concentration: {concentration_ppm} ppm")
print(f"Gas concentration: {sensor.ppm_to_percent(concentration_ppm)} %")
# Example conversion to mg/m3 for carbon dioxide (CO2), molar mass 44 g/mol
concentration_mg_m3 = sensor.ppm_to_mg_m3(concentration_ppm, molar_mass=44)
print(f"Gas concentration: {concentration_mg_m3} mg/m3")
# Calibrate the sensor
sensor.calibrate_zero()
sensor.calibrate_span()
# Close the connection
sensor.close()
Features
- Read Gas Concentration: Read CO2 concentration in ppm from the MH-410D sensor.
- Calibrate Sensor: Calibrate the zero and span points of the sensor.
- Convert Units: Convert gas concentration from ppm to percentage and mg/m3.
API Reference
MH410D_CO2
__init__(self, port='COM3', baudrate=9600, timeout=2)
Initializes the serial connection with the specified parameters.
port(str): Port name to which the sensor is connected (default 'COM3').baudrate(int): Data transmission speed (default 9600).timeout(int): Timeout for read operations (default 2 seconds).
read_gas_concentration(self)
Sends a command to read gas concentration and returns the value.
- Returns: Gas concentration in ppm, or
Noneif reading failed.
calibrate_zero(self)
Sends a command to calibrate the sensor zero point.
- Returns:
Trueif calibration is successful, otherwiseFalse.
calibrate_span(self)
Sends a command to calibrate the sensor span point.
- Returns:
Trueif calibration is successful, otherwiseFalse.
ppm_to_percent(self, ppm)
Converts ppm to percentage.
ppm(int): Value in ppm.- Returns: Value in percentage.
ppm_to_mg_m3(self, ppm, molar_mass, temperature=25, pressure=101325)
Converts ppm to mg/m3.
ppm(int): Value in ppm.molar_mass(float): Molar mass of the gas in grams per mole.temperature(float): Temperature in degrees Celsius (default 25).pressure(float): Pressure in Pascals (default 101325 Pa).- Returns: Value in mg/m3.
close(self)
Closes the serial connection.
Out Another Projects:
https://github.com/NekoRMD/NekoRMD - Control MyActuator RMD X8-PRO using Python by CAN
https://github.com/K-Lab-Students/REIS_PCB - PBC library
Metadata
Release files for MH410D 1.0.0
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 |
|---|---|---|---|---|
| mh410d-1.0.0.tar.gz | 3.6 kB | Without provenance | Details for mh410d-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| MH410D-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for MH410D-1.0.0-py3-none-any.whl |
Total release size: 7.9 kB
Release files / mh410d-1.0.0.tar.gz
| Download URL | mh410d-1.0.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc7cd73626c3ceb1fb82893e7890b1e88521dc1005695b9322949764e850e596
|
|
BLAKE2b-256 checksum How to use checksums |
395db55ba49f8ce65fc8dc2adbf195fe2381231c11db42830958971d458366c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / MH410D-1.0.0-py3-none-any.whl
| Download URL | MH410D-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e561795d9a583fe46d34c407615156b6a96656aa753f5a409f074c9154daa3ce
|
|
BLAKE2b-256 checksum How to use checksums |
cf0161665f9c476679def8c76c23521f59cf758d134a84c99667bfa866601ce7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for MH410D 1.0.0
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.