How to make a GAS-level monitoring system with ESP32 board

How to make a GAS-level monitoring system with ESP32 board

Hello and welcome back. In this project, we will learn how to make a GAS-level monitoring system with an ESP32 board. For that, I mainly used the MQ2 GAS detection sensor. With this system, we can monitor these values on our smartphones or computers from anywhere in the world. For that, I used the Blynk cloud system. I think this system is most suitable for your home. Because you can try it easily and low cost.

In this project, I have additionally added an LCD display and buzzer. Therefore, we can monitor the GAS values on the LCD screen and the buzzer will automatically turn on when the GAS value increases. We can see the same process in the Blynk dashboard. You can change these values and components to your liking. Also, I have used Blynk free widgets for this project. OK, let’s move on.

If you are a new member of our SriTu Hobby website, please refer to our previous articles for more information. We are on every social media and you can check them out.

  • What’s the MQ2 sensor and how to use it – Click on me
  • How to make a GAS-level monitoring system with ESP8266 – Click on me

OK, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, connect the ESP32 board to the adapter. If you don’t have an adapter, please use two breadboards together.

Step 3

Thirdly, place the MQ-2 sensor and buzzer on the mini breadboard. And then, connect these components to the ESP32 board. For that, use the circuit diagram below.

Step 4

Now, connect the LCD screen to the ESP32 board.

Step 5

OK, let’s set up the Blynk web dashboard step by step. For that, follow the instructions below.

  • First, go to the Blynk official website and create a new account. Then, log in to your account.
  • Next, create a new template. For that, select the device as ESP32 and name it as you like. I have named it “GAS-level monitoring system”.
  • Now, click the datastreams tab and create two virtual pins.
  • Virtual Pin > Name – GAS Level / PIN – V0 / MIN – 0 / MAX – 100
  • Virtual Pin > Name – Warning LED / PIN – V1 / MIN – 0 / MAX – 1
  • Next, click the Web dashboard tab and drag and drop one gauge widget and one LED widget to the dashboard.
  • Then, click the one-by-one setting icons and select the datastream we created earlier. Also, you can change colors as you like.
  • Now, click the search icon button and create a new device. For that, select the template you created earlier. Then, you can see the Blynk auth token of this project.

OK, the Blynk web dashboard is ready for you.

Step 6

Now, let’s set up the Blynk mobile dashboard. For that, follow the instructions below.

  • First, download and install the Blynk app on your smartphone. Then, log in to your account using your email and password.
  • Next, click the template and add one gauge widget and one LED widget to the dashboard. Next, customize these widgets as you like.
  • And then, click the one-by-one widget and select the datastreams you created on the web dashboard. Also, you can change the colors as you like.

OK, the Blynk mobile dashboard is ready for you.

Step 7

Now, let’s set up the program for this project. For that, connect the ESP32 board to the computer.

How to make a GAS-level monitoring system with ESP32 board
  • Next, copy and paste the following program to the Arduino IDE.
  • Then, install the following libraries on the Arduino IDE.
  • Code and circuit diagram — Download
  • I2C library — Download
  • Blynk Library — Download
//Include the library files
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define sensor 34
#define buzzer 2

//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);

BlynkTimer timer;

// Enter your Auth token
char auth[] = "************";

//Enter your WIFI SSID and password
char ssid[] = "************";
char pass[] = "***********";

void setup() {
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  lcd.init();
  lcd.backlight();
  pinMode(buzzer, OUTPUT);

  lcd.setCursor(1, 0);
  lcd.print("System Loading");
  for (int a = 0; a <= 15; a++) {
    lcd.setCursor(a, 1);
    lcd.print(".");
    delay(200);
  }
  lcd.clear();
}

//Get the ultrasonic sensor values
void GASLevel() {
  int value = analogRead(sensor);
  value = map(value, 0, 4095, 0, 100);

  if (value >= 50) {
    digitalWrite(buzzer, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Warning!  ");
    WidgetLED LED(V1);
    LED.on();
  } else {
    digitalWrite(buzzer, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Normal   ");
    WidgetLED LED(V1);
    LED.off();
  }

  Blynk.virtualWrite(V0, value);
  Serial.println(value);
  lcd.setCursor(0, 0);
  lcd.print("GAS Level :");
  lcd.print(value);
  lcd.print(" ");
}

void loop() {
  GASLevel();
  Blynk.run();//Run the Blynk library
  delay(200);
}
  • Now, copy and paste the Blynk Auth token into this program. It’s included in the Blynk web dashboard. Then, enter your WIFI SSID and password.
  • Next, select the board and port. After, click the upload button.

Now, you can test this project. For that, power up this circuit and bring the GAS source close to the sensor. I have used a lighter for it. The full video guide is below. So, we hope to see you in the next project or tutorial.

How to make a GAS-level monitoring system with ESP32 board

How to make a GAS-level monitoring system with ESP32 board

Similar Posts

Leave a Reply

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