Introduction
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
Requirements
- Arduino Uno
- MQ5 Gas Sensor
- Bread Board
- Led
Connection
- Vcc to 5v
- Gnd to Gnd
- Signal (Middle Pin)---->Arduino
- led analog pin to 13
- Cathode to Gnd

Figure 1: MQ5 Gas Sensor
| Items | Parameter | Min |
| Vcc | Working Voltage | 4.9 |
| PH | Heating Consumption | 0.5 |
| RL | Load Resistance | - |
| RS | Sensing Resistance | 3 |
Application:
- Gas Leakage Detection
Programming:
- const int analog=A0;
- const int led=13;
- int sensor=0;
- void setup()
- {
- Serial.begin(9600); //Baud Rate
- pinMode(led,OUTPUT);
- }
- void loop()
- {
- sensor=analogRead(analog);
- if(sensor>=350)
- {
- digitalWrite(led,HIGH);
- }
- else
- {
- digitalWrite(led,LOW);
- }
- Serial.print("SensorValue = ");
- Serial.println(sensor);
- delay(10);
- }
Output


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
Conclusion
And finally, we made the Gas Sensor to sense the Gas and alert it through the LED.

Jaco ZwartsPosted Jan 30, 2016, 8:24 AM
Thank you for sharing
Shubham KumarPosted Jan 28, 2016, 1:37 AM
good
Kumaresh RajalingamPosted Jan 27, 2016, 8:32 AM
Thanks Ankit Sir
Ankit BansalPosted Jan 27, 2016, 6:16 AM
Nice share..thanks..
Pooja BaraskarPosted Jan 24, 2016, 4:56 AM
What is Gas Moisture Sensor? Never heard something like that.
Kumaresh RajalingamPosted Jan 23, 2016, 7:34 AM
Thanks Karthiga
Sr KarthigaPosted Jan 23, 2016, 5:23 AM
nice one