In numerous low-resource farming areas, monitoring gaps and the absence of predictive control mean farmers typically respond to problems after they occur instead of using timely data to prevent them. This study introduces a cost-effective and modular precision farming framework that integrates IoT-based sensing, workflow automation, and machine learning for anticipatory decision support. The system utilizes an ESP32 DevKit-V1 microcontroller linked with six sensors—DHT11, MQ135, MQ9, soil moisture, rainfall, and water flow—to continuously capture real-time field parameters. Instead of relying on a single data pipeline, the framework employs a dual-stream design: instantaneous updates are transmitted to ThingSpeak for on-field visualization, while long-term data are simultaneously stored in a MySQL database for analysis and predictive modelling. Apache Airflow 2.7.3 acts as the orchestration engine, periodically executing four independent Random Forest–based models that forecast short-term trends in temperature, humidity, and air quality. These predictions enable proactive interventions, such as adjusting irrigation or ventilation before adverse conditions arise. Visualization dashboards developed in Metabase translate both real and predicted data into easily interpretable insights for farmers. The entire system operates through Dockerized components, supports horizontal scaling across multiple farms, and remains economically viable for rural communities. The proposed framework thus demonstrates how combining ESP32-based IoT data acquisition with Airflow-driven machine learning pipelines can create an accessible, predictive, and low-cost precision agriculture platform for small and medium-scale farmers.
Introduction
Traditional agriculture often relies on intuition rather than timely, data-driven insights, causing inefficiencies in irrigation, crop management, and environmental control. Unnoticed fluctuations in soil moisture, temperature, humidity, or the accumulation of harmful gases can lead to resource wastage and crop stress. To address this, the paper proposes a low-cost IoT-based system using ESP32 microcontrollers to collect real-time environmental data and transmit it via a dual-path system: one for live visualization (ThingSpeak) and another for historical storage (MySQL).
The backend employs Apache Airflow to automate machine learning pipelines that predict environmental changes such as humidity, temperature, gas levels, and soil moisture. This proactive approach allows farmers to make forecast-based decisions for irrigation, ventilation, and other farm operations, reducing resource waste and improving crop health. The modular, scalable architecture integrates sensing, data storage, predictive analytics, and visualization, offering an accessible, affordable, and sustainable framework for precision agriculture suitable for small- to medium-scale farms.
Conclusion
The system developed in this study demonstrates that low-cost IoT sensing, dual-path data transmission, and automated machine learning pipelines can be effectively combined to create a practical and scalable foundation for data-driven agriculture. By distributing responsibilities between edge-level sensing and backend prediction, the ESP32 functions as a lightweight data acquisition unit while Apache Airflow manages continuous and dependable model orchestration.
The application of Random Forest algorithms yielded a strong correlation between forecasted and observed values, confirming that accurate environmental prediction is achievable without the need for costly or proprietary hardware. The findings highlight that prediction-aware irrigation and environmental monitoring can substantially minimize resource wastage and provide farmers with clearer, more informed decision-making capabilities.
Ultimately, the success of this system reinforces the idea that open-source toolchains and low-cost IoT architectures can serve as a sustainable foundation for the digital transformation of agriculture. By enabling accessible, predictive, and automated control, the framework strengthens the potential for machine-learning-driven precision farming in developing regions—making smart agriculture both practical and attainable for smallholder farmers worldwide.
References
[1] M. R. Islam, T. K. Roy and S. Hossain, “IoT Based Smart Agriculture Monitoring System,” International Journal of Advanced Research in Computer Science, vol. 8, no. 5, 2017.
[2] A. A. Bhosale and P. D. Pawar, “Smart Farming Using IoT,” International Journal of Electrical and Computer Engineering, vol. 9, no. 3, 2019.
[3] P. Gupta and R. K. Singh, “Soil Moisture Monitoring using ESP32 and Cloud Platforms,” International Journal of Engineering Research & Technology, vol. 9, no. 11, 2020.
[4] S. J. Patel, K. Shah and H. Naik, “IoT Based Agricultural Decision Support System,” International Journal of Innovative Technology and Exploring Engineering, vol. 8, no. 9, 2019.
[5] V. Sharma, R. Kumar and S. Goyal, “Machine Learning Techniques for Prediction of Environmental Parameters in Agriculture,” International Journal of Computer Applications, vol. 182, no. 32, 2018.
[6] J. L. José, A. N. Regis and V. H. Rodrigues, “ESP32 Based Remote Sensor Node for Smart Farming,” International Journal of Research in Engineering and Technology, vol. 7, no. 4, 2021.
[7] K. R. Khandelwal and P. K. Jain, “Data Driven Irrigation Control using Random Forest Models,” International Journal of Scientific Research in Computer Science, Engineering and Information Technology, vol. 6, no. 5, 2020.
[8] A. Dash, P. Kabi and S. Sahu, “Workflow Automation using Apache Airflow for Data Engineering Pipelines,” International Journal of Engineering and Advanced Technology, vol. 8, no. 6, 2019.
[9] Apache Airflow Documentation, “Core Concepts and DAG Orchestration,” Website Link: https://airflow.apache.org/docs/ .
[10] Metabase Documentation, “Metabase Dashboards and Data Analytics,” Website Link: https://www.metabase.com/docs/latest/ .
[11] B. Karmel, “Airflow in Action,” Manning Publications, 2022. (Book on practical Airflow workflow design)
[12] A. Lahiri, “Practical Data Engineering with Apache Airflow,” Packt Publishing, 2023.