Electric vehicles (EVs) are quickly becoming a staple of smart transportation in applications involving smart cities due to their ability to reduce carbon footprints. However, the widespread use of electric vehicles significantly strains the nation's electrical system. In-depth descriptions of the EV's energy management system (EMS) should highlight the vehicle's powertrain's vital role. The energy for propulsion in electric automobiles comes from a rechargeable battery. The safe and dependable operation of batteries in electric vehicles relies heavily on online surveillance and status estimations of charges. An energy management strategy (EMS) that considers the electric vehicle's battery and ultra-capacitor may lessen the vehicle's reliance on external power sources and extend the battery's lifespan. A machine learning-based mathematical dynamic programming algorithm is used in designing the energy management system to teach the system how to respond appropriately to various situations without resorting to predefined rules. Therefore, this research aims to use Machine Learning to create a Smart Energy Management System for Hybrid Electrical Vehicles (SEMS-HEV) with energy storage. Energy optimization techniques and algorithms are necessary in this setting to reduce expenses and length of charging and appropriately arrange the EV charging process to prevent bursts in the electrical supply that may impact the transmission network. To improve the performance of an energy management system, this study employs an IoT-based smart charging system for scheduling V2G connections for hybrid electrical vehicles. It allows for more precise and effective control and greater efficiency by enabling the system to learn from its surroundings.