One critical issue in wireless sensor networks is how to gather sensed information in an energy-efficient way since the energy is a scarce resource in a sensor node. Cluster-based architecture is an effective architecture for data-gathering in wireless sensor networks. In this paper, by taking the nodes energy consumption into account, we first derive the optimal number of clusters for data gathering in sensor networks. To balance the cluster heads energy consumption, we propose a mixed communication modes where the cluster heads can transmit data to the base station in either single-hop or multi-hop. We then develop a data gathering method based on the optimal number of clusters and mixed communication modes. The simulation results show that the proposed method outperforms LEACH and HEED in terms of network lifetime by balancing energy dissipation.