Popularity
1.1
Growing
Activity
0.0
Stable
18
4
9

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.

Programming language: Python
License: GNU General Public License v3.0 or later
Latest version: v1.0.1

Gas detection alternatives and similar packages

Based on the "Hardware" category.
Alternatively, view Gas detection alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Gas detection or a related project?

Add another 'Hardware' Package

README

Gas detection

Latest Version Total Downloads License Build Status

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.


*Note that all licence references and agreements mentioned in the Gas detection README section above are relevant to that project's source code only.