NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

LPG (Liquid Petroleum Gas) is use almost in every house for cooking purpose. This gas is highly inflammable and need to be careful while using it. There are situations where accidents have occurred and huge damage has is done. In this article we will build a LPG gas detection system using MQ5 Sensor. The project NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm will be built using MQ5 gas sensor and Blynk.

You can monitor the gas level or leakage from your smartphone. This project is easy to build with minimum components. Lets see how we can build NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm.

Materials Required

  • MQ5 gas sensor  x 1
  • NodeMCU ESP8266 x 1
  • 5V Buzzer x 1
  • Led Red x 1
  • Led Green x 1
  • Resistor 220Ω x 2
  • Jumper Wires
  • Breadboard
  • Mobile Charger as power supply(5v/1A)

How it Works?

The MQ-5 gas sensor has a sensitive filament which is made of SnO2. When there is no presence of gas or the air is clean then, the filament will tends to have low electrical conductivity. If the sensor detects combustible gas like LPG, the filament’s electrical conductivity rises.The amount of change in filament’s conductance or resistance is used to indicate the equivalent gas concentration.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

In this project we will be using blynk esp8266 based NodeMCU. When the gas concentration will increase, a blynk notification will be sent to your smartphone. This is how this gas leakage detection system works.

Sensors and Modules Functions

MQ5 Gas Sensor

This is a gas sensor which detects using a filament SnO2, which is sensitive to LPG, Methane and natural gas. Apart from these gases it is also sensitive to other flammable gases. This sensor is used for building gas leakage detecting equipment. This can be used at home and industry. The sensitivity of the sensor can be adjusted by using the potentiometer which is available at the back of the module.

Features of MQ5

  • High sensitivity to LPG, natural gas and coal gas
  • Partially able to identify alcohol and smoke
  • Quick response in detection
  • It is Stable and has long life
  • Driver circuit is simple

This module can provide us two outputs analog out (A0) and digital out (D0). Through analog output you can measure the gas leakage and also measure the gas volume which is PPM. The digital output gives either High or Low values. This is used to detect gas leakage and trigger an alert. Its more suitable for detection of gas leakage.

NodeMCU

ESP8266 NodeMCU

NodeMCU is the main part of this project. It gets the input from MQ5 sensor and send it to Blynk app. It will also control buzzer and led’s as per code. This project can also be known as gas leakage detector using nodemcu.

More Projects:

Circuit Diagram

Below components are mounted on a breadboard. The GREEN wire is  connected from analog output pin of MQ5 gas sensor to A0 pin of NodeMCU. This entire project is connected to 5V DC.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

MQ5 sensor takes approx 15-20min for warm up hence it might not show you the correct reading after powering on the circuit immediately. Red light will indicate gas leakage and Green light will indicate no leakage.

Blynk Setup

Its a simple blynk set up using Blynk app. Install it from play store or iOS app store.

Open Blynk App and tap on New Project

Blynk config

Enter a name of the project, Choose device as NodeMCU and tap on Create.

Blynk setup

An Auth  Token will be sent to your registered email address. Tap on OK

Blynk Token

Now tap on the highlighted icon to add widgets

adding widgets

Scroll down and select Gauge

safety from fire

Scroll down and select Notification widget

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

Tap on Gauge and configure it with below parameters.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

Finally your Blynk Project is ready. Press the triangular play button to start.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

Once your project is ready and the hardware is connected with blynk then it will show the gas level.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

Code

You can copy paste the code below in Arduino IDE and upload the code in NodeMCU.


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
char auth[] = "Auth_Token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Your_SSID";
char pass[] = "Your_Network_Password";

int buzzer = D2; //buzzer
int sensor = A0; //sensor
int led_green = D5; //no leakage indication
int led_red = D6; // leakage indication

// Define threshold value. You might need to change it.
int sensor_limit = 600;

void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(sensor, INPUT);
pinMode(led_green, OUTPUT);
pinMode(led_red, OUTPUT);
digitalWrite(led_green, LOW);
digitalWrite(led_red, LOW);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}

void loop()
{
int sensor_value = analogRead(sensor);
Serial.print("Gas Level: ");
Serial.println(sensor_value);
Blynk.virtualWrite(V1, sensor_value);
// Checks if it has reached the threshold value
if (sensor_value > sensor_limit)
{
digitalWrite(led_green, HIGH);
digitalWrite(led_red, LOW);
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
Blynk.notify("Alert: Gas Leakage Detected");
}
else
{
digitalWrite(buzzer, LOW);
digitalWrite(led_green, LOW);
digitalWrite(led_red, HIGH);
}
delay(100);
Blynk.run(); // Initiates Blynk
}

Construction

The entire project is assembled on a bread board very easily. You can use the same code and use WeMos D1 mini replacing NodeMCU.

NodeMCU ESP8266 IoT based LPG Gas Leakage Alarm

Testing

Once you power on the the project the MQ5 sensor will take 20-30min to warm up. During this time you might get a bad smell but nothing to worry, after some time it will disappear. Once the sensor is ready the gas level will be steady.

The green light will be ON indicating no gas leakage detected. The buzzer will also be is OFF state. In Case any gas detected and the gas level increases beyond 600, then red light will turn ON indicating gas leakage. You will also get notified by blynk app as an alert.

Conclusion

This project is simple to build and effective to use at home for safety from fire. This is one of the most important part of home safety. Even if you stay away from home you will come to know if there is any gas leak. You can make enhancements on this project and comment below.

Leave a Comment