Gas detection
Gas detection for Raspberry Pi using ADS1x15 and MQ-2 sensors.
Description
The MQ-2 sensor can detect multiple gases (CO, H2, CH4, LPG, propane, alcohol, smoke) and outputs analog voltage. This project can convert it to digital using ADS1015 or ADS1115 and filter out the target gases.
The sensor can be inaccurate so don't use those measurements if you need them for security purposes. Use some professional measurement device if you need to do this.
Usage
The detection class uses ADS1115 and it's I2C address 0x48 by default. It assumes the sensor is connected to P0. You can also pass them to arguments.
The ro value is about 1000, but it needs to be calibrated. This is done automatically if it is not specified. The calibration must be done in good fresh air to make measurements more accurate. Alternativly, you can save the calibration value and later pass it as ro argument.
from gas_detection import GasDetection
detection = GasDetection()
You can then read percentage of gases in parts per million (ppm). The measurements are returned as dictionary and gas be accessed by GAS_XX constant.
ppm = detection.percentage()
print('CO: {} ppm'.format(ppm[detection.CO_GAS]))
print('H2: {} ppm'.format(ppm[detection.H2_GAS]))
print('CH4: {} ppm'.format(ppm[detection.CH4_GAS]))
print('LPG: {} ppm'.format(ppm[detection.LPG_GAS]))
print('PROPANE: {} ppm'.format(ppm[detection.PROPANE_GAS]))
print('ALCOHOL: {} ppm'.format(ppm[detection.ALCOHOL_GAS]))
print('SMOKE: {} ppm\n'.format(ppm[detection.SMOKE_GAS]))
You can also look to example file for more examples. For more details how the values are calculated you can read tutorial on Raspberry Pi Tutorials.
Versioning
This library uses SemVer for versioning. For the versions available, see the tags on this repository.
License
This library is licensed under the GPLv3+ license. See the LICENSE file for details.
A lot of code has been taken from Raspberry-Pi-Gas-Sensor-MQ. Thank you @tutRPi and others who contributed to that repository.
Metadata
Release files for gas-detection 1.0.1
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 |
|---|---|---|---|---|
| gas-detection-1.0.1.tar.gz | 19.4 kB | Without provenance | Details for gas-detection-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gas_detection-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for gas_detection-1.0.1-py3-none-any.whl |
Total release size: 38.1 kB
Release files / gas-detection-1.0.1.tar.gz
| Download URL | gas-detection-1.0.1.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58925d283c74fc1675e2514cfdecf319d050506fcb1205ad448dcf848a0ae642
|
|
BLAKE2b-256 checksum How to use checksums |
43bed2665e67b7305bcd07380f87f92c7f776d13f87bb799134afc7b6bbe110d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.4.8
|
Release files / gas_detection-1.0.1-py3-none-any.whl
| Download URL | gas_detection-1.0.1-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a006743162fa06b0d3549dd62a7441a47e59fe47a0dd50f20e0f782d3376fadd
|
|
BLAKE2b-256 checksum How to use checksums |
ef8ee1267e4ea2ed2048eb307e2510eaede70e547deac421a14a8c22423b1109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.4.8
|
Security for gas-detection 1.0.1
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.