Heterogeneous wireless sensor networks are a source of large amount of different information representing environmental aspects such as light, temperature, and humidity. A very important research problem related to the analysis of the sensor data is the detection of relevant anomalies. In this work, we focus on the detection of unexpected sensor data resulting either from the sensor system itself or from the environment under scrutiny. We propose a novel approach for automatic anomaly detection in heterogeneous sensor networks based on coupling edge data analysis with cloud data analysis. The former exploits a fully unsupervised artificial neural network algorithm, whereas cloud data analysis exploits the multi-parameterized edit distance algorithm. The experimental evaluation of the proposed method is performed applying the edge and cloud analysis on real data that has been acquired in an indoor building environment and then distorted with a range of synthetic impairments. The obtained results show that the proposed method can self-adapt to the environment variations and correctly identify the anomalies. We show how the combination of edge and cloud computing can mitigate the drawbacks of purely edge-based analysis or purely cloud-based solutions.