Working With MQ5 Gas Sensor


In my previous articles, I explained some sensors and its functions and in this article, I'll show you working with the MQ5 Gas Sensor to sense the Natural Gas, Coal Gas and LPG
  • Arduino Uno
  • MQ5 Gas Sensor
  • Bread Board
  • Led
  • Vcc to 5v
  • Gnd to Gnd
  • Signal (Middle Pin)---->Arduino
  • led analog pin to 13
  • Cathode to Gnd
Gas Moisture Sensor
Figure 1: MQ5 Gas Sensor
MQ5 Gas Sensor Specifications
Items Parameter Min
Vcc Working Voltage 4.9
PH Heating Consumption 0.5
RL Load Resistance -
RS Sensing Resistance 3
  • Gas Leakage Detection
  1. const int analog=A0;  
  2. const int led=13;  
  3. int sensor=0;  
  5. void setup()  
  6. {  
  7.   Serial.begin(9600);  //Baud Rate
  8.   pinMode(led,OUTPUT);  
  9. }  
  11. void loop()  
  12. {  
  13.   sensor=analogRead(analog);  
  14.   if(sensor>=350)  
  15.   {  
  16.     digitalWrite(led,HIGH);  
  17.   }  
  18.   else  
  19.   {  
  20.     digitalWrite(led,LOW);  
  21.   }  
  22.   Serial.print("SensorValue = ");  
  23.   Serial.println(sensor);  
  24.   delay(10);  
  25. }   
const int analog and const int led constants won't change. They are used to give the name to the pin. Sensor value ='0', it reads the value from the sensor.
In the Setup() function set the baud rate and PinMode led as OUTPUT and in the loop() function we want to set the working conditions to the MQ5 Gas Sensor.
Sensor = analogRead(analog)
//Reads the analog value if(sensor>=300)
//Condition to the sensor base up on this if conditions it will act if(sensor>=300).
The LED for Gas is leaking will ON as shown in the above figure else the LED is in the off condition.
Serial.print // Print the result in the serial monitor


And finally, we made the Gas Sensor to sense the Gas and alert it through the LED.