In wireless sensor networks (WSNs), a large number of tiny, inexpensive and computable sensor nodes are usually deployed randomly to monitor one or more physical phenomena. The sensor nodes collect and process the sensed data and send the data to the sink wirelessly. Energy consumption is however a serious problem affecting WSNs lifetime. Radio communication is often the major cause of energy consumption in wireless sensor nodes. Thus, applying data compression before transmission can significantly help in reducing the total power consumption of a sensor node. In this paper, we propose an efficient and robust adaptive data compression scheme (ADCS). The proposed scheme independently compresses each block of source data losslessly or lossily on local nodes based on the given application. Simulation results show the merits of the proposed compression scheme in comparison with other recently proposed compression algorithms for WSNs including S-LZW, LEC, MPDC, Two-modal GPC and LTC.