This Arduino sketch addresses a known problem with low-cost knock-off HC-SR04 ultrasonic distance sensors. These sensors-when they encounter out of range distances-get stuck and only return zero. This sketch will try 3 times to reset the sensor, if the value is still zero the sketch returns "out of range", else, the distance in centimeters and inches are returned.
heduenas/Arduino-HC-SR04-Fixed-Zero-Lock
This Arduino sketch addresses a known problem with cheap HC-SR04 ultrasonic distance sensors that, when they read out of range, get stuck in returning zero.