The MQ series sensors are widely used low-cost sensors, commonly applied in gas leak monitoring devices in homes or factories. This article introduces the use of the MQ-2 smoke sensor from the MQ family, and other MQ sensors operate similarly.
1. Working Principle of MQ Series Sensors
The sensitive material used in MQ series sensors is a highly active metal oxide semiconductor. After heating the sensor, the conductivity varies with different gas concentrations. A simple circuit can convert the change in conductivity into a signal output corresponding to the gas concentration.
2. Introduction to the Smoke Sensor Module
The MQ-2 sensor is highly sensitive to combustible gases and smoke. The smoke sensor module based on MQ-2 provides two output methods through circuit design:
-
Digital Output: The concentration threshold is set through the onboard potentiometer. When the detected gas concentration exceeds the threshold, a low level is output through the digital pin DO.
-
Analog Output: The higher the concentration, the higher the voltage value output from the AO pin, and the higher the analog value collected by the ADC.
It should be noted that after powering on, the sensor needs to preheat for about 20 seconds for the measured data to stabilize. As the sensor requires internal heating while operating, the heat generated by the sensor is normal.
3. Experimental Materials
-
Uno R3 Development Board
-
USB Data Cable
-
Breadboard and Connecting Wires
-
MQ-2 Smoke Sensor Module
4. Experimental Steps
1. Build the circuit according to the schematic.
The VCC and GND of the smoke sensor module are connected to the 5V and GND of the development board, respectively. The AO pin of the module is connected to the analog pin A0 of the development board, and the DO pin of the module is connected to the digital pin 2 of the development board.
The experimental schematic is shown in the figure below:
The actual connection diagram is shown in the figure below:
2. Create a sketch, copy the following code to replace the automatically generated code, and save it.
/*
Using the MQ-2 Smoke Sensor
*/
#include <Arduino.h>
#define Sensor_AO A0
#define Sensor_DO 2
unsigned int sensorValue = 0;
void setup()
{
pinMode(Sensor_DO, INPUT);
Serial.begin(9600);
}
void loop()
{
sensorValue = analogRead(Sensor_AO);
Serial.print("Sensor AD Value = ");
Serial.println(sensorValue);
if (digitalRead(Sensor_DO) == LOW)
{
Serial.println("Alarm!");
}
delay(1000);
}
3. Connect the development board, set the corresponding port number and board type, and download the program.
5. Experimental Phenomenon
Open the serial monitor, set the baud rate to 9600, which is consistent with the program. The monitor will display the ADC analog value corresponding to the voltage output from the AO pin. When the gas concentration exceeds the set threshold, an alarm prompt will be output. We can use devices such as sound and light alarms to create a home smoke monitoring instrument.
Summary of Arduino Basics
Arduino Advanced Part 10 – Controlling OLED Backlight with Light Intensity Sensor
Arduino Meets Node.js: Control LED Brightness via Web Interface
If you find the article helpful, please give it a thumbs up, share, and leave a message as support.
Follow the public account “TonyCode”, reply “Advanced” in the background to get the code in the article.
Long press to recognize the QR code in the image to follow us
Leave a Comment
Your email address will not be published. Required fields are marked *