[Diao Ye learns programming] Arduino hands-on (25) - MQ-2 methane carbon monoxide gas-sensitive smoke sensor module 2

insert image description here

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensors and modules on hand, according to the concept of true knowledge (must be done by hands), for the purpose of learning and communication, I am going to try and do experiments one by one here, and will record them whether they are successful or not—Xiao Xiao The progress or problems that cannot be solved, I hope to be able to throw bricks and spark jade.

[Arduino] 168 sensor module series experiments (data code + simulation programming + graphic programming)
Experiment 25: MQ-2 gas-sensitive smoke sensor module (methane liquefied gas flammable gas) alcohol hydrogen carbon monoxide flammable liquefied sensor module probe

insert image description here
insert image description here

MQ2 gas sensor module electrical schematic diagram

insert image description here
insert image description here

Step 1: Supply 5V DC to the module (be careful not to reverse the positive and negative poles, otherwise the chip will be easily burned).

Step 2: If you choose DOUT, TTL high and low level terminals, the output signal can be directly connected to the IO port of the microcontroller or connected to an NPN transistor to drive the relay. The potentiometer RP is used here to adjust the threshold of the output level jump. The schematic diagram can be analyzed. When the sensor detects the measured gas, the voltage value of the comparator LM393 pin 2 is proportional to the concentration of the gas detected by the sensor. When the concentration value exceeds the threshold value set by the potentiometer RP, The point of pin 2 of the comparator is higher than that of pin 3. At this time, the output of pin 1 of the comparator is low, and the LED light is on. R3 is the current limiting resistor of the LED light, and C1 is the filter capacitor. The sensor outputs a low level, on the contrary, when there is no signal, the sensor outputs a high level, which is equal to the power supply voltage.

Step 3: If you choose AOUT, analog output, then you don’t need to control the potentiometer, just connect the AOUT pin to the input terminal of AD conversion or a single-chip microcomputer with AD function. According to our experience: In a normal environment, that is, an environment without the gas to be measured, set the sensor output voltage as the reference voltage. At this time, the voltage at the AOUT terminal is about 1V. When the sensor detects the gas to be measured, the voltage is Increase by 0.1V, the actual measured gas concentration increases by 200ppm (simply speaking: 1ppm=1mg/kg=1mg/L=1×10-6 is often used to indicate the gas concentration, or solution concentration.), according to this parameter can The measured analog voltage value is converted into a concentration value in the single-chip microcomputer. Note: If you are using it as a precision instrument, please purchase a standard calibration instrument on the market, otherwise there will be errors, because the ratio of the relationship between output concentration and voltage is not linear, but tends to be linear.

Special reminder: After the sensor is powered on, it needs to preheat for about 20 seconds before the measured data is stable. It is normal for the sensor to heat up, because there is a heating wire inside, if it is hot, it will be abnormal.

Module features:
1. Adopt high-quality double-panel design, with power indicator and TTL signal output indicator;
2. With DO switch signal (TTL) output and AO analog signal output;
3. The effective signal of TTL output is low level. (When the output is low level, the signal light is on, and it can be directly connected to a single-chip microcomputer or a relay module)
4. The analog output voltage increases with the concentration higher.
5. It has good sensitivity to liquefied petroleum gas, natural gas, city gas and smog.
6. There are four screw holes for easy positioning;
7. Product dimensions: 32(L)*20(W)*22(H)
8. Long-term service life and reliable stability
9. Fast response and recovery characteristics

insert image description here
insert image description here

Electrical performance:
Input voltage: DC5V Power consumption (current): 150mA
DO output: TTL digital 0 and 1 (0.1 and 5V)
AO output: 0.1-0.3V (relatively pollution-free), the highest concentration voltage is around 4V
Special reminder: sensor After power on, it needs to preheat for about 20 seconds before the measured data is stable. It is normal for the sensor to heat up, because there is a heating wire inside, if it is hot, it will be abnormal.

insert image description here


insert image description here

Wiring method:
1. VCC: connect to the positive pole of the power supply (5V)
2. GND: connect to the negative pole of the power supply
3. DO: TTL switch signal output
4. AO: analog signal output

insert image description here

insert image description here

Simulation diagram

insert image description here

insert image description here

/*

【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)

实验二十五:MQ-2气敏式烟雾传感器模块(甲烷 液化气可燃气体)

*/

 

#define Aout A0 //MQ-2 AO 接 Arduino Uno A0

 

int temp = 0; //临时变量,存储A0读取的数据

 

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);//定义波特率

  pinMode(Aout, INPUT);//定义A0为INPUT模式

}

 

void loop() {

  // put your main code here, to run repeatedly:

  temp = analogRead(Aout); //读取A0的模拟数据

  Serial.println(temp); //串口输出temp的数据

  delay(500);  //延时500毫秒

}

Experimental schematic

insert image description here

Test with butane gas from a lighter

insert image description here

The serial port data of the first experiment

insert image description here

The detection data of the second experiment

insert image description here

Waveform diagram of the experiment, it is very sensitive to detect butane gas

insert image description here

insert image description here

insert image description here

insert image description here

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验二十五:MQ-2气敏式烟雾传感器模块(甲烷 液化气可燃气体)
项目:声音烟雾报警器
蜂鸣器 buzzer=D4
*/
 
int MQ2=A0;//指定模拟端口A0
 
int val=0;//声明临时变量
int buzzer=4;
void setup()
{
  pinMode(MQ2,INPUT);
 
  Serial.begin(9600);//设置串口波特率为9600
  pinMode(buzzer,OUTPUT);//设置IO脚模式,OUTPUT为输出
}
void loop()
{
  val=analogRead(MQ2);//读取A0口的电压值并赋值到val
  Serial.println(val);//串口发送val值
  if(val>70)
 
  digitalWrite(buzzer,HIGH);//发声音
  else
 
  digitalWrite(buzzer,LOW);//关闭声音
}

Some relevant information collected

1. Combustible gas sensor (MQ series) - a life-saving sensor

https://www.bilibili.com/video/av804079838/?from=search&seid=11663358107279587563&spm_id_from=333.337.0.0

2. Explanation of MQ-3 Alcohol Detection Sensor in "Single Chip Microcomputer Practical Project" (274)

https://www.bilibili.com/video/av287274155?from=search&seid=5350287723948680848&spm_id_from=333.337.0.0

3.
Arduino-MQ-2 Gas Sensor Detection Demonstration

https://www.bilibili.com/video/av805299651/?from=search&seid=13856095729728797361&spm_id_from=333.337.0.0

4. (Chapter 3. Basic experiment) Experiment 19. MQ-2 gas sensor

https://www.bilibili.com/video/av886804760/?from=search&seid=13856095729728797361&spm_id_from=333.337.0.0

5. MQ series gas detection alarm operation demonstration smoke sensor test combustible gas sensor alarm

https://www.bilibili.com/video/av807019421/?from=search&seid=13856095729728797361&spm_id_from=333.337.0.0

6. mq2 combustible gas alarm

https://www.bilibili.com/video/av70300691/?from=search&seid=13856095729728797361&spm_id_from=333.337.0.0

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132501997