Before starting, you need to adjust the sensitivity of the gas sensor. Power on the sensor, adjust the potentiometer onside, and the D2 LED will light up or dim accordingly. Spin the pot and stop just when the LED gets brighter or dimmer. At this moment, the sensitivity of the gas sensor is the highest. You can confirm it with a lighter.
Connect pin A0 of the gas sensor to pin A0 of the SunFounder Mega 2560, and D0 to pin 7. The higher the smoke concentration is, the lower the resistance of the gas sensor gets. Thus, the voltage of the gas sensor decreases, which means the voltage of pin A0 increases. If the voltage of A0 is greater than the threshold, LM393 will output low level. Thus, the LED will light up and pin D0 will output low level.
-1 * SunFounder Mega 2560
-1 * MQ-2 Gas Sensor Module
-1 * USB Cable
– 1 * 3-Pin anti-reverse cable
Step1: Build the circuit
Step4: Burn the program into the SunFounder Mega 2560 board (check board and port selected)
Now, ignite a lighter. Then the sensor detects the gas emitted. Thus, the LED on the gas sensor and that attached to pin 13 on the SunFounder Uno board will light up. Also you can see the value at A0 and D0 printed on Serial Monitor.
Note: It is normal that the gas sensor generates heat. Actually, the higher the temperature is, the more sensitive the sensor is.