piratadelestrecho:
Thank you @teckel after ignoring the 0 values, it's working perfectly!
This may not be sufficient. I've seen valid, in-range values (nonzero) reported by the HC-SR04 when nothing was in range. You could get false positives if all you do is ignore 0cm distances.