Today, the Internet of Things (IoT) has various applications in security systems, intelligent infrastructure, traffic management, weather systems, and industrial and military applications, and produces a huge amount of data. This volume of data raises issues such as providing routing and clustering protocols and data transfer management as upcoming challenges. In general, the performance of (IoT) devices is limited, especially in terms of battery life and energy efficiency, so to increase the energy efficiency of the network, various mechanisms such as energy-based clustering or sleep scheduling mechanisms are used in routing protocols. There is currently a lot of research going on in this field, but most of the designs are complex and not easily implemented in real-world scenarios. In this regard, this research presents a method for routing using clustering algorithm. The proposed approach first groups network members using the dragonfly algorithm by determining clusters as well as cluster members and cluster heads. After that, the routing time starts and in this phase, the Particle Swarm Evolution (PSO) algorithm determines the interface nodes to send the packets to the base station. MATLAB programming language is used to evaluate the proposed approach. The results of the evaluations are measured using two criteria of the amount of remaining energy and the number of active nodes in the network and are presented in the form of two different scenarios. The results of the evaluations show that the proposed method was able to perform better than the comparable method in both evaluation criteria, and as a result, it obtained a higher efficiency.