The Internet of Things (IoT) has rapidly grown in the past decade as an emerging technology. Due to the heterogeneity and energy limitations of IoT devices, adopting efficient management practices for developing IoT applications and managing IoT networks is a challenging task. One of the most critical IoT challenges that needs to be considered is routing due to its significant impact on energy consumption. Software Defined Networking (SDN) is a novel approach that decouples the control plane from the data plane, enabling network administrators to program and manage their networks more efficiently. This paper proposes an energy-aware routing mechanism for IoT networks by leveraging the capabilities of SDN. In the proposed method, the SDN controller has a global view of the network devices and establishes several optimal clusters in the IoT environment using Fuzzy logic. Then, the controller computes optimal routes by combining the Fuzzy logic system and the Improved African Vulture Optimization Algorithm (IAVOA). Applying this mechanism enables data packets to be routed through IoT devices with sufficient energy, leading to prolonged network lifetime and improved Quality of Service (QoS). Simulation results confirm that the proposed solution significantly improves energy efficiency and QoS in terms of packet delivery ratio.