Product Introduction #
MQ-4 gas sensor is a combustible gas sensor, which can detect the concentration of combustible gas in the environment. Its working principle is based on the change of electrical properties of semiconductor gas sensitive materials. When there is combustible gas (such as methane, propane, butane, etc.), the gas sensitive materials inside the sensor will react with the gas, resulting in changes in the resistance value of the material.
It is widely used in domestic and industrial fields in methane leakage detection, gas leakage alarm and gas detection.
Parameter Specification #
Parameters | Value/Description |
Operating voltage | 5V |
Operating temperature | -20°C~+80°C |
Concentration detection | 300~10000ppm |
Output signal | Analog signal |
Size | 4.72cm*2.38cm |
#
Wiring Diagram #
Note:Expansion board is attached to esp32 controller board.
MQ-4 Gas Sensor | ESP32 |
VCC | 5V |
GND | GND |
Sign | Pin 32 |
Sample Code #
void setup() {
pinMode(32,INPUT);//Set pin 32 to input mode
Serial.begin(115200);//Set baud rate to 115200
}
void loop() {
Serial.println(analogRead(32));//Read the state of pin 32 and print it to the serial monitor
delay(1000);
}
Note: If you are using an Arduino board, then change the pin in the program to PIN A0, set the baud rate to 9600, and then connect the hardware pin to PIN A0 and upload the program.
Test Results #
After uploading the code to the controller board, open the serial port monitor of the Arduino IDE, set the baud rate to 115200, and switch to the scroll mode. When pressed half with a lighter, flammable gas will be released. At this time, the gas will be sprayed to the MQ-4 gas sensor, and the following data can be seen.
Note: The MQ-4 gas sensor will be heated at the beginning, and it will be 20 seconds before normal detection.
Related Resources #
Get One Now #
B2B Business: info@acebott.com