This paper presents a holistic view of energy management in sensor networks. We first discuss hardware designs that support the life cycle of energy, namely: (i) energy harvesting, (ii) energy storage and (iii) energy consumption and control. Then, we discuss individual software designs that manage energy consumption in sensor networks. These energy-aware designs include media access control, routing, localization and time-synchronization. At the end of this paper, we present a case study of the VigilNet system to explain how to integrate various types of energy management techniques to achieve collaborative energy savings in a large-scale deployed military surveillance system.