Since tiny nodes of a wireless sensor network (WSN) are typically powered by batteries with, due to miniaturization and costs, a limited capacity, with the aim of extending the lifetime of WSNs and making the exploitation of WSNs appealing, a lot of research has been devoted to save energy. Although a number of factors contribute to power consumption, radio communication has been generally considered its main cause and thus most of the techniques proposed for energy saving have mainly focused on limiting transmission/reception of data, for instance, through data compression. As sensor nodes are equipped with limited computational and storage resources, enabling compression requires to develop purposely-designed algorithms. To this aim, we propose an approach to generate lossy compressors to be deployed on single nodes based on a differential pulse code modulation scheme with quantization of the differences between consecutive samples. The quantization levels and thresholds, which allow achieving different trade-offs between compression performance and information loss, are determined by a two-objective evolutionary algorithm. We tested our approach on four datasets collected by real WSN deployments. We show that the lossy compressors generated by our approach can achieve significant compression ratios despite negligible reconstruction errors and outperform LTC, a lossy compression algorithm purposely designed to be embedded in sensor nodes