Wireless ad hoc networks have played an increasingly important role in a wide range of applications. A key challenge in such networks is to achieve maximum lifetime for battery-powered mobile devices with dynamic energy-efficient algorithms. Recent studies in battery technology have revealed that the behavior of battery discharging is more complex than we used to know. Battery-powered devices might waste a huge amount of energy if their battery discharging is not carefully scheduled and budgeted. In this paper, we introduce a novel energy model for batteries and study the effect of battery behavior on routing in wireless ad hoc networks. We first propose an online computable discrete-time mathematical model to capture battery discharging behavior. The model has low computational complexity and data storage requirement. It is therefore suitable for online battery capacity computation in routing. Our evaluations indicate that the model can accurately capture the behavior of battery discharging. Based on this battery model, we then propose a battery-aware routing (BAR) scheme for wireless ad hoc networks. BAR is a generic scheme that implements battery awareness in routing protocols and is independent of any specific routing protocol. By dynamically choosing the devices with well-recovered batteries as routers and leaving the “fatigue” batteries for recovery, the BAR scheme can effectively recover the device's battery capacity to achieve higher energy efficiency. Our simulation results demonstrate that, by adopting the BAR scheme, network lifetime and data throughput can be increased by up to 28% and 24%, respectively. The results also show that BAR achieves good performance in various networks composed of different devices, batteries, and node densities. Finally, we also propose an enhanced prioritized BAR (PBAR) scheme for time-sensitive applications in wireless ad hoc networks. Our simulation results illustrate that PBAR achieves good performance in- - terms of end-to-end delay and data throughput.