This study investigates the application of machine learning (ML) algorithms in smart farming, particularly using the Internet of Things (IoT) to predict agricultural conditions like temperature and soil moisture. The research compares the effectiveness of various ML models, including Linear Regression, Decision Tree, Random Forest, and XGBoost, with XGBoost yielding the best prediction results. The aim is to assist farmers in optimizing agricultural practices through accurate data analysis and prediction capabilities.