Home Sensor Projects Arduino and MQ-4 Gas sensor example

Arduino and MQ-4 Gas sensor example

by shedboy71

The MQ-4 gas sensor modules are used in gas leakage detecting equipments, they are suitable for the detection of CH4,Natural gas.LNG, avoid alcohol and cooking fumes and cigarette smoke with this sensor.

Features

  • High sensitivity to CH4 and Natural gas
  • Slight sensitivity to alcohol, smoke
  • Fast response
  • Stable and long life
  • Simple drive circuit

Connection was as follows

VCC - 5V
GND - GND
A0  - Analog pin0
D0  - Not connected

Code

[codesyntax lang=”cpp”]

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorVoltage; 
  float sensorValue;
 
  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
 
  Serial.print("sensor voltage = ");
  Serial.print(sensorVoltage);
  Serial.println(" V");
  delay(1000);
}

[/codesyntax]

 

Results

Again via the serial monitor

sensor voltage = 0.22 V
sensor voltage = 0.22 V
sensor voltage = 0.22 V
sensor voltage = 0.23 V
sensor voltage = 0.23 V
sensor voltage = 0.23 V
sensor voltage = 0.24 V

 

Links

Mq-4 datasheet
MQ4 Methane Gas Sensor

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More