

_0x0_webp.jpeg)
The MQ2 Sensor Module is a complete module designed to interface with microcontrollers like Arduino, Raspberry Pi, and other development boards. It's essentially a ready-to-use version of the MQ2 gas sensor with additional components for easier integration and use in your projects.
Typically, the MQ2 sensor module has the following pins:
Here's how you can connect the MQ2 Sensor Module to an Arduino:
int mq2AnalogPin = A0; // MQ2 analog output pin
int mq2DigitalPin = 2; // MQ2 digital output pin
int sensorValue = 0; // Variable to store the analog sensor value
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
pinMode(mq2DigitalPin, INPUT); // Set digital pin as input for threshold detection
}
void loop() {
// Read the analog value from the MQ2 sensor
sensorValue = analogRead(mq2AnalogPin);
// Print the sensor value to the serial monitor
Serial.print("Analog Value: ");
Serial.println(sensorValue);
// Check if the digital output is HIGH (threshold exceeded)
int digitalValue = digitalRead(mq2DigitalPin);
if (digitalValue == HIGH) {
Serial.println("Gas concentration above threshold!");
} else {
Serial.println("Gas concentration below threshold.");
}
delay(1000); // Delay for 1 second
}
The MQ2 sensor module requires calibration to ensure accurate readings. Initially, the sensor might require a preheating period of 24-48 hours, and the potentiometer on the module can be adjusted to calibrate the sensitivity for the desired gases.
Origin : China
Brand : Generic