아두이노 > 가스센서

인기검색어 > 아두이노 센서 ATMEGA128

최신글 질문게시판 동영상강좌 가입하기

▼ BASIC4MCU 후원업체 신제품 정보 ▼

▲ BASIC4MCU 후원업체 신제품 정보 ▲

BASIC4MCU > 아두이노

아두이노 | 가스센서

페이지 정보

작성자 키트 작성일17-09-13 13:51 조회1,082회 댓글0건

본문

 

Grove - Gas Sensor(MQ2)

Twig-Gas Sensor

中文 The Grove - Gas Sensor(MQ2) module is useful for gas leakage detection (in home and industry). It is suitable for detectingH2, LPG, CH4, CO, Alcohol, Smoke or Propane. Due to its high sensitivity and fast response time, measurements can be taken as soon as possible. The sensitivity of the sensor can be adjusted by using the potentiometer.


Get One Now Banner 
 

Contents

 

Features

  • Wide detecting scope
  • Stable and long life
  • Fast response and High sensitivity

Specification

ItemParameterMinTypicalMaxUnit
VCCWorking Voltage4.955.1V
PHHeating consumption0.5-800mW
RLLoad resistanceadjustable
RHHeater resistance-33-Ω
RsSensing Resistance3-30

Application Ideas

  • Gas leakage detection.
  • Toys.

Hardware Overview

This is a Analog output sensor. This needs to be connected to any one Analog socket in Base Shield. The examples used in this tutorial makes uses of A0 analog pin. Connect this module to the A0 port of Base Shield.

It is possible to connect the Grove module to Arduino directly by using jumper wires by using the connection as shown in the below table:

ArduinoGas Sensor
5VVCC
GNDGND
NCNC
Analog A0SIG


The output voltage from the Gas sensor increases when the concentration of gas increases. Sensitivity can be adjusted by varying the potentiometer. Please note that the best preheat time for the sensor is above 24 hours. For detailed information about the MQ-2 sensor, please refer to the data-sheet provided in resource section.

Getting Started

Gas Sensor Connected to A0

Connect the Grove - Gas Sensor(MQ2) to A0 port as shown in the above picture.

Gas Detection : Basic Example

In this example, the sensor is connected to A0 pin. The voltage read from the sensor is displayed. This value can be used as a threshold to detect any increase/decrease in gas concentration.

void setup() {  Serial.begin(9600);} void loop() {  float sensor_volt;   float sensorValue;   sensorValue = analogRead(A0);  sensor_volt = sensorValue/1024*5.0;   Serial.print("sensor_volt = ");  Serial.print(sensor_volt);  Serial.println("V");  delay(1000);}

Measurement : Approximation

This examples demonstrates a way to know the approximate concentration of Gas. As per the data-sheet of the MQx sensors, these equations are tested for standard conditions and are not calibrated. It may vary based on change in temperature or humidity.

1.Keep the Gas Sensor in clean air environment. Upload the below program.

void setup() {  Serial.begin(9600);} void loop() {  float sensor_volt;   float RS_air; //  Get the value of RS via in a clear air  float R0;  // Get the value of R0 via in H2  float sensorValue; /*--- Get a average data by testing 100 times ---*/       for(int x = 0 ; x < 100 ; x++)  {    sensorValue = sensorValue + analogRead(A0);  }  sensorValue = sensorValue/100.0;/*-----------------------------------------------*/   sensor_volt = sensorValue/1024*5.0;  RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL  R0 = RS_air/9.8; // The ratio of RS/R0 is 9.8 in a clear air from Graph (Found using WebPlotDigitizer)   Serial.print("sensor_volt = ");  Serial.print(sensor_volt);  Serial.println("V");   Serial.print("R0 = ");  Serial.println(R0);  delay(1000); }

 

2. Then, open the serial monitor of Arduino IDE. Write down the value of R0 and this needs to be used in the next program. Please node down the R0 after the reading stabilizes.


Replace the R0 below with value of R0 tested above . Expose the sensor to any one of the gas listed above.

void setup() {  Serial.begin(9600);} void loop() {   float sensor_volt;  float RS_gas; // Get value of RS in a GAS  float ratio; // Get ratio RS_GAS/RS_air  int sensorValue = analogRead(A0);  sensor_volt=(float)sensorValue/1024*5.0;  RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL   /*-Replace the name "R0" with the value of R0 in the demo of First Test -*/  ratio = RS_gas/R0;  // ratio = RS/R0   /*-----------------------------------------------------------------------*/   Serial.print("sensor_volt = ");  Serial.println(sensor_volt);  Serial.print("RS_ratio = ");  Serial.println(RS_gas);  Serial.print("Rs/R0 = ");  Serial.println(ratio);   Serial.print("\n\n");   delay(1000); }

 

Now, we can get the concentration of gas from the below figure  

Gas sensor 1

According to the graph, we can see that the minimum concentration we can test is 100ppm and the maximum is 10000ppm, in a other word, we can get a concentration of gas between 0.01% and 1%. However, we can't provide a formula because the relation between ratio and concentration is nonlinear.  

Suggest Reading / References

Download Arduino and install Arduino driver
Getting Started with Seeeduino
How to choose a Gas Sensor
What's LEL

 

Resources



3660040649_urKXyUs7_39189_1.jpg


디바이스 마트에서 판매하는 mq2 센서입니다.

3660040649_JhqNdaXQ_mq3_ma6_-_1_ekit.jpg3Ftype3Dw740
mq2,3,6등은 가스 농도에 비례해서 전류가 흐르고
센서 출력 단자에 풀다운 저항을 연결하면 전류에 비례한 전압을 얻습니다.
센서 종류에따라서 저항값이 다릅니다.

1
2
3
4
5
6
7
8
9
void setup(){
  Serial.begin(9600);
}
//
void loop(){
  int mq2Val=analogRead(A0);
  float volt=(float)mq2Val*5.0/1023.0;
  Serial.println(volt,1); // 소숫점 이하 1자리 출력
}
cs

가스 농도에 따른 출력 전압이 시리얼 모니터에 표시됩니다.


3660040649_43udJP9m_DC12V_25C625D225B125B825B525BF.PNG3Ftype3Dw740

<디지털 ON-OFF 출력>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const int FAN=11;
//
void setup() {
  pinMode(FAN, OUTPUT);
  Serial.begin(9600);
}
//
void loop() {
  int mq2Val=analogRead(A0);
  float volt=(float)mq2Val*5.0/1023.0// 전압으로 변환
  Serial.println(volt,1);              // 소숫점 이하 1자리 출력
  if(volt>2.5)digitalWrite(FAN,HIGH);  // 가스농도가 2.5V 이상이면 FAN-ON
  else        digitalWrite(FAN,LOW);   // 아니면 FAN-OFF
}
cs

//

 if(volt>2.5)digitalWrite(FAN,HIGH);  // 가스농도가 2.5V 이상이면 FAN-ON
  else        digitalWrite(FAN,LOW);   // 아니면 FAN-OFF
체크 전압은 원하는 농도에서의 전압으로 변경하세요

댓글 : 0

조회수 : 1,082

등록된 댓글이 없습니다.

게시물 검색

아두이노 목록

게시물 검색


Privacy Policy
MCU BASIC ⓒ 2017
PC버전