An IoT-Based Environmental Monitoring System with Machine Learning Soil Moisture Prediction for Polybag Rice Cultivation on Limited Land

Automated Irrigation ESP32 Firebase Internet of Things Machine Learning

Authors

October 13, 2026

Downloads

The continued decline in conventional farmland has created a need for cultivation methods that do not depend on paddy field infrastructure. This study presents an Internet of Things (IoT)-based environmental monitoring and automated irrigation system for polybag rice cultivation, developed using an ESP32 microcontroller integrated with a DHT22 temperature and humidity sensor, a BH1750 ambient light sensor, and an analog soil moisture sensor. Sensor readings were transmitted to the Firebase Realtime Database and visualized through a responsive web dashboard, while pump actuation followed a two-threshold control logic at soil moisture levels of 50% and 80%. Functional validation yielded a mean absolute percentage error (MAPE) of 0.53% for the DHT22 and 2.86% for the BH1750, an average transmission time of 409.8 ms to the cloud and 3.8 s to the dashboard, and pump response times of 1.2 s in automatic mode and 12 s in manual mode, with a preliminary dashboard usability rating of 4.2 out of 5. Beyond functional validation, a 79-day continuous field deployment generated 7,208 environmental samples, from which diurnal soil moisture patterns and the correlation structure of the polybag growing medium were quantitatively characterized. A machine learning model was subsequently developed to predict soil moisture using only data obtained from the low-cost sensors. Among the four approaches evaluated using chronologically held-out data, the Random Forest model achieved an R² of 0.997 and reduced prediction error by 94.5% compared with a non-predictive baseline. Overall, the results demonstrate the feasibility of transitioning from reactive to anticipatory irrigation using a low-cost cultivation platform designed for land-constrained environments.