MQ2 flammable gas and smoke sensor detects the concentrations of combustible gas in the air and ouputs its reading as an analog voltage. The sensor can measure concentrations of flammable gas of 300 to 10,000 ppm.The sensor can operate at temperatures from -20 to 50°C and consumes less than 150 mA at 5 V.
Connecting five volts across the heating (H) pins keeps the sensor hot enough to function correctly. Connecting five volts at either the A or B pins causes the sensor to emit an analog voltage on the other pins. A resistive load between the output pins and ground sets the sensitivity of the detector. Please note that the picture in the datasheet for the top configuration is wrong. Both configurations have the same pinout consistent with the bottom configuration.The resistive load should be calibrated for your particular application using the equations in the datasheet, but a good starting value for the resistor is 20 kΩ.
DownLoad Url osoyoo.com
You must be logged in to post a comment.
TEST OK:
HARDWARE
Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
MQ2 Smoke Detector x 1
M/M jumpers
USB Cable x 1
PC x 1
Pin Definitions :
VCC : 3.3V-5V ⇔ UNO 5V
GND : The Ground ⇔ UNO GND
A0 : I/O Interface of MQ2 ⇔ UNO PIN A0
Sample source :
volatile float sensorValue;
volatile float sensorVolt;
volatile float RS_air;
volatile float R0;
volatile float rate;
void setup()
{
Serial.begin(9600);
sensorValue = analogRead(A0);
sensorVolt = (sensorValue / 1024) * 5.0;
RS_air = (5.0 – sensorVolt) / sensorVolt;
R0 = RS_air / 9.8;
rate = RS_air / R0;
}
void loop()
{
for (int x = 0; x <= 100; x = x + (1)) {
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue / 100.0;
Serial.print("sensorValue = ");
Serial.print(sensorValue);
Serial.println("");
Serial.print("sensor_volt = ");
Serial.print(sensorVolt);
Serial.println("v");
Serial.print("R0 = ");
Serial.print(R0);
Serial.println("R0");
Serial.print("rate = ");
Serial.print(rate);
Serial.println("%");
delay(1000);
}