Hello everyone. I am trying out a project to read the value from a MQ2 Gas Sensor using my Arduino Uno board and display it on the serial monitor. Following is the attached code :-
#define MQ2_PIN A0
void setup() {
Serial.begin(115200);
pinMode(MQ2_PIN, INPUT);
}
void loop() {
int gasSensorValue = analogRead(MQ2_PIN);
Serial.print("MQ2 Sensor Value: ");
Serial.println((gasSensorValue/1023)*100);
delay(1000);
}
I have set the correct baud rate and connected the pin A0 of the MQ2 sensor to the A0 pin of Arduino Uno, yet everytime I get a zero (0) reading as output from the sensor. Can anyone please help me ?