The Internet of Things (IoT) technology is one of the most important emerging technologies in today's world, and it is one of the most important and hot topics in information technology research. The Internet of Things (IoT) refers to the concept of connecting smart things to monitor, control, or exchange data over the Internet. These smart things could be tiny devices, with limited battery capacity and power supplies. These devices' high energy consumption shortens their lifespan, affecting the entire IoT network. The Internet Engineering Task Force (IETF) developed the main routing protocols used in the IoT, such as the IPv6 Routing Protocol for Low-Power and Lossy Networks (RPL), and standardized it in RFC6550, as one of the IoT's core routing protocols, and it is the only standard protocol that assists the routing process in Low Power and Lossy Networks (LLNs) of IoT applications. An approach that addresses the challenges of IoT networks and exploits new flexible network architectures, such as Software-Defined RPL networks, there is a considerable gap in adapting objective functions (OFs) for routing and controlling control messages for RPL operations, which enhance the energy efficiency of the IoT networks. This paper proposes a unique software-defined RPL system with optimized RPL operations for heterogeneous IoT environments to enhance energy efficiency. The proposed work performed adaptive OF selection and routing, for that purpose the proposed work formulated three categories of objective functions (OF1, OF2, OF3) namely TriOF. The optimal OF is selected based on the status of the network using the Killer Whale Optimization (KWO) algorithm. It improved the performance of adaptive OF selection and enhanced the network energy efficiency. We evaluate the outcomes through a series of simulated experiments using the Network Simulator (NS3). The proposed model approach results in a reduced number of control messages, control overhead, packet delivery ratio, and packet loss rate. Compared to the contrast works, energy consumption is reduced by 40% and 60%, respectively.