In this study, we present an integrated approach utilizing IoT data and machine learning models to enhance precision agriculture. We collected an extensive IoT secondary dataset from an online data repository, including environmental parameters such as temperature, humidity, and soil nutrient levels, from various sensors deployed in agricultural fields. This dataset, consisting of over 1 million data points, provided comprehensive insights into the environmental conditions affecting crop yield. The data were preprocessed and used to develop predictive models for crop yield and recommendations. Our evaluation shows that the LightGBM, Decision Tree, and Random Forest classifiers achieved high accuracy scores of 98.90%, 98.48%, and 99.31%, respectively. The IoT data collection enabled real-time monitoring and accurate data input, significantly improving the models’ performance. These findings demonstrate the potential of combining IoT and machine learning to optimize resource use and improve crop management in smart farming. Future work will focus on expanding the dataset to include more diverse environmental factors and exploring the integration of advanced deep learning techniques for even more accurate predictions.