Agriculture plays a vital role in feeding the growing global population, yet optimizing crop production and resource management remains a significant challenge for farmers. This paper presents a Machine Learning (ML)-enabled Internet of Things (IoT) prototype designed to monitor soil parameters in real time and provide customized crop recommendations. The proposed system integrates four sensors — a JXBS-3001 NPK sensor, an FC-28 soil moisture sensor, a DHT11 temperature-humidity sensor, and an analog soil pH probe — deployed in the crop field and interfaced with a NodeMCU (ESP8266) microcontroller. Collected data is transmitted to the Ubidots cloud platform via the MQTT protocol. The Random Forest classifier is employed as the primary algorithm, achieving 99.09% test accuracy on the standard Kaggle Crop Recommendation dataset (2,200 samples, 22 crop classes); Logistic Regression, LightGBM, and a Neural Network are evaluated as benchmarks. Recommendations and fertilizer guidance are delivered to the farmer through a web-based dashboard, and a rule-based fertilizer engine maps measured N, P, K deficits to dosage suggestions per crop. The prototype was demonstrated in a working deployment and received first prize at the AURA 2.0 State-Level Project Expo (2023) and first prize at Shark Tank 2.0 (2024).
Introduction
Global food demand is increasing while arable land is decreasing, and current farming practices rely heavily on manual soil inspection and slow laboratory testing, which are often costly, delayed, and difficult for farmers to interpret. As a result, fertilizer use is frequently inefficient and crop yields are suboptimal.
To solve this, the authors propose a low-cost IoT system using a NodeMCU (ESP8266) connected to multiple sensors (NPK, soil moisture, pH, temperature, and humidity). The system continuously collects soil data and sends it to the cloud via MQTT. A Random Forest machine learning model analyzes this data to recommend suitable crops and provide fertilizer guidance. The results are displayed through a web dashboard for easy farmer access.
The system combines hardware (sensors + microcontroller), cloud connectivity (Ubidots), and a software interface (Google Sites) into an end-to-end precision agriculture platform. The ML pipeline includes data collection, preprocessing, feature engineering, training (mainly using Random Forest), prediction, and periodic retraining.
Key contributions include a low-cost real-time soil monitoring device, integration of ML for crop recommendation, a farmer-friendly web interface, and a complete working prototype demonstrating practical precision agriculture for small and medium farms.
Conclusion
This paper presented an IoT-based soil nutrient analysis and crop recommendation prototype that integrates real-time sensor data acquisition with a Random Forest-based machine learning pipeline to assist farmers in making data-driven crop and fertilizer decisions. The prototype demonstrates the feasibility of combining low-cost IoT hardware — a NodeMCU with NPK, soil moisture, temperature-humidity, and pH sensors — with cloud-based data processing and a simple web interface.
While the current system establishes a working end-to-end pipeline, quantitative field validation across multiple crop cycles and soil types remains future work. As agriculture continues to face challenges from climate change, resource scarcity, and fluctuating market demands, ML-based precision agriculture tools offer a promising pathway toward improved efficiency, productivity, and sustainability
References
[1] J. An, F. Le Gall, J. Kim, J. Yun, J. Hwang, M. Bauer, M. Zhao, and J. Song, \"Toward global IoT-enabled smart cities interworking using adaptive semantic adapter,\" IEEE Internet of Things Journal, vol. 6, no. 3, 2023.
[2] A. Ashwitha and C. Latha, \"Crop recommendation and yield estimation using machine learning,\" Journal of Mobile Multimedia, 2023.
[3] V. K. Quy, N. V. Hau, D. V. Anh, N. M. Quy, N. T. Ban, S. Lanza, G. Randazzo, and A. Muzirafuti, \"IoT-enabled smart agriculture: architecture, applications, and challenges,\" Applied Sciences, vol. 12, no. 7, 2023.
[4] R. Reshma, V. Sathiyavathi, T. Sindhu, K. Selvakumar, and L. SaiRamesh, \"IoT based classification techniques for soil content analysis and crop yield prediction,\" in Proc. 2022 Fourth International Conference on I-SMAC (IoT in Social, Mobile, Analytics and Cloud), IEEE, 2022.
[5] N. N. Thilakarathne, M. S. A. Bakar, P. E. Abas, and H. Yassin, \"A cloud enabled crop recommendation platform for machine learning-driven precision farming,\" vol. 16, 2024, p. 6299.
[6] V. F. Rodriguez-Galiano, B. Ghimire, J. Rogan, M. Chica-Olmo, and J. P. Rigol-Sanchez, \"An assessment of the effectiveness of a random forest classifier for land-cover classification,\" ISPRS Journal of Photogrammetry and Remote Sensing, vol. 67, pp. 93–104, 2012.