In wireless sensor networks, a large number of cheap and small sensor nodes send data to a single sink node. To overcome the limitations of computing and energy capacity of sensor nodes, a simple yet energy-efficient routing is required. In this paper, we propose a clustering algorithm that enables sensor nodes to autonomously establish routing paths to a sink node. Our algorithm utilizes network coding to improve energy-efficiency and reliability. We analyze the benefit of using network coding in our algorithm through Markov chain Monte Carlo (MCMC) simulations, and simulation results prove that our algorithm reduces energy consumption and traffic load in wireless sensor networks.