A Smart Energy Management System (SEMS), which uses the Internet of Things (IoT), has been created in response to the increasing demand for energy-efficient solutions. A cost-effective and efficient IoT-based SEMS that optimizes energy usage, reduces costs, and improves sustainability is presented in this work. The suggested solution uses smart meters, cloud-based analytics, and inexpensive sensors (total cost is less than US$20) to track and control energy use in real time. Through the use of Machine Learning (ML) algorithms and data-driven decision-making, the system can forecast future consumption trends and provide consumers with relevant data. Energy conservation is achieved through the system’s affordability, which makes it appropriate for residential, commercial, and industrial applications without requiring significant infrastructure investments. The system’s effectiveness in reducing energy waste while maintaining user convenience is demonstrated by experimental results. The considerable potential of IoT-based technologies in creating an economical and sustainable framework for energy management is demonstrated by this study. Furthermore, energy consumption prediction systems based on ML are presented. In addition, a scalable approach for more intelligent and environment-friendly energy management systems in future smart cities is developed using OPNET simulation for about 1000 nodes (smart meters). The findings demonstrated that boosting family classifiers achieved the best accuracy with a 98% prediction rate. When 1000 nodes are simulated, the latency for the proposed system may reach as low as 0.21 ms with approximately 20 bytes/s of network traffic, according to the network simulation results that used OPNET.