Overview

This tutorial is to design a LEL gas (Flammable gas)detector through a raspberry pi board and MQ-5 smoke sensor.It can detect LEL gas lealage in your kitchen.The gas-sensing materials the MQ-5 sensor used is SnO2 material,which is lower conductivity in clear air, the conductivity of sensor would go up with the increase of the smoke concentration.The sensor can convert the different conductivity to the correspondent output signal of the smoke concentration.The MQ-5 gas sensor has high sensitivity to butane,propane and methane. This sensor is very suitable for detecting the multi-component gas, especially for natural gas and has various application with lower price.

DSC_5496

Parts

PI
Pi3 x1
5
MQ-5 sensor x1
MCP3008
 Analog to digital convertor(ADC)   x1
LACC2006AD-12
Breadboard x1
LACC2006AD-31
male to male jumper wire
19
male to female

Hardware

As only the digital signal can be processed by raspberry pi, we need to add a analog to digital converter (ADC) to process the analog signal from MQ-5 sensor.It can detect the smoke in the air according to the valtage value. MCP3008as ADC chip is very common and recommended highly.

The MQ-5 sensor can output the analog and digital signal when the work voltage is 5V. When the LEL gas lealage is detected by sensor, the signal light turns on and the digital signal output the low-level valtage. In additon, there is a adjustable resistor to change the sensor sensitivity.

The schematic diagram is as follows:

MQ-55

Pay more attention to the anode and cathode, otherwise it would burnout your raspberry pi board and sensor.You can connect the GND of the sensor to OV, VCC to 5V. You could visit the article for your referenc if you want to learn more about the raspberry pi IO port. :How to read Raspberry Pi i/o pin diagram (GPIO pin graph)

Software

You could choose the connect the raspberry pi to monitor, or login in pi via SSH.

1)Write the code

Add new file named mq-5.py under the /home/pi file path via nano editor (the name is arbitrary)

sudo nano mq-5.py

Write the sample code in new file, the code can be obtained by executing shell commands.

sudo wget --no-check-certificate   http://osoyoo.com/driver/mq-5.py

2)Execute python program

sudo python ./mq-5.py

3)Test

Please power on the sensor for 1 minuts to preheat it.When the programme start,it is normal for sensor to stay hot slightly.It can produce the smoke using the lighter.When you light the lighter in front of sensor,there is a signal output of “Gas lealage” word and the valtage value, the signal light turns on . If these the phenomenon above doesn’t appear, you could swing clockwise to adjust the resistor until the above phenomenon appear.

2017-03-30-094819_1824x984_scrot