Low-cost Internet of Things (IoT) soil sensors are increasingly used in precision agriculture; however, the reliability of machine learning models developed from continuous field data remains uncertain. This study investigated the estimation of soil nitrogen (N), phosphorus (P), and potassium (K) using environmental variables collected from low-cost IoT soil-sensing nodes. A total of 63,769 observations were recorded over 170 days from two LoRa-based soil sensor nodes deployed under tropical field conditions in Thailand. The measured variables included soil moisture, temperature, electrical conductivity (EC), pH, and sensor-based N, P, and K readings.
A multi-output machine learning model was evaluated using two validation approaches: conventional random data splitting and chronological data splitting. SHapley Additive exPlanations (SHAP) were then applied to examine the contribution of each input variable to the nutrient predictions. With random splitting, the model produced high apparent prediction accuracy, with R² values of 0.86–0.88 for N, P, and K. However, when chronological splitting was used to avoid temporal leakage, the model performance decreased substantially, with R² values below zero. This result indicates that the high performance obtained from random splitting was mainly caused by autocorrelated and near-duplicate samples rather than true predictive ability.
The results also showed clear distributional drift between the training and testing periods. SHAP analysis identified EC and soil moisture as the most influential variables, suggesting that the model mainly captured the conductivity-related response of the sensor system rather than independent chemical information. These findings show that random-split validation can overestimate the practical performance of IoT-based soil nutrient prediction models. The study highlights the importance of time-aware validation, laboratory calibration, and careful interpretation when applying machine learning to low-cost soil sensor data in tropical smart agriculture.