This paper proposes density based clustering protocol for optimizing the energy consumption in Wireless Sensor Network. There are many approaches in the literature; which are differ in the method and frequency of cluster head selection. This paper proposes a new method of cluster head selection. The nodes of the network are categorized as interior and exterior nodes based on the density of other nodes in the surrounding. The ratio of interior type of neighbors to exterior type of neighbors of a node is used to decide the level of a node. This level in combination with distance of a node from the base
station is used to decide whether it will act as a cluster head or not. As the energy of nodes depletes, some neighbors may die thus changing the level of the node. At this point, new cluster heads are selected. Due to this the energy of network is consumed in a balanced manner. Simulation experiments are designed to compare the proposed method with other popular clustering algorithms. Overall impression of results is that the proposed method gives a longer network life due to properly distributed energy consumption throughout the network.