To further prolong the lifetime of wireless sensor network (WSN), researchers from various countries have proposed many clustering routing protocols. However, the total network energy consumption of most protocols is not well minimized and balanced. To alleviate this problem, this paper proposes an energy-efficient clustering routing protocol in WSNs. To begin with, this paper introduces a new network structure model and combines the original energy consumption model to construct a new method to determine the optimal number of clusters for the total energy consumption minimization. Based on the balanced energy consumption, then we optimize the AGglomerative NESting (AGNES) algorithm, including: (1) introduction of distance variance, (2) the dual-cluster heads (D-CHs) division of the energy balance strategy, and (3) the node dormancy mechanism. In addition, the CHs priority function is constructed based on the residual energy and position of the node. Finally, we simulated this protocol in homogeneous networks (the initial energy = 0.4 J, 0.6 J and 0.8 J) and heterogeneous networks (the initial energy = 0.4–0.8 J). Simulation results show that our proposed protocol can reduce the network energy consumption decay rate, prolong the network lifetime, and improve the network throughput in the above two networks.