Based on LEACH, a new clustering protocol for wireless sensor networks is proposed and implemented. A new visualization method is also introduced. There are two outcomes from the implemented protocol. The first outcome is prolonged network lifetime. The second outcome is an increase in flexibility of the location of the base station. Another contribution of this thesis is development of a visualization tool that helps users to understand the energy behavior of the sensors in similar applications. The first outcome —prolonged network lifetime —are due to considering the distance of each node from the base station while clusters are formed. The energy dissipation for transmitting certain amount of data is defined as a piecewise function which is divided by certain distance threshold. A piece of this piecewise function is implemented in this work, which leads to increased flexibility in the location of the base station.