MQ-7 Carbon Monoxide Gas Sensor
The MQ-7 gas sensor uses tin oxide (SnO) as its sensitive material, which exhibits low conductivity in clean air. It uses a high-low temperature cycle detection method to detect carbon monoxide. At low temperatures (1.5V heating), it detects CO, and at high temperatures (5.0V heating), it cleans the gas adsorbed during low-temperature detection. As the concentration of carbon monoxide increases in the air, the sensor’s conductivity rises. The changes in conductivity are then converted into an output signal corresponding to the concentration of CO. This sensor is ideal for detecting carbon monoxide, providing a simple and effective way to monitor CO levels in the air.
Module Source
Purchase Link:
https://detail.tmall.com/item.htm?abbucket=0&id=13673403530&ns=1&spm=a21n57.1.0.0.5668523c1NVcMb
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1B8WhPIzTmWwQsFFVayRpAA?pwd=9966
Password: 9966
Specifications
Operating Voltage: 3.3V-5V
Operating Current: 150MA
Output Methods: DO (Digital Output) AO (Analog Output)
Reading Method: ADC (Analog-to-Digital Converter)
Pin Count: 4 Pins (2.54mm pitch header)
Hardware Connection
- Connect the Vcc pin of the sensor to the 5V power supply of the development board.
- Connect the GND pin of the sensor to the GND of the development board.
- Connect the AO (Analog Output) pin to the A0 analog input pin of the development board.
- Connect the DO (Digital Output) pin to the digital pin 8 of the development board.
Usage Method
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 8, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
int MQ7_AO_Pin = A0; // 定义一氧化碳传感器的AO连接到开发板的A0引脚
int MQ7_DO_Pin = 8; // 定义一氧化碳传感器的DO连接到开发板的8号引脚
int MQ7Value = 0; // 用于存储一氧化碳浓度值的变量
#define ADC_MAX_VALUE 1023 //ADC的最大采集值
void setup() {
Serial.begin(9600); // 开始串行通讯,设置波特率为9600
pinMode(MQ7_DO_Pin, INPUT_PULLUP);
}
void loop() {
// 读取状态
int MQ7State = digitalRead(MQ7_DO_Pin);
if (MQ7State == LOW) {
Serial.println("检测到一氧化碳过高");
} else {
Serial.println("未检测到一氧化碳过高");
}
MQ7Value = analogRead(MQ7_AO_Pin); // 读取A0引脚的电压值
Serial.print("一氧化碳浓度: ");
Serial.println( MQ7Value); // 将读取的值发送到电脑的串行监视器
delay(1000); // 延时1秒
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38