As a novel technology, the Internet of Things (IoT) has many applications in diverse fields, especially in smart homes. IoT includes a variety of communication networks and technologies which facilitate communication between heterogeneous devices. One of the primary challenges of IoT is energy consumption. This paper introduces a new Software Defined Network-based (SDN-based) clustering approach using intelligent algorithms for energy conservation in IoT. The proposed method uses an evolutionary algorithm to identify the required number of clusters and ensures their distribution in the environment. A virtual network is also employed to ensure network coverage and the formation of balanced clusters. Clustering, steady, and routing are the main steps of the proposed method that the clustering step is done in SDN. By expanding the steady phase and leveraging energy-based greedy routing, the network’s lifetime increases. After simulation in MATLAB, the proposed method is tested then the results are compared with other well-known algorithms. The evaluation results indicate that the proposed method has improved in terms of metrics such as energy consumption and network lifetime. The proposed approach improves energy consumption by 31%, 28%, 8% and 21% than FPA, MCFL, BEEG and NodeRanked respectively. The lifetime has been improved by 34% and 71% than BEEG and NodeRanked, respectively, and more than 100% for MCFL and FPA.