Design a LEL gas detector through a raspberry pi board and MQ-5 sensor

Byamber

Design a LEL gas detector through a raspberry pi board and MQ-5 sensor

{:en}


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

{:}{:ja}

概要

本プロジェクトではMQ-5ガスセンサーとラズパイ3ボードを使って、可燃性ガス検出器を作ります。キッチンに置いて、ガス漏れ状況を続いて観測できます。MQ-5可燃ガス/煙センサーを使って、ラズパイに煙、ガスを検出装備をデザインします。SnO2系煙センサーですので、ガス濃度の変化に応じてSnO2の抵抗値が変化します。周囲環境でのガス濃度が増えると、SnO2の抵抗値が下げます。センサーがその変化値を輸出しできます。MQ-5は、
ブタン、プロパン、メタンなどに敏感と言われます。代表として天然ガスの多種の可燃ガスが検出できるので、様々な環境に採用できる、コストパフォーマンス高いのセンサーと言われます。

DSC_5496

必要なパーツ

PI
Pi3ボード x1
5
MQ-5モジュール x1
MCP3008
MCP3008 A/Dコンバータ x1
LACC2006AD-12
 ブレッドボード x1
LACC2006AD-31
ジャンプワイヤー(オス~オス) x若干
19
ジャンプワイヤー(オス~メス) x若干

ハードウェア

ラズパイはデジタル信号しか処理しできませんので、今回はガス検知センサーからの電圧信号(アナログ信号)を処理するため、A/Dコンバータも必要です。本プロジェクトではMCP3008と言う、よく利用されるA/Dコンバータを使用します。周囲環境でのガス濃度が増えると、SnO2の抵抗値が下げます。センサーがその変化値を電圧値に変更して、輸出しできます。電圧値より、ガスがあるか無いか判断しできます。

MQ-5モジュールの工作電圧は5Vになります、MQ-5モジュールはアナログ信号とデジタル信号2重輸出できますので、本プロジェクトに、アナログOUTPUT(AO)とデジタルOUTPUT(DO)両方と使用します。ガス検出したら、指示ランプが点灯、DOpinから低電位信号を輸出する、モジュールに可変抵抗がありますので、センサーの感度が調整しできます。

配線図

MQ-55

線路が違うとボード、センサーに損害の恐れが御座いますので、正極と負極を十分ご注意して下さい。Raspberry PiのGPIOピンの概要はこちら~

ソフトウエア

下記の操作は、ラズパイとスクリーンを接続しても、SSHを通じでラズパイと接続しても、操作できます。

1)プログラム

nanoエディタを使用して、下記のコマンドを作動して、/home/piにmq-5.pyと言うファイルを新規作成します。

sudo nano mq-5.py

ファイルにをコードをコーピーして、キーボードのCtrlとXボーダーを押して、Yを入力して、ファイルを保存します。

或いは、下記のコマンドを作動して、弊社編集済みのmq-5.pyを直接にダウンロードできます。

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

2)下記のコマンドを作動して、pythonプログラムを作動する

sudo python ./mq-5.py

3)結果

まず、mq-5モジュールは60秒の予熱が必要、预热20s左右,ガスライターを使って、モジュールに少しガスを释放したら、ターミナルに”Gas lealage”を表示し、電圧値も表示し、指示ランプも点灯します。もし、モジュールにガスを释放しても、何も変化しないの場合、モジュールでの可変抵抗を調整して、確認して下さい。

2017-03-30-094819_1824x984_scrot

{:}{:zh}
Overview

本项目将利用MQ-5可燃气体传感器模块,在树莓派上设计可燃气体检测器,可以将其安装于自己家厨房,时刻检测煤气罐有无泄漏。MQ-5气体传感器所使用的气敏材料是在清洁空气中电导率较低的二氧化锡(SnO2),当传感器所处环境中存在可燃气体时,传感器的电导率随空气中可燃气体浓度的增加而增大,模块可以将将电导率的变化转换为与该气体浓度相对应的输出信号。MQ-5气体传感器对丁烷、丙烷、甲烷的灵敏度高,对甲烷和丙烷可较好的兼顾。这种传感器可检测多种可燃性气体,特别是天然气,是一款适合多种应用的低成本传感器。

DSC_5496

Parts

本项目将用到如下器件

PI
Pi3 x1
5
MQ-5模块 x1
MCP3008
模数转换器 x1
LACC2006AD-12
面包板 x1
LACC2006AD-31
公对公跳线 x若干
19
公对母跳线 x若干

Hardware

Raspberry Pi只能处理数字信号,但是本项目中要用到MQ-5模块输出的模拟信号,所以需要用到模数转换器。本项目中利用MCP3008把MQ-5模块输出的电压信号转换成数字信号,根据转换后电压的大小来判断是否有可燃气体泄漏。

其中MQ-5模块工作在5V电压下,具有模拟信号和数字信号双路输出,当模块检测到有可燃气体泄漏的时候,信号指示灯亮起,数字信号输出口输出低电平。模块上面有一个可调电阻,通过调节可调电阻能够调节模块的灵敏度。

模块之间与树莓派具体连接请参考下图

MQ-55

在接线的时候请认清模块正负极,不要接反了,否则会烧坏你的Pi和模块。模块的上的GND接Pi上的0V;模块上的VCC接5V。对于如何识别Pi的IO口请参考这篇文章: How to read Raspberry Pi i/o pin diagram (GPIO pin graph)

Software

可以把pi直接接到显示器上,也可以通过SSH方式远程登录Pi。

1)编写代码

在/home/pi路径下用nano新建一个mq-5.py(名字随意,你喜欢就好!)

sudo nano mq-5.py

并往新建的文件中写入示例代码,代码可以通过执行下面的shell命令得到

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

2)执行python程序

sudo python ./mq-5.py

3)测试

先上电1分钟左右,让mq-5模块预热一下,如果出现模块有细微发烫是正常的。用打火机对着模块释放可燃气体,屏幕会打印出来”Gas lealage”的字样,并且打印出当前传感器输出电压,信号指示灯亮起,如果没有上述现象,可通过顺时针调节可调电阻,直到出现上述现象为止;在不向其释放可燃气体时候会输出”Gas not leak”字样。

2017-03-30-094819_1824x984_scrot{:}

About the Author

amber administrator

You must be logged in to post a comment