MQ4 sensor is a sensor having high sensitivity to natural gas, methane, propane and butane.
The SnO2 semiconductor material is used in the MQ4 for detecting the gases. It has lower conductivity in clean air. It helps in detecting rising levels of gases through rise in its conductivity. Users can convert the change of conductivity to gas concentration through a simple electronic circuit.
An MQ4 Methane gas sensor has a wide array of applications such as:
- Domestic gas leakage detector
- Industrial Combustible gas detector
- Portable gas detector
The applicability of an MQ4 Methane gas sensor is enhanced by the following features:
- Good sensitivity
- Long life
- Simple drive circuit
MQ4 Methane Gas Sensor specifications
- Operating Voltage: 5V
- Operating Current: 150mA
- Concentration: 300-10000ppm
MQ4 Methane Gas Sensor pin diagram
Pin1: It is VCC Pin. It is used to connect 5V to the sensor.
Pin2: It is GND Pin. It is used to connect GND to the sensor.
Pin3: It is a digital output Pin. From this pin you will get digital data HIGH/LOW.
Pin4: It is analog output Pin. From this pin you will get analog data.
Circuit diagram of MQ4 Methane Gas Sensor with Arduino
Pin connection of MQ4 Methane Gas Sensor with Arduino
- Connect the VCC pin of the sensor to the 5V pin of the Arduino UNO board
- Connect the GND pin of the sensor to the GND pin of the Arduino UNO board
- Connect the AO pin of the sensor to the A2 pin of the Arduino UNO board
Arduino code for interfacing MQ4 Methane Gas Sensor with Arduino
sensorData = analogRead(sensorPin);
Arduino code working
Create a variable named sensorPin to the pin number of the Arduino UNO board where you have connected the AO pin of the sensor. In our case, it is A2 pin of the Arduino UNO board.
Create another variable named sensorData. We will use this variable to store the data that will be received by the Arduino from the sensor.
Inside the void setup block, set the baud rate for the serial communication and initiate the serial communication using Serial.begin() command.
Then use the pinMode() function to set the sensorPin as INPUT. The Arduino will use this pin to get the analog data from the sensor.
Inside the void loop() function, use sensorData variable to store the data that is received by the Arduino from the sensor.
Then, print the data on the serial monitor using the print and println command.
Note: The sensor can detect natural gas, methane, propane and butane. So, the value that you will get from the sensor will depend on the gas that is present.