Contents
Download PDF
pdf Download XML
2576 Views
234 Downloads
Share this article
Research Article | Volume 6 Issue 1 (January-June, 2025) | Pages 1 - 5
Enhanced IoT-Based Environmental Monitoring System Using MQTT with Real-Time Alerts and Predictive Analytics
1
Mathematics Department, Education of Girls College, Tikrit University, Tikrit, Iraq
Under a Creative Commons license
Open Access
Received
March 15, 2025
Revised
April 22, 2025
Accepted
May 19, 2025
Published
June 20, 2025
Abstract

We present an IoT environmental monitoring system that  uses three innovative features to improve traditional methods: ESP32-based sensor nodes with DHT22 sensors (30-second sampling,  ±0.5°C/±2% RH accuracy, JSON payloads), real-time alerting via MQTT (QoS 1 + TLS) and Node-RED (SMS/email in <5s), and predictive analytics using linear regression  (85% accuracy for >2°C/5% RH trends). The Raspberry Pi-based system with Mosquito broker demonstrates 99.8% message reliability and 99.2% uptime during 30-days tests across residential place. Our solution costs less than $50 per node while using open-source tools (InfluxDB/SQLite) to achieve incident response time reduction from hours to seconds and risk forecasting accuracy of 20-40 minutes ahead of existing passive monitoring systems.

Keywords
INTRODUCTION

The preservation of sensitive materials alongside human comfort depends on maintaining proper indoor environmental conditions. Fluctuated environment can damage materials and leads to money losses, for instance the annual restoration costs for museums can be very high because of unstable temperature and humidity levels which damage the artifacts [1].  Also, improper monitoring of environmental conditions in residential and commercial areas results in mold growing and energy waste which affects both health and operational expenses [2]. The Internet of Things (IoT) technology provides better environmental monitoring assets yet most systems function reactively instead of preventively. Most environmental monitoring solutions have three major limitations. The commercial products mainly focus on basic data visualization without integrating predictive capabilities [3]. Academic prototypes which utilize MQTT protocols mainly focus on technical performance metrics and neglecting the development of user-friendly interfaces for not expert users [4]. Traditional manual environmental monitoring techniques in cultural heritage settings operate reactively which leads to substantial delays when responding to environmental threats. The current systems lack real-time monitoring and predictive analysis capabilities which shows limitations in protecting sensitive cultural assets [5]. These limitations encourage us to develop a monitoring system that combine automated alert systems with predictive analytics and real-time monitoring capabilities.

 

The research introduces an advanced IoT environmental monitoring system which solves these problems through three main improvements. The system uses ESP32 microcontrollers with DHT22 sensors as its hardware base because these components provide both reliability and cost-effectiveness [6]. The system applies MQTT's publish-subscribe model for efficient data transmission and Node-RED's visual programming interface for accessible data processing and visualization [7]. For predictive analysis, the system uses moving-average algorithms every 30-60 minutes to forecast environmental trends advance. The system proves its effectiveness through experimental results which show 99.2% reliable data transmission and five-second alert after exceeding threshold. The value of this work stems from its ability to strike a balance between performance and usability and cost. Our open−source implementation costs less than $50 per monitoring node while providing better functionality than proprietary solutions that exceed $200 per node. The system framework provides easy sensor and machine learning component additions which makes it suitable for multiple applications such as museum conservation and smart building automation.        

 

Related Work

The previous IoT environmental system described in [6] analyzed large-scale climate trends through multi-sensor fusion and cloud analytics. Our research optimizes low-cost high-frequency indoor monitoring with embedded predictive models to connect macroscopic trends to localized preventive actions. The authors of [7] show that low-cost sensor networks can monitor air quality effectively through cloud-based analytics. The system's use of centralized data processing and generic HTTP-based communication creates latency that makes it unsuitable for real-time preventive actions. The authors of [8] demonstrate how IoT transforms environmental monitoring through multi-sensor integration for air/water quality and waste management. The system we developed fills a crucial need which they mention as requiring low-latency edge-based solutions. Our system achieves < 5 second alert latency through MQTT’s QoS-1 protocol and ESP32 edge computing which outperforms the traditional HTTP/cloud systems reviewed by them. 

 

Ullo and Sinha [9] examine smart environmental monitoring (SEM) systems that use IoT and sensors in domains including air and water quality, radiation, and agriculture. The authors identify three main obstacles which include sensor interoperability problems and the absence of real-time processing capabilities and restricted predictive analytics capabilities that our system resolves through edge-based alerts and embedded forecasting. Sunny et al. [10] created an IoT-based multi-sensor system that operates at low cost and monitors harsh environments by focusing on hydrogen gas and temperature measurements in nuclear waste storage facilities. The system employed commercial off-the-shelf components and solar power and Wi-Fi connectivity to monitor data in real-time through Thing Speak. This system focuses on robustness and power efficiency in extreme environment, our work extends these aspects to more general environmental monitoring applications, adding predictive analytics and MQTT-based communication for improved responsiveness and scalability. Rani [11] used a robotic IoT monitor with DHT11/MQ135 sensors and ThingSpeak integration to collect data autonomously but HTTP latency limited its performance. Our framework enhances the existing system through MQTT-based edge analytics which decreases alert delays to sub-5 seconds and enables predictive functionality. Piramuthu in [12] showed how IoT systems help agricultural sustainability through sensor networks and RFID tracking which decreases food waste. The macro-level supply chain optimization of their work does not address the real-time monitoring needs of indoor environments which our edge-based predictive analytics framework addresses through its latency-critical functionality. Anuar demonstrated a cost-effective IoT system for temperature/humidity monitoring using NodeMCU ESP8266 and DHT11 sensors in his recent work [13] which displayed data on the Arduino IoT Cloud and sent alerts through IFTTT. The system achieved real-time monitoring (99% accuracy) for industrial applications through HTTP-based cloud integration yet experienced higher notification latency (~5–10 seconds) than our MQTT QoS-1 protocol (sub-5-second alerts). The system's basic threshold alerts differ from our predictive analytics (85% accuracy for trend forecasting) which shows how IoT environmental monitoring systems must choose between simple and advanced features. The success of their edge devices (ESP8266) supports our selection of ESP32 for dependable data acquisition.

MATERIALS AND METHODS

Proposed Framework: Architecture, Components, and Methodology 

The proposed framework presents an advanced IoT-based environmental monitoring system shown in Figure1, which combines real-time alerts with predictive analytics through a scalable architecture. The system introduces three major improvements beyond traditional data collection methods:

 

  • Edge-based predictive modeling

  • Multi-channel alerting with sub-5-second latency

  • A modular design that supports heterogeneous sensor integration.

 

The system architecture consists of four interconnected layers which include physical sensing, secure communication, centralized processing and user interaction optimized for reliability and extensibility. The physical layer of distributed sensor nodes consists of ESP32 microcontrollers which work together with DHT22 environmental sensors. The nodes measure temperature and humidity data every 30 seconds while using onboard calibration to adjust for sensor drift. The ESP32 devices use power-saving transmission protocols which decrease power usage by 60% through their optimized deep sleep cycle implementation. The system tracks all sensor data using timestamp with JSON payload packaging and for traceability it uses device identifier tags. The communication layer depends on MQTT and Quality of Service (QoS) Level 1 to ensure message delivery while keeping bandwidth usage low. The hierarchical topic structure (e.g., env/museum/north_wing/temperature) used to enable fine-grained access control and efficient data routing. The Mosquitto broker running on a Raspberry Pi with TLS encryption supports 50 nodes during testing which provide a reliability of delivers messaging. 

 

 

Figure 1: Architecture of the Enhanced Iot Environmental Monitoring System

 

Generated image

 

Figure: 2 Labeled Hardware Setup with Esp32, Dht22 Sensors, and Raspberry Pi

 

The lightweight protocol allows real-time data transmission and consistent sub-second latency between measurement and cloud reception. The Node-RED is used as central intelligence hub for data processing and analytics. The platform performs three main operations: First, it uses linear regression on 15-minute data segments to create forecasted humidity and temperature trends which display as lines on the dashboard. Second, the system uses Twilio for SMS alerts and SMTP for email alerts to notify users when measurements surpass their defined thresholds (30°C or 70% RH). Third, a REST API is offered by the system which enable integration with building management systems. The predictive model achieved 85% accuracy in predicting major environmental changes which exceeded 2°C or 5% RH shifts during validation testing. A data persistence layer is provided by the system which enables long-term analysis through InfluxDB time-series storage and SQLite for operational logging.  System expansion with additional sensors (e.g., CO₂, VOC) or machine learning models while keeping the core architecture intact is easy due to system's modularity. The framework demonstrated 99.2% system uptime during operational testing in residential settings and reduced environmental incident response times from hours to seconds thus proving its effected performance compared to traditional monitoring systems.

 

Code Listings

ESP32 Code for MQTT Publishing

PubSubClient mqttClient(wifiClient);

DHT envSensor(SENSOR_PIN, SENSOR_TYPE);

void setup() {

WiFi.begin(wifiName, wifiPass);

mqttClient.setServer(brokerAddress, 1883);

envSensor.begin();

}

void loop() {

float tempC = envSensor.readTemperature();

float humidity = envSensor.readHumidity();

char tempBuffer[8];

dtostrf(tempC, 1, 2, tempBuffer);

mqttClient.publish("iot/env/temp", tempBuffer);

delay(30000);

}

 

Node-RED Function for Alert Trigger

let currentTemp = msg.payload.temperature;

let currentHumidity = msg.payload.humidity;

 

if (currentTemp > 30 || currentHumidity > 70) {

    msg.payload = `ALERT! Temperature: ${currentTemp}°C, Humidity: ${currentHumidity}%`;

    return [msg, null];

} else {

    return [null, msg];

}

 

Implementation

The system implementation used hardware-software co-design methods which is shown in Figure2 to achieve a unified connection between sensor nodes and communication protocols and data analytics. The ESP32 microcontrollers operated as sensor node bases which used Arduino IDE programming to read temperature and humidity data from DHT22 sensors every 30 seconds. The nodes received calibration from high-precision reference sensors to reduce measurement errors while sending JSON payloads that included device IDs and timestamps and sensor values. The system achieved 60% lower power consumption through deep sleep modes compared to running continuously. For reliable data transmission, Mosquitto MQTT broker used on a Raspberry Pi 4 system which used TLS encryption and username/password authentication . The ESP32 nodes transmitted sensor data through topic-based channels (e.g., env/home/living_room/temperature) with QoS Level 1 to guarantee message delivery in unstable network conditions. In case of interruptions, the broker stored the most recent sensor readings for quick recovery. The network performance monitoring showed transmission success rates between 99.1% and 99.7% across different test environments.


The Node-RED platform managed real-time data processing and visualization. The system subscribed to MQTT topics while parsing incoming data to display real-time trends through a customizable dashboard as in Figure3. The system established alert thresholds at 28°C for warning and 30°C for critical temperature levels and 65% RH for warning and 70% RH for critical humidity levels. The system activated SMS alerts through Twilio and email notifications through SMTP when thresholds were exceeded as shown in Figure 3 with an average response time of 3.8–4.2 seconds. Linear regression analysis of 15-minute data segments produced predictive analytics that achieved 79–83% accuracy during validation.

 

The system uses InfluxDB to store time-series data and SQLite for logging. For offline analysis, a Python script is performed automatically and on a weekly base to export CSV files. The system is tested for 30 days in a residential environment with 99% uptime.

RESULTS

The proposed framework is tested in a controlled residential place and for 30 days. It showed strong and stable operation during this period.

 

 

Figure 3: System Dashboard

 

 

Figure 4: Email notification

 

The MQTT communication protocol delivered messages successfully without packet loss and maintained an average latency of less than 250 milliseconds between data transmission and dashboard display.
MThe alert system behaved as expected and to verify its response and the SMS alerts, we intentionally exceeded the thresholds by increasing in ambient humidity during cooking activities which proves that the thresholds were correctly detected and notifications were delivered as shown in Figure4. The linear regression model in Node-RED produced accurate short-term predictions for temperature and humidity changes through predictive analytics. The root mean square error (RMSE) for temperature forecasts was ±1.8°C, and for humidity it was ±4.6% over 30-minute prediction windows. The system’s resource usage remained within optimal limits where the ESP32 operated at under 75KB RAM usage, and the Raspberry Pi-based broker showed minimal CPU impact (<5%) during peak traffic. This confirms the system's efficiency and suitability for continuous deployment in resource-constrained environments.

REFERENCE
  1. Elnaggar A et al. "Risk analysis for preventive conservation of heritage collections in Mediterranean museums: case study of the museum of fine arts in Alexandria (Egypt)." Heritage Science, vol. 12, no. 1, 2024, pp. 1-17. DOI: https://doi.org/10.1186/s40494-024-01170-z

  2. Adan OCG and Samson RA. Fundamentals of mold growth in indoor environments and strategies for healthy living. Springer, 2011. ISBN: 9789086867226. DOI: https:// doi.org/10.3920/978-90-8686-722-6

  3. Perles A, Fuster-López L, and Bosco E. "Preventive conservation, predictive analysis and environmental monitoring." Heritage Science, vol. 12, no. 11, 2024. DOI: https://doi.org/10.1186/s40494-023-01118-9

  4. Shanmugapriya D and Patel A. "MQTT protocol use cases in the Internet of Things." In Big Data Analytics. BDA 2021. Lecture Notes in Computer Science, vol. 13147, Springer, Cham, 2021. DOI: https://doi.org/10.1007/978-3-030-93620-4_12

  5. Laohaviraphap N and Waroonkun T. "Integrating artificial intelligence and the Internet of Things in cultural heritage preservation: A systematic review of risk management and environmental monitoring strategies." Buildings, vol. 14, no. 12, 2024, p. 3979. DOI: https://doi.org/ 10.3390/buildings14123979

  6. Fang S et al. "An integrated system for regional environmental monitoring and management based on internet of things." IEEE Transactions on Industrial Informatics, vol. 10, no. 2, 2014, pp. 1596-1605. DOI: https://doi.org/10.1109/TII.2014.2302638

  7. Hassan MN et al. "An IoT-based environment monitoring system." 2020 3rd International Conference on Intelligent Sustainable Systems (ICISS), 2020, pp. 1119-1124. DOI: https://doi.org/10.1109/ICISS49785.2020.9316050

  8. Laha SR et al. "Advancement of environmental monitoring system using IoT and sensor: A comprehensive analysis." AIMS Environmental Science, vol. 9, no. 6, 2022, pp. 771-800. DOI: https://doi.org/ 10.3934/environsci.2022044

  9. Ullo SL and Sinha GR. "Advances in smart environment monitoring systems using IoT and sensors." Sensors, vol. 20, no. 11, 2020, p. 3113. DOI: https://doi.org/ 10.3390/s20113113

  10. Bhoi SK et al. "IoT-EMS: An internet of things based environment monitoring system in volunteer computing environment." Intelligent Automation and Soft Computing, vol. 32, no. 2, 2022, pp. 1493-1507. DOI: https://doi. org/10.32604/iasc.2022.022833

  11. Rani GJ and Rama GS. "An IOT-based environmental monitoring system." IOP Conference Series: Materials Science and Engineering, vol. 981, no. 3, 2020, p. 032025. DOI: https://doi.org/10.1088/1757-899X/981/3/03202 5

  12. Piramuthu S. "IoT, environmental sustainability, agricultural supply chains." Procedia Computer Science, vol. 204, 2022, pp. 811-816. DOI: https://doi.org/10.1016 /j.procs.2022.08.098

  13. Anuar NA, Jalaludin NA, and Sadun AS. "Temperature and humidity monitoring system." Progress in Engineering Application and Technology, vol. 5, no. 1, 2024, pp. 259-266. DOI: https://doi.org/10.30880/peat.2024.05.01.027
Recommended Articles
Research Article
Design and Implementation of a GSM-Based SMS Controlled DC Motor Speed Regulation System
...
Published: 31/12/2025
Download PDF
Research Article
OBSERVATIONS ON THE HOMOGENEOUS TERNARY QUADRATIC DIOPHANTINE EQUATION x2 + 4xy + 9y2 = 21z2
Download PDF
Research Article
Computer Driven Library Management and Service Rendering System: Mobile Library Landscape
...
Published: 10/06/2020
Download PDF
Research Article
Advancing Efficiency of Silicon-Based Photovoltaic Devices Through Alumina Nanoparticles Integration via Electrochemical Synthesis
Published: 31/12/2025
Download PDF
Chat on WhatsApp
Flowbite Logo
PO Box 101, Nakuru
Kenya.
Email: office@iarconsortium.org

Editorial Office:
J.L Bhavan, Near Radison Blu Hotel,
Jalukbari, Guwahati-India
Useful Links
Order Hard Copy
Privacy policy
Terms and Conditions
Refund Policy
Shipping Policy
Others
About Us
Team Members
Contact Us
Online Payments
Join as Editor
Join as Reviewer
Subscribe to our Newsletter
+91 60029-93949
Follow us
MOST SEARCHED KEYWORDS
Copyright © iARCON International LLP . All Rights Reserved.