fbpx

ESP8266 – GAS monitor

A gas detector is a device that detects the presence of gases in an area.Sense the gas and indicates the warning. Gas detector is use to find the leakage of gas in gas station. Integrating gas detector with esp8266 and connected with cloud makes the gas detector more smart, when higher amount of gas detected it gives alert to fire station without human intervention.

Block Diagram

Flow Chart

Component Required

  1. Node MCU.
  2. Gas Sensor
  3. Jumper wire
  4. BreadBoard

Software Required:

  1. MIT App inventor – Android
  2. Firebase
  3. Arduino 

Circuit diagram:

Firebase:

Login To firebase

  • create new project
  • Create database for Gas monitoring device
  • Set firebase security rules to test mode to allow esp8266 to set and read database
  • Set Rules of firebase to read and write in real time database
  • Select Real-time Database 
  • Copy the URL- Required in code as firebase host-id to communicate with firebase
  • Click to add child to Create a field to hold data in firebase
  • Create gas field to hold gas data in firebase.
  • Gas field in realtime database hold Gas data.
  • Get authentication id from firebase.

Android Application:

  • Create New project from mit app inventor for gas monitoring
  • Select layout to place the user interface component
  • Create a header from the Android application: 

                 drag and drop label in the screen for app header

Android App

Code

 #include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

#define FIREBASE_HOST " "
const char* ssid = "IMAKE"; // Your ssid
const char* password = "12345678"; // Your Password
#define Gas_sensor A0
int Gas_Threshold = 400;
void setup()
{
pinMode(Gas_sensor,INPUT);
Serial.begin(115200);
delay(100);
dht.begin();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi is connected");
Serial.println(WiFi.localIP());
delay(1000);
Firebase.begin(FIREBASE_HOST);
}

void loop()
{
int Gas_sensor_value = analogRead(Gas_sensor);

if(Gas_sensor_value > Gas_Threshold)
{
Firebase.setString("Gas","Detected");
}
else
{
Firebase.setString("Gas","Not_Detected");
}
delay(1000);
} 

1 comment on “ESP8266 – GAS monitor

Leave a Reply

Your email address will not be published. Required fields are marked *