The nodes of wireless sensor networks (WSN) are severely restricted in terms of computing capabilities, limited communications, and limited power supplies, as it is difficult or impossible to replace or recharge the sensor battery. Consequently, the energy of nodes is one of the most important resources to consider when designing of WSNs. So, most of the routing protocols in WSNs are to assure the saving of energy as a significant aim for improvement. Nevertheless, just providing power is not sufficient to extend the lifetime of WSN. Where unbalance energy depletion in WSNs is a challenging issue often leading to splits the network and reduces its lifetime, also retrogression of its performance. This paper, therefore, uses a powerful routing protocol named spider monkey optimization routing protocol (SMORP) to generate an optimal data routing of the pathway for heterogeneous WSNs (HWSNs). SMORP, here, can compute the best way from a sensor to the sink through the cluster head, inside the intra-cluster, and the inter-cluster respectively. For this purpose and the organization of heterogeneous nodes, this paper uses the clustering partition. The simulation results revealed that SMORP significantly improves in terms of data latency reduction, stabilizing depletion of energy, and maximizing the network lifetime for HWSNs.