Routing in a wireless sensor network is a very challenging task that allows nodes to be routed to transmit information from source to destination. As a result, optimal energy consumption is an important goal for designing a routing algorithm. In addition, due to the wireless communications and adverse environments, it is very important to ensure the security of communication links. In this research, a secure routing method for clustered and heterogeneous wireless sensor networks is presented. The proposed secure routing method consists of three phases: startup phase, inter-node routing phase and communication security phase. In the startup phase, the base station loads the system parameters and encryption functions into the memory of the sensor nodes. In the routing phase between cluster head nodes, the cluster head nodes calculate their score for rerouting the path request packet (RREQ) based on the information in the packet. If their score exceeds a threshold, they will redistribute the RREQ package. It should be noted that the score of cluster head nodes is calculated based on four parameters: the distance of the current cluster head node to the destination, the residual energy of the nodes, the quality of the communication link and the number of steps. The proposed secure routing method is implemented using NS2 emulator. Then, the results are compared with SMEER and LEACH-C routing methods. Experimental results indicate that the proposed routing method improves end-to-end delays, efficiency, energy consumption, packet delivery rate (PDR) and packet loss rate (PLR).