How to make a Gas and Smoke leakage detection system using an ESP32 board

How to make a Gas and Smoke leakage detection system using an ESP32 board

Hello and welcome back. In this project, we will learn how to make a Gas and Smoke leakage detection system using an ESP32 board. For that, I have mainly used the MQ-2 sensor. Additionally, I integrated the Blynk cloud for data reading, enabling us to monitor the system from anywhere in the world. Plus, I incorporated an LCD screen and a buzzer. The LCD screen displays sensor values, while the buzzer emits Gas and Smoke leakage detection alarms. These actions can also be viewed through the Blynk mobile and computer dashboards. I believe this project is most important for your home. Furthermore, I have designed a PCB for this project. Then, we can get a clean and organized appearance. You can easily print these PCBs with JLCPCB. We will talk about it in the making process.

(adsbygoogle = window.adsbygoogle || []).push({});

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, let’s order PCBs. For that, follow the instructions below.

  • First, go to the JLCPCB official website and log in to your account. If you are a new member of this, please use this link. Then, you can get a 60$ coupon for orders to PCBs. Also, you can order 6 Layer PCBs using the following links.
  • JLCPCB: 48-Hour Turnaround for 6 Layer PCBs! — Click on me
  • Limited Time Offer: Get $10 OFF on JLCPCB 6-Layer PCBs! — Click on me
  • Now, click the instant quote button and upload the Gerber file. You can download it using the link below.
  • Gerber file — Download
  • I have ordered 5 PCBs with white color. Then, select the build time and shipping. Finally, click the save to cart button.
  • Now, open your cart and click the secure checkout button. Then, enter your shipping details and shipping method.
  • Next, submit your order and pay for this using Paypal, Debit Card, Credit Card, or Coupon. Then, it will be received soon.
(adsbygoogle = window.adsbygoogle || []).push({});

Step 3

Thirdly, when you receive the PCB package, unbox and inspect it.

Step 4

Now, solder one by one component to the PCB.

Step 5

Next, install the LCD screen, ESP32 board, and MQ2 sensor on the PCB.

Step 6

Now, let’s set up the Blynk cloud 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.
(adsbygoogle = window.adsbygoogle || []).push({});
  • Next, create a new template. For that, select the device as ESP32 and name it as you like. I have named it “Gas and Smoke detection system”.
  • Now, click the datastreams tab and create two virtual pins.
  • Virtual Pin > Name – Gas or Smoke Level / PIN – V0 / MIN – 0 / MAX – 100
  • Virtual Pin > Name – LED Indicator / PIN – V1 / MIN – 0 / MAX – 1
  • Next, go to the web dashboard tab. Then, drag and drop the LED and Guage widgets from the widget box.
  • Then, click the one-by-one setting icons and select the datastream we created earlier. Also, you can change colors as you like. Afterward, click the save button.
  • Now click the device tab and select the template we created earlier. Finally, we can see the Blynk ID, Name, and Auth token.

OK, the Blynk web dashboard is ready for you.

Step 7

OK, 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.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 8

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

How to make a Gas and Smoke leakage detection system using an ESP32 board
  • Next, copy and paste the following program to the Arduino IDE.
  • Then, install the following libraries on the Arduino IDE.
  • Code and Gerber file — Download
  • Blynk Library — Download
//Include the library files
#include <LiquidCrystal.h>
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define sensor 34 //MQ2 sensor pin
#define buzzer 23 //Buzzer pin

LiquidCrystal lcd(2, 4, 5, 18, 19, 21);

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);
  lcd.begin(16, 2);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  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 MQ2 sensor values
void GasSmokeLevel() {
  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() {
  GasSmokeLevel();
  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.
(adsbygoogle = window.adsbygoogle || []).push({});

Step 9

Finally, adjust the LCD contrast value using the variable resistor. Then, you can power up it with a USB cable or an external 5VDC power supply. I have used a 5V DC external power supply.

Now, you can test this system with lighter and fire Smoke. The full video guide is below. So, we hope to see you in the next project. The full video guide is below. Have a good day.

Troubleshooting

  • Check your WIFI SSID and password.
  • Check the Blynk Auth token.
  • Check DC voltage.
  • Adjust the LCD contrast value.
  • Verify the health of your components.

How to make a Gas and Smoke leakage detection system using an ESP32 board

Similar Posts

Leave a Reply

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