Introduction: How to Detect Concentration of Gas by Using MQ2 Sensor
MQ-2 Gas sensor is used to detect the gas level around the area. This sensor able to use as home or factory gas leak monitoring, suitable for gas, butane, propane, methane, alcohol, hydrogen, smoke and other monitoring devices.
- Size: 35mm x 22mm x 23mm (length x width x height)
- Main chip: LM393, ZYMQ-2 gas sensors
- Working voltage: DC 5 V
- With a signal output instruction.
- Dual signal output (analog output, and high/low digital output)
- 0 ~ 4.2V analog output voltage, the higher the concentration the higher the voltage.
- Better sensitivity for gas, natural gas, city gas.
- With a long service life and reliable stability.
- Rapid response and recovery characteristics.
Step 1: Gather Materials
Step 2: Understanding Pin Definition of MQ2 Gas Sensor
Step 3: Set Up the Circuit Above
-Pins D7 , D6 , D5 , D4 connect to arduino digital pins 2,3,4,5 respectively.
-Pins A and K connect to 5V and GROUND respectively
-Pins VSS and VDD connect to Ground and 5V respectively.
-Use as a LED indicator for the calibration process of the MQ2 gas sensor
-Connect to digital pin 13 of Arduino Uno
MQ2 Gas Sensor
-Analog output connect to the A0 of arduino
-Center pin connect to the V0 of LCD display
-Other two pins just connect to 5V and GROUND respectively
*Note: All of pins above is configured regarding the circuit figure above. You can configure the connection yourself regarding your favourite.
Step 4: Programming the Arduino Uno
As you can see in the graph above , it shows several gases.
The values are plotted on a semilog paper, as you can see the values indicate 100......1000.....10000 ppm.
These values when plotted on a normal graph would represent a curve like an exponential one.
Formula In the Coding
pow(10,( ((log(rs_ro_ratio)-pcurve)/pcurve) + pcurve))
Based on the graph MQ2, the derivation of ppm formula will be:
Y - y1 = m( X - x1)
X= (y-y1)/m + x1
X= (Rs/Ro-y1)/m + x1
log X =(log (Rs/Ro) - y1)/m +x1
X =10^( (log (Rs/Ro) - y1)/m +x1)
*Note: X = ppm on the graph
***The derivation formula are same and can be used for other types of MQ gas sensor.
If you have any problem about the coding, you are welcome to ask any question in the comments below or contact us for further details.
We have a be nice policy.
Please be positive and constructive.
How to adjust load resistance(RL) which is given to be 5Kohms in data sheet..and how clean air resistance (Ro) is taken to be 10Kohms?
i want to make same projct but for mq7 (i use a Modula like you use but mq7 )
what is RL for mq7
and R0 and clean air
and normal RO
because i search in data sheet and didn't understand this thing