The problem of data sampling and collection in wireless sensor networks (WSNs) is becoming critical as larger networks are being deployed. Increasing network size poses significant data collection challenges, for what concerns sampling and transmission coordination as well as network lifetime. To tackle these problems, in-network compression techniques without centralized coordination are becoming important solutions to extend lifetime. In this paper, we consider a scenario in which a large WSN, based on ZigBee protocol, is used for monitoring (e.g., building, industry, etc.). We propose a new algorithm for in-network compression aiming at longer network lifetime. Our approach is fully distributed: each node autonomously takes a decision about the compression and forwarding scheme to minimize the number of packets to transmit. Performance is investigated with respect to network size using datasets gathered by a real-life deployment. An enhanced version of the algorithm is also introduced to take into account the energy spent in compression. Experiments demonstrate that the approach helps finding an optimal tradeoff between the energy spent in transmission and data compression.