Gas Sensor ============ The MQ-9 Analog Gas Sensor is useful for gas leakage detection (in home and industry). It has high sensitivity and is suitable for a variety of applications. When temperature rises (heated by 5.0V), it detects Methane, Propane, combustible gas, etc and cleans the other gases adsorbed under low temperature. Due to its high sensitivity and fast response time, measurements can be taken instantly. The sensitivity of the sensor can be adjusted by using the potentiometer. **NOTE**: The sensor value only reflects the approximated trend of gas concentration. It does not represent the exact gas concentration. .. warning:: Before proceeding with this sensor, you will need to learn about the :ref:`mcpadc`. | Connecting the Sensor ---------------------- The gas sensor is an analog sensor and cannot be connected directly to the Raspberry Pi pins. It needs an analog to digital converter, :ref:`mcpadc` in this case, in order to collect proper data. .. image:: Circuits/gassensor.jpg :align: center | - Black wire is connected to GND - Red wire to RPi VCC(3.3V) - Blue wire (green in this Figure) to one of MCP3008’s left pins. | .. warning:: This Sensor gets hot when connected to RPi, so do not touch it after it is connected. | Python Program Examples ------------------------ .. literalinclude:: Code/gassensor.py :linenos: :language: python | The Value read from the sensor is displayed. This value can be used as a threshold to detect any increase/decrease in gas concentration. For example, if the first values read ranges between 0.4 and 0.5, this means that this range is the threshold. Any increase/decrease in gas concentration will increase/decrease these values. To test it, bring a lighter close to the sensor, and start emitting gas (JUST GAS). Beware not to light it. In this next code we added a LED (on pin 7), so that any increase/decrease will turn the LED ON .. literalinclude:: Code/gassensor2.py :linenos: :language: python |