Getting reasonably robust proximity measurements from an ultrasonic sensor on the Raspberry Pi

from blog Kevin Boone's website, | ↗ original
The HC-SR04 proximity sensor is an inexpensive and widely-used ultrasonic device. Connecting one to an HC-SR04 to a Raspberry Pi is a common educational exercise, but getting accurate, repeatable measurement of distance in a real application is actually quite difficult. This article explains why, and what can be done to improve matters.