Industrial Safety Monitoring System With ESP8266, Gas, Flame, DHT11, PIR & KiwisIoT

by Keerthana Dass in Circuits > Electronics

9 Views, 0 Favorites, 0 Comments

Industrial Safety Monitoring System With ESP8266, Gas, Flame, DHT11, PIR & KiwisIoT

cover image.png

Industrial environments can have multiple safety risks such as gas leakage, fire, high temperature, and unexpected movement. In this project, we will build an Industrial Safety Monitoring System using an ESP8266 NodeMCU, gas sensor, flame sensor, DHT11, PIR motion sensor, and KiwisIoT.

The system continuously monitors gas level, flame detection, temperature, and motion. Based on the sensor readings, it determines whether the overall safety condition is NORMAL or ALERT.

All the important information is sent to a KiwisIoT dashboard, allowing us to monitor the safety conditions remotely.

The dashboard displays:

  1. 🔥 Gas Level
  2. 🔥 Flame Status – True / False
  3. 🌡️ Temperature
  4. 🚶 Motion Status – Motion / No Motion
  5. ⚠️ Safety Status – ALERT / NORMAL

Supplies

Hardware

  1. ESP8266 NodeMCU
  2. Gas sensor module
  3. Flame sensor module
  4. DHT11 temperature and humidity sensor
  5. PIR motion sensor
  6. Jumper wires
  7. USB cable

Software

  1. Arduino IDE
  2. ESP8266 Board Package
  3. KiwisIoT Library
  4. DHT Sensor Library
  5. Adafruit Unified Sensor Library
  6. KiwisIoT account

How the Project Works

The ESP8266 collects data from four different sensors.

The gas sensor provides an analog gas level through A0.

The flame sensor detects whether a flame is present.

The DHT11 measures the surrounding temperature.

The PIR sensor detects movement.

The ESP8266 processes these readings and determines the overall safety condition.

The gas threshold used in this project is:

Gas Value >= 500
↓
Gas Alert

If a flame is detected:

Flame Detected
↓
Flame Alert

The overall safety status is calculated using both conditions:

Gas Alert OR Flame Alert
↓
ALERT

If neither condition is detected:

No Gas Alert + No Flame
↓
NORMAL

The sensor values are then sent to KiwisIoT.

Circuit Connections

circuit.png

Gas Sensor

VCC → Vin
GND → GND
AO → A0

Flame Sensor

VCC → 3.3V
GND → GND
DO → D5

DHT11 Sensor

VCC → 3.3V
DATA → D2
GND → GND

PIR Motion Sensor

VCC → 3.3V
GND → GND
OUT → D7

KiwisIoT Configuration

Create a new panel in KiwisIoT and copy the Topic ID.

The project uses five channels:

Channel 0 → Gas Level

Channel 1 → Flame Status

Channel 2 → Temperature

Channel 3 → Motion Status

Channel 4 → Safety Status

For the dashboard, you can add five display widgets:

  1. Gas Level
  2. Flame Status
  3. Temperature
  4. Motion Status
  5. Safety Status

The widgets can display values such as:

Gas Level:

748

Flame Status:

True
False

Temperature:

33.8 °C

Motion Status:

Motion
No Motion

Safety Status:

ALERT
NORMAL


Install the Required Libraries

Open Arduino IDE and install:

  1. DHT sensor library
  2. Adafruit Unified Sensor
  3. KiwisIoT

Make sure the ESP8266 board package is also installed.

Select:

Tools → Board → ESP8266 → NodeMCU 1.0 (ESP-12E Module)

Arduino Code

code_832x551.png

Paste the following code into Arduino IDE:

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

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

const char* topic = "YOUR_DASHBOARD_TOPIC_ID";

#define GAS_PIN A0
#define FLAME_PIN D5
#define DHT_PIN D2
#define PIR_PIN D7

#define DHT_TYPE DHT11

DHT dht(DHT_PIN, DHT_TYPE);

const int GAS_THRESHOLD = 500;

KiwisIoT kiwisiot(ssid, pass, topic);

void sendSafetyStatus() {

int gasValue = analogRead(GAS_PIN);
int flameState = digitalRead(FLAME_PIN);
int pirState = digitalRead(PIR_PIN);
float temperature = dht.readTemperature();

String flameStatus;

if (flameState == LOW) {
flameStatus = "True";
}
else {
flameStatus = "False";
}

String motionStatus;

if (pirState == HIGH) {
motionStatus = "Motion";
}
else {
motionStatus = "No Motion";
}

bool gasAlert = gasValue >= GAS_THRESHOLD;
bool flameAlert = (flameState == LOW);
bool safetyAlert = gasAlert || flameAlert;

String safetyStatus;

if (safetyAlert) {
safetyStatus = "ALERT";
}
else {
safetyStatus = "NORMAL";
}

Serial.println();
Serial.println("---------- INDUSTRIAL SAFETY ----------");

Serial.print("Gas Level: ");
Serial.println(gasValue);

Serial.print("Flame Status: ");
Serial.println(flameStatus);

if (isnan(temperature)) {
Serial.println("Temperature: Sensor Error");
}
else {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
}

Serial.print("Motion Status: ");
Serial.println(motionStatus);

Serial.print("Safety Status: ");
Serial.println(safetyStatus);

kiwisiot.send("0", String(gasValue));
kiwisiot.send("1", flameStatus);

if (!isnan(temperature)) {
kiwisiot.send("2", String(temperature, 1));
}

kiwisiot.send("3", motionStatus);
kiwisiot.send("4", safetyStatus);

Serial.println();
Serial.println("KiwisIoT Data Sent");

Serial.print("Channel 0 - Gas Level: ");
Serial.println(gasValue);

Serial.print("Channel 1 - Flame Status: ");
Serial.println(flameStatus);

if (!isnan(temperature)) {
Serial.print("Channel 2 - Temperature: ");
Serial.println(temperature);
}

Serial.print("Channel 3 - Motion Status: ");
Serial.println(motionStatus);

Serial.print("Channel 4 - Safety Status: ");
Serial.println(safetyStatus);

Serial.println("---------------------------------------");
}

void setup() {

Serial.begin(115200);

Serial.println();
Serial.println("======================================");
Serial.println(" INDUSTRIAL SAFETY MONITORING");
Serial.println("======================================");

pinMode(FLAME_PIN, INPUT);
pinMode(PIR_PIN, INPUT);

dht.begin();

Serial.println("Sensors initialized");

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

kiwisiot.begin();

Serial.println("KiwisIoT initialized");

Serial.println("Starting industrial safety monitoring...");
}

void loop() {

kiwisiot.run();

static unsigned long lastSend = 0;

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

lastSend = millis();

sendSafetyStatus();
}

delay(100);
}

Understanding the Safety Logic

The project uses the following gas threshold:

const int GAS_THRESHOLD = 500;

Gas Level

If the gas value is greater than or equal to 500:

Gas Value >= 500
↓
Gas Alert

If the gas value is below 500:

Gas Value < 500
↓
Normal Gas

Flame Detection

The flame sensor uses a LOW signal to indicate flame detection.

LOW
↓
Flame Detected

HIGH
↓
No Flame

Overall Safety Status

The project combines gas and flame conditions:

Gas Alert OR Flame Alert
↓
ALERT

Otherwise:

No Gas Alert + No Flame
↓
NORMAL

PIR Motion Detection

The PIR sensor is connected to D7.

The ESP8266 checks the PIR output:

HIGH
↓
Motion

LOW
↓
No Motion

The motion status is sent to KiwisIoT through Channel 3.

Example:

Motion Status: Motion

or

Motion Status: No Motion

DHT11 Temperature

The DHT11 is connected to D2.

The ESP8266 reads the temperature using:


float temperature = dht.readTemperature();

The temperature is displayed in the Serial Monitor and sent to KiwisIoT through Channel 2.

Example:

Temperature: 33.8 °C

If the DHT11 reading fails, the Serial Monitor displays:

Temperature: Sensor Error

Sending Data to KiwisIoT

The project sends five values to KiwisIoT:

kiwisiot.send("0", String(gasValue));
kiwisiot.send("1", flameStatus);
kiwisiot.send("2", String(temperature, 1));
kiwisiot.send("3", motionStatus);
kiwisiot.send("4", safetyStatus);

The dashboard receives:

Channel 0 → Gas Level
Channel 1 → Flame Status
Channel 2 → Temperature
Channel 3 → Motion Status
Channel 4 → Safety Status

The data is updated every 2 seconds.

Testing the Project

serial_monitor_832x551.png

After uploading the code, open the Serial Monitor.

Set the baud rate to:

115200

During testing, you should see output similar to:

---------- INDUSTRIAL SAFETY ----------
Gas Level: 748
Flame Status: False
Temperature: 33.8 °C
Motion Status: Motion
Safety Status: ALERT

KiwisIoT Data Sent
Channel 0 - Gas Level: 748
Channel 1 - Flame Status: False
Channel 2 - Temperature: 33.8
Channel 3 - Motion Status: Motion
Channel 4 - Safety Status: ALERT
---------------------------------------

When the gas level is below the threshold and no flame is detected, the safety status becomes:

Safety Status: NORMAL

When the gas level reaches the threshold or a flame is detected:

Safety Status: ALERT

KiwisIoT Dashboard

dashboard_output_832x551.png

The final KiwisIoT dashboard can contain five widgets:

Gas Level

Displays the current gas sensor reading.

Example:

748

Flame Status

Displays:

True

or

False

Temperature

Displays the temperature measured by the DHT11.

Example:

33.8 °C

Motion Status

Displays:

Motion

or

No Motion

Safety Status

Displays the overall safety condition:

ALERT

or

NORMAL

This provides a simple real-time view of the industrial safety monitoring system.

Result

The completed system successfully monitors gas level, flame status, temperature, and motion using an ESP8266.

When the gas level reaches the defined threshold or a flame is detected, the system changes the overall safety status to ALERT.

The sensor information is also sent to the KiwisIoT dashboard, where the different safety parameters can be monitored remotely.

The final dashboard shows:

Gas Level | Flame Status | Temperature | Motion Status | Safety Status

This makes the project a simple practical example of combining ESP8266, multiple sensors, safety monitoring, and IoT.

Applications

This project can be adapted for:

  1. Industrial safety monitoring
  2. Workshops
  3. Laboratories
  4. Storage areas
  5. Factory environments
  6. Equipment rooms
  7. Server or electrical rooms
  8. IoT-based safety monitoring
  9. Student IoT projects
  10. Safety monitoring prototypes

Future Improvements

The system can be expanded by adding:

  1. 🚨 Buzzer for local alarm
  2. 💡 Warning LED indicators
  3. 📱 Mobile notifications
  4. 📧 Email alerts
  5. 📊 Historical sensor graphs
  6. 🌡️ Additional environmental sensors
  7. 🖥️ Larger monitoring dashboards
  8. 🔔 Automatic emergency alerts
  9. 📷 Camera-based monitoring
  10. ☁️ Cloud-based data logging

Conclusion

This Industrial Safety Monitoring System with ESP8266, Gas, Flame, DHT11, PIR & KiwisIoT demonstrates how multiple sensors can be combined to monitor important safety conditions through an IoT platform.

The ESP8266 collects and processes the sensor readings, while KiwisIoT provides a real-time dashboard for monitoring gas level, flame status, temperature, motion, and the overall safety condition.

The project can serve as a basic foundation for developing more advanced IoT-based industrial safety monitoring systems.