ESP8266 Smart Gas Leakage Detection Using MQ-2 & KiwisIoT Cloud Platform
by prakatheeshwaranR in Circuits > Microcontrollers
82 Views, 0 Favorites, 0 Comments
ESP8266 Smart Gas Leakage Detection Using MQ-2 & KiwisIoT Cloud Platform
Gas monitoring is important in homes, laboratories, industries, kitchens, and other environments where combustible or harmful gases may be present.
In this project, I built a simple IoT-based gas monitoring system using an MQ gas sensor and an ESP8266 NodeMCU (ESP-12E).
The MQ gas sensor detects changes in gas concentration in the surrounding air. The ESP8266 reads the sensor value and sends the data through Wi-Fi to the KiwisIoT cloud dashboard.
The gas level can then be monitored remotely in real time using a Gauge widget.
The basic working flow is:
Gas in Air → MQ Gas Sensor → ESP8266 → Wi-Fi → KiwisIoT Cloud → Live Dashboard
This is a beginner-friendly project for learning how sensors, microcontrollers, Wi-Fi, and IoT dashboards work together.
Note: This project is intended for learning and prototyping. It should not be used as a certified life-safety or industrial gas alarm.
Supplies
For this project, I used:
- ESP8266 NodeMCU development board with ESP-12E module
- MQ-series gas sensor module
- Jumper wires
- Micro-USB cable
- Laptop/PC
- Wi-Fi connection
- Arduino IDE
- KiwisIoT account/dashboard
- Platform:https://kiwisiot.in/
For your Supplies section, upload your separate ESP8266 photo and separate MQ sensor photo. Those real photos are much better here than generated component images.
Understanding the ESP8266 NodeMCU
The ESP8266 NodeMCU is a Wi-Fi-enabled development board based on the ESP8266 microcontroller.
It is useful for IoT applications because it can read sensor data, process the readings, connect directly to a Wi-Fi network, and communicate with an online IoT platform.
In this project, the ESP8266 performs two main jobs:
- Reads the gas sensor value.
- Sends the reading to the KiwisIoT dashboard through Wi-Fi.
Understanding the ESP8266 NodeMCU
The MQ-series gas sensor is designed to respond to gases present in the surrounding air.
The module provides a signal whose value changes according to the sensor response.
For this project, we use the sensor reading as our Gas Value and send it to the ESP8266.
The sensor module generally provides pins such as:
VCC – Power
GND – Ground
AO – Analog Output
DO – Digital Output, if provided by the module
The analog output is useful when we want to observe changes in the sensor reading instead of only receiving a simple HIGH/LOW indication.
Connect the MQ Sensor to ESP8266
Connect the MQ gas sensor module to the ESP8266 NodeMCU.
For the analog-reading part of this project, the important connections are:
Important: ESP8266 I/O works at 3.3 V, and the allowable A0 input depends on the exact NodeMCU board design. Some MQ modules are powered at 5 V and can produce an output higher than the ESP8266 ADC can safely accept. Check your specific sensor module and NodeMCU specifications and use a voltage divider/level conditioning when necessary.
After completing the connections, connect the ESP8266 to the computer using the USB cable.
Install and Configure Arduino IDE
Download and install the Arduino IDE.
Then add ESP8266 board support and select the appropriate NodeMCU board.
Typical setup:
Connect the board using the USB cable and verify that Arduino IDE detects the correct port.
Read the Gas Sensor Value
Before connecting the project to the cloud, first verify that the ESP8266 is receiving sensor readings correctly.
A basic analog test can be done with:
Upload the program and open:
Tools → Serial Monitor
Set:
Baud Rate: 9600
You should start seeing values similar to:
The values will change according to the sensor response.
Image: This is exactly where your Arduino screenshot should go. Your screenshot already shows readings around 235–236, so it provides good evidence that the sensor and ESP8266 are communicating.
Don't describe 235 as a specific gas concentration or danger level unless you have calibrated the particular MQ sensor for the target gas.
Convert It Into an IoT Project
Once the sensor reading is working correctly, the next step is to send the data to the cloud.
The ESP8266 connects to the Wi-Fi network and sends the gas sensor value to the KiwisIoT platform.
The complete data flow becomes:
This is what converts our basic sensor project into an IoT project.
Instead of viewing the reading only on the computer connected to the ESP8266, we can monitor the sensor through an online dashboard.
Connect ESP8266 to KiwisIoT
In my project, I used the KiwisIoT library to connect the ESP8266 to the KiwisIoT platform.
The program follows this structure:
Replace the Wi-Fi and topic details with your own credentials.
Very important before publishing: Don't put your real Wi-Fi password, private API keys, access tokens, or other credentials in the Instructables screenshots/code. Blur or replace them with placeholders such as YOUR_WIFI_PASSWORD.
Monitor the Gas Value on KiwisIoT Dashboard
After the ESP8266 connects successfully, the gas sensor data is transmitted to the KiwisIoT dashboard.
I added a Gauge widget to display the live sensor value.
During testing, the dashboard displayed a value such as:
285
The gauge provides a simple visual way to monitor changes in the sensor reading.
The complete communication is:
MQ Sensor → ESP8266 → Wi-Fi → KiwisIoT → Gauge
Your KiwisIoT screenshot is perfect for this step because it visibly shows:
Connected → Online → Gauge → 285
How the Complete System Works
The complete operation can be understood in five stages.
1. Detection: The MQ sensor responds to gas in the surrounding air.
2. Reading: The ESP8266 reads the analog sensor signal through the configured analog input.
3. Processing: The ESP8266 converts the ADC result into a value that can be displayed and transmitted.
4. IoT Communication: Using its built-in Wi-Fi capability, the ESP8266 sends the value to KiwisIoT.
5. Monitoring: The KiwisIoT dashboard receives the data and displays the current gas sensor reading using the Gauge widget.
Testing the Project
Power the ESP8266 through USB and allow the MQ sensor enough time to stabilize according to the sensor manufacturer's recommendations.
Open Arduino Serial Monitor and confirm that values are being received.
Then open the KiwisIoT dashboard.
Check that:
During my test, the Serial Monitor showed values around 235–236, while the dashboard screenshot captured a later live value of 285.
Possible Improvements
This basic project can be expanded with additional features.
You can add a buzzer and warning LED for local alerts, configure dashboard alerts, add an OLED/LCD display, store historical readings, add multiple sensors, or create automatic control using a relay.
A more advanced version could follow:
Gas detected → ESP8266 → Cloud → Alert → Exhaust fan/relay control
For meaningful gas concentration or alarm thresholds, however, the sensor should be properly calibrated for the particular gas and application.
Applications
This type of IoT gas-monitoring prototype can be used as a learning foundation for projects involving:
- Smart-home environmental monitoring
- Kitchen monitoring prototypes
- Laboratory demonstrations
- Industrial IoT education
- Air-quality experiments
- IoT sensor-data logging
- Remote environmental monitoring
For real safety-critical environments, certified gas-detection equipment should be used rather than a hobby MQ/ESP8266 prototype.
Conclusion
In this project, we successfully interfaced an MQ gas sensor with an ESP8266 NodeMCU and monitored the sensor reading using the KiwisIoT IoT dashboard.
First, the ESP8266 reads the analog sensor value. We verified the reading using Arduino Serial Monitor. The ESP8266 then uses Wi-Fi to transmit the data to KiwisIoT, where it can be displayed using a live Gauge widget.
The project demonstrates the basic IoT workflow:
Sense → Read → Process → Connect → Send → Monitor
It is a simple starting point for beginners who want to learn ESP8266, sensors, Arduino programming, Wi-Fi communication, and IoT dashboards.
Best order for your actual images
Use your ESP8266 close-up in Step 1, MQ sensor close-up in Step 2, connected hardware photo in Step 3, Arduino Serial Monitor screenshot in Step 5/7, and KiwisIoT Gauge screenshot in Step 8. That sequence tells the story naturally: components → wiring → code → sensor data → cloud result.