MQ-2 gas sensor example

The MQ-2 gas sensor module is suitable for detecting LPG, i-butane, propane, methane ,alcohol, Hydrogen, smoke.

mq2 gas sensor

Code

In this example we simply connect the AOUT to Analog pin 0 and read in the value and output this via the serial monitor

[cpp]

int sensorValue;
void setup()
{
 Serial.begin(9600);      // sets the serial port to 9600
}
void loop()
{
 sensorValue = analogRead(0);       // read analog input pin 0
 Serial.println(sensorValue, DEC);  // prints the value read
 delay(100);                        // wait 100ms for next reading
}

[/cpp]

 

Links


CG312 MQ2 Smoke Gas Sensor Module for Arduino (Works with Official Arduino Boards)

Related posts

Build a UV light detector with an Si1145 sensor

Ultrasonic distance measurement project using an HY-SRF05

MPL3115A2 pressure sensor readings on LCD

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