This project implements a Gas Leak Detection System using an ESP32 microcontroller, an OLED display, a gas sensor (e.g., MQ-2), a buzzer, and Blynk for remote monitoring. When the gas level exceeds a certain threshold, the system triggers an alert using a buzzer and sends an SMS through the Notify.lk API. Additionally, the gas level is monitored and displayed in real-time using the Blynk app.
- Monitors gas levels using an analog gas sensor.
- Displays gas level and status on an OLED screen.
- Sends SMS alert when a gas leak is detected.
- Real-time monitoring via the Blynk app π±.
- Buzzer activation for gas leak warning
β οΈ . - Optional QR Code-based local monitoring
In addition to Blynk remote monitoring, the ESP32 can host a local web server that allows real-time gas level monitoring through a web browser. This feature enables users to access the system by simply scanning a QR code while connected to the same WiFi network.
This approach provides:
- Offline monitoring (no internet required)
- No mobile app dependency
- Improved privacy (local network only)
- Reduced reliance on third-party cloud services
- The ESP32 connects to a WiFi network.
- A local web server starts on port 80.
- The device generates a local IP address (e.g.,
192.168.1.105). - A QR code encodes the URL:
- ESP32 board
- OLED Display (SSD1306)
- Gas sensor (MQ-2)
- Buzzer
- Blynk account
- Adafruit_SSD1306: For controlling the OLED display.
- BlynkSimpleEsp32: For connecting the ESP32 to the Blynk app.
- WiFi: For Wi-Fi connectivity.
- HTTPClient: For sending HTTP requests to the Notify.lk API.
-
Clone the repository to your local machine.
-
Install the required libraries:
Adafruit_SSD1306BlynkSimpleEsp32WiFiHTTPClient
-
Update the code:
- Replace the Wi-Fi credentials (
ssidandpass). - Replace the Blynk authentication token (
auth). - Replace Notify.lk API credentials (
notifylk_user_id,notifylk_api_key,notifylk_sender_id,recipient_number).
- Replace the Wi-Fi credentials (
-
Hardware setup:
- Connect the gas sensor (e.g., MQ-2) to the sensor pin (GPIO 34 on ESP32).
- Connect the buzzer to the buzzer pin (GPIO 2 on ESP32).
- Connect the OLED display (SSD1306) to the I2C pins (default SDA and SCL on ESP32).
-
Upload the code to the ESP32.
-
Open the Blynk app to monitor gas levels in real-time π².
-
Ensure the ESP32 connects to your WiFi network.
-
Upload the firmware that includes WebServer functionality.
-
Open Serial Monitor after upload.
-
Copy the displayed IP address (e.g., 192.168.1.105).
-
Generate a QR code using:
http://
-
Scan the QR code from a device connected to the same WiFi network.
-
View the real-time gas monitoring dashboard in your browser.