Wireless sensor networks (WSNs) and the Internet of Things (IoT) are increasingly making an impact in a wide range of domain-specific applications. In IoT-integrated WSNs, nodes generally function with limited battery units and, hence, energy efficiency is considered as the main design challenge. For homogeneous WSNs, several routing techniques based on clusters are available, but only a few of them are focused on energy-efficient heterogeneous WSNs (HWSNs). However, security provisioning in end-to-end communication is the main design challenge in HWSNs. This research work presents an energy optimizing secure routing scheme for IoT application in heterogeneous WSNs. In our proposed scheme, secure routing is established for confidential data of the IoT through sensor nodes with heterogeneous energy using the multipath link routing protocol (MLRP). After establishing the secure routing, the energy and network lifetime is improved using the hybrid-based TEEN (H-TEEN) protocol, which also has load balancing capacity. Furthermore, the data storage capacity is improved using the ubiquitous data storage protocol (U-DSP). This routing protocol has been implemented and compared with two other existing routing protocols, and it shows an improvement in performance parameters such as throughput, energy efficiency, end-to-end delay, network lifetime and data storage capacity.