The next-generation of wireless sensor platforms allows for more advanced in-network data processing. The central challenge remains energy and communication efficiency. This paper presents a resourceawareness framework for wireless sensor networks that allows in-network data processing to adapt to changing resource levels such as battery power or available memory. We have implemented the proposed framework as part of a query processing system for the Sun SPOT sensor network platform. As a case study, we have applied the framework to the query processor’s on-line data clustering algorithm, making it resource-aware. In an experimental study, we demonstrate how communication costs can be significantly reduced by de-coupling clustering and data communication. The results also show the effectiveness of the resource-aware clustering algorithm: It can keep a constant memory footprint for only a marginal acceptable error in result accuracy.