Pin names
Positive power supply
Ground
Digital output
Analog output
Attributes
Initial gas concentration (in parts per million)
Digital output threshold voltage
Operation
The MQ2 Gas Sensor is a semiconductor sensor that can detect the presence of various combustible gases including LPG, Propane, Hydrogen, Methane, and Carbon Monoxide. The sensor has both analog and digital outputs:- The analog output (AO) provides a continuous voltage reading that corresponds to the gas concentration (ppm). Higher gas concentration results in higher voltage output.
- The digital output (DO) acts as a threshold detector - it goes LOW when gas concentration exceeds the threshold set by the potentiometer.
- Connect VCC to 5V power supply
- Connect GND to ground
- For analog readings:
- Connect AO to an analog input pin
- Read the analog value to get relative gas concentration
- For threshold detection:
- Connect DO to a digital input pin
- The pin will read LOW when gas concentration exceeds threshold
- Adjust threshold using the
thresholdattribute
In real hardware, the sensor needs a pre-heating time of about 20-30 seconds before taking readings. The simulator provides readings immediately.
Digital output
The digital output (DO) pin will read LOW when gas concentration exceeds the threshold. The threshold is set by thethreshold attribute. The default threshold is 4.4V.