This paper exploits the tradeoff between data quality and energy consumption to extend the lifetime of wireless sensor networks. We consider the applications that require some aggregate form of sensed data with precision guarantees. Our key idea is to differentiate the precisions of data collected from different sensor nodes to balance their energy consumption. This is achieved by partitioning the precision constraint of data aggregation and allocating error bounds to individual sensor nodes in a coordinated fashion. Three factors affecting the lifetime of sensor nodes are identified: (1) the changing pattern of sensor readings; (2) the residual energy of sensor nodes; and (3) the communication cost between the sensor nodes and the base station. We analyze the optimal precision allocation in terms of network lifetime and propose an adaptive precision allocation scheme that dynamically adjusts the error bounds of sensor nodes. Experimental results using real data traces show that the proposed scheme significantly improves network lifetime compared to existing methods.