Due to their inherent variability, incorporating renewable energy sources into current power grids poses major challenges. This study aims to optimize renewable energy integration using Internet of Things (IoT) technology and machine learning (ML) algorithms. The study was conducted across 30 renewable energy sites in the United States over six months (April-September 2023), encompassing solar, wind, and hydroelectric installations. Three ML models (Random Forest, XGBoost, and Long Short-Term Memory networks) were developed and compared against a traditional persistence model for energy generation forecasting. The study also implemented a reinforcement learning-based grid optimization system. Results showed significant improvements in forecasting accuracy, with the LSTM model achieving a 59.1% reduction in Mean Absolute Percentage Error compared to the persistence model. Grid stability improved substantially, with a 64.2% reduction in supply-demand mismatches. Overall renewable energy utilization increased by 19.2%, with wind energy seeing the largest improvement (21.8%). The implemented system resulted in estimated monthly cost savings of $320,000. These findings demonstrate the potential of IoT-ML systems to enhance renewable energy integration, contributing to more efficient, reliable, and sustainable power grids.