DEV Community

Cover image for Building an IoT-Based Gas Level Monitoring System Using ESP8266 and KiwisIoT Platform
manikanda balamurugan S
manikanda balamurugan S

Posted on Edited on

Building an IoT-Based Gas Level Monitoring System Using ESP8266 and KiwisIoT Platform

Introduction

The Internet of Things (IoT) connects physical devices to the internet, allowing us to collect, transmit, and monitor data remotely.

In this project, I developed an IoT-Based Gas Level Monitoring System using an ESP8266 NodeMCU and MQ-2 Gas Sensor, integrated with the KiwisIoT Platform.

The system collects sensor readings and sends them over Wi-Fi to the KiwisIoT dashboard, where the readings are displayed using a Gauge widget.

๐Ÿ› ๏ธ Technologies Used

  • ESP8266 NodeMCU
  • MQ-2 Gas Sensor
  • Arduino IDE
  • C++ / Arduino
  • KiwisIoT Arduino Library
  • KiwisIoT Platform
  • Wi-Fi Connectivity

๐Ÿ”Œ Hardware Components

Component Quantity
ESP8266 NodeMCU 1
MQ-2 Gas Sensor 1
Jumper Wires As required
USB Cable 1

โš™๏ธ How Does It Work?

The project follows a simple IoT communication process:

  1. The MQ-2 sensor provides an analog output based on surrounding gas and smoke conditions.
  2. ESP8266 reads the sensor value through its A0 pin.
  3. The sensor reading is processed by the microcontroller.
  4. The ESP8266 connects to Wi-Fi and sends the data to KiwisIoT.
  5. The dashboard displays the received sensor value using a Gauge widget.

๐Ÿ”„ System Architecture

MQ-2 Gas Sensor
       |
       v
ESP8266 NodeMCU
       |
       v
Analog Data Reading
       |
       v
Wi-Fi Communication
       |
       v
KiwisIoT Platform
       |
       v
IoT Dashboard
       |
       v
Gauge Widget
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”— Hardware Connections

MQ-2 Sensor ESP8266
VCC 3.3V*
GND GND
AO A0

Check your particular sensor module's supply requirements and ensure its analog output is within the ESP8266 board's A0 input voltage range.

๐Ÿ’ป Software Implementation

The project is developed using Arduino IDE with the ESP8266 board package and KiwisIoT Arduino library.

The sensor value is collected using:

int gasValue = analogRead(A0);
Enter fullscreen mode Exit fullscreen mode

The reading is converted into a string:

String gasData = String(gasValue);
Enter fullscreen mode Exit fullscreen mode

The data is transmitted to KiwisIoT Channel 0:

kiwisiot.send("0", gasData);
Enter fullscreen mode Exit fullscreen mode

The ESP8266 periodically sends sensor readings to the dashboard.

๐Ÿ“Š KiwisIoT Platform Integration

One of the main parts of this project is its integration with the KiwisIoT Platform.

The platform allows the sensor data to be visualized through an IoT dashboard.

Dashboard Configuration:

  • Platform: KiwisIoT
  • Channel ID: 0
  • Widget: Gauge
  • Parameter: Gas Sensor Value

This integration makes it possible to monitor sensor readings remotely through the dashboard.

ARDUINO CODE

/*
 * Project: Gas Level Monitoring with ESP8266 and KiwisIoT
 * Project ID: KIWISIOT-006
 * Board: ESP8266 NodeMCU
 * Sensor: MQ-2 Gas Sensor
 */

#include <ESP8266WiFi.h>
#include <KiwisIoT.h>

const char* ssid = "YOUR_WIFI_NAME";
const char* pass = "YOUR_WIFI_PASSWORD";

const char* topic = "YOUR_DASHBOARD_TOPIC_ID";

#define GAS_SENSOR_PIN A0

KiwisIoT kiwisiot(ssid, pass, topic);

void sendGasLevel() {

  int gasValue = analogRead(GAS_SENSOR_PIN);

  Serial.println();
  Serial.println("---------- GAS MONITORING ----------");

  Serial.print("Gas Sensor Value: ");
  Serial.println(gasValue);

  String gasData = String(gasValue);

  kiwisiot.send("0", gasData);

  Serial.print("Sent to KiwisIoT Channel 0: ");
  Serial.println(gasData);
}

void setup() {

  Serial.begin(115200);

  Serial.println("       GAS MONITORING       ");

  pinMode(GAS_SENSOR_PIN, INPUT);

  Serial.println("Gas sensor initialized");

  Serial.println("Connecting to KiwisIoT...");

  kiwisiot.begin();

  Serial.println("KiwisIoT initialized");
  Serial.println("Starting gas monitoring...");
}

void loop() {

  kiwisiot.run();

  static unsigned long lastSend = 0;

  if (millis() - lastSend >= 2000) {

    lastSend = millis();

    sendGasLevel();
  }

  delay(100);
}
Enter fullscreen mode Exit fullscreen mode

REAL TIME IMAGE

๐ŸŽฏ Applications

  • Gas monitoring systems
  • Smoke monitoring concepts
  • Smart home applications
  • Indoor environmental monitoring
  • Industrial monitoring concepts

๐Ÿ”ฎ Future Enhancements

This project can be extended with:

  • Buzzer-based warning systems
  • Alert notification integration
  • Additional sensor integration
  • Automated monitoring features
  • IoT-based automation

๐Ÿ“š What I Learned

While developing this project, I gained practical knowledge of:

  • ESP8266 microcontroller programming
  • Analog sensor data acquisition
  • Wi-Fi communication
  • IoT platform integration
  • Sending sensor data to cloud dashboards
  • Real-time data visualization

GitHub Reference:KiwisIoT-Projects/esp8266/006-gas-kiwisiot at main ยท Kiwistron/KiwisIoT-Projects
My GitHub Repository:https://github.com/bala02102008/Gas-Level-Monitoring-System-Using-ESP8266-KiwisIoT-Platform

๐Ÿ Conclusion

This project helped me understand how hardware components and IoT platforms work together to build connected applications.

By combining the MQ-2 Gas Sensor, ESP8266 NodeMCU, and KiwisIoT Platform, I developed a system that collects sensor readings and displays them on a remote dashboard.

It was a valuable hands-on learning experience in IoT development!

Note: The displayed value is a raw analog sensor reading, not a calibrated gas concentration in PPM. This is an educational prototype and should not be used as a certified gas safety system.


Thanks for reading! Feel free to share your thoughts and suggestions.

Top comments (0)