top of page

Using MQ5 Sensor with Arduino

Updated: Aug 8, 2021

In this tutorial, we will be learning how we can use MQ5 with Arduino to detect Gas Leakage in our environment. In this simple project, we will be detecting the leakage of LPG(gas) and trigger an alarm by using a buzzer in case of LPG gas presence detected beyond a particular threshold level.

Before using MQ5 Sensor, we need to know if MQ5 Sensor can detect the gas that we are trying to identify. Different MQ sensors are sensitive towards different types of gaseous, hence it is important to know which one to use.

Having that said, let's move on the circuit diagram. The connection between Arduino, MQ5 and Buzer are as shown below.

Once the above connection has been setup, we can now upload the below code into Arduino.

 

int alarm = 8;

int smokeLevel = A5;

int threVal = 250;


void setup() {

// put your setup code here, to run once:

pinMode(alarm,OUTPUT);

pinMode(smokeLevel,INPUT);

Serial.begin(9600);

}


void loop() {

int sensorVal = analogRead(smokeLevel);

Serial.println(sensorVal);


if(sensorVal > threVal){

tone(alarm,2000,200);

}

else{

noTone(alarm);

}

}

 

Level of LPG gases can be detected in Serial Monitor. Refer screenshots below.

LOW/NO LPG Gas Detection

HIGH LPG GAS Detection


For more detailed instruction on this tutorial, feel free to check out my step by step video on using MQ5 with Arduino.


Comentários


bottom of page