Internet of things is one of the most important technologies in the last century which covers various domains such as wireless sensor networks. Wireless sensor networks consist of a large number of sensor nodes that are scattered in an environment and collect information from the surrounding environment and send it to a central station. One of the most important problems in these networks is saving energy consumption of nodes and consequently increasing lifetime of networks. Work has been done in various fields to achieve this goal, one of which is clustering and the use of sleep timing mechanisms in wireless sensor networks. Therefore, in this article, we have examined the existing protocols in this field, especially LEACH-based clustering protocols. The proposed method tries to optimize the energy consumption of nodes by using genetic-based clustering as well as a sleep scheduling mechanism based on the colonial competition algorithm. The results of this simulation show that our proposed method has improved network life (by 18%) and average energy consumption (by 11%) and reduced latency in these networks (by 17%).