Among the different challenges related to the improvement of wireless sensor network (WSN) performance, the optimization of energy consumption takes an important place. Basically, sensor nodes in WSN are powered by limited battery. These batteries can allow sensor nodes to be functional for a limited period of time then sensor nodes turn out to be dead. Enhancing energy consumption and finding new manners to save sensor nodes' energy is becoming essential and more challenging. Improving energy consumption for each sensor nodes leads to enhance the lifetime of WSN. Clustering is among the outstanding strategies to reach this goal. In this paper, a new scheme of routing protocol in WSN will be presented in order to minimize the energy consumption and improve WSN lifetime. The new scheme is proposed in order to find the best selection of cluster head (CH) by taking in consideration the energy at each sensor node. It has been proposed based on Firefly Algorithm. We have compared the proposed scheme with LEACH, EAMMH, SEP, E-SEP, BRE, NEAHC and WEB protocol. Experimental results show that the proposed scheme yields better performance than the compared routing protocols in terms of better energy consumption and packet delivery between sensor nodes and base station. Results obviously prove that the proposed scheme could improve the WSN lifetime.