HC-SR04 Ultrasonic Range Sensor on the Raspberry Pi

This is a  mere  liaison if one happens to end up here first.
The blog at ModMyPI contains an excellent explanation and (illustrated) instruction.

https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi

A simple Python script for using the sensor can be found here:

https://bitbucket.org/RoboBasics/raspberry-robo-cars/src/d4fef2c5aad183ce186c378d9c89f618bddfd032/Handy%20stuff/usonic_HCSR04.py?at=master

(The script searches for 2 readings with a difference < 15%. Then it searches for other readings in the same range and calculates the average. Choices made are explained in the comments.)

A similar script, using the 3-pin Seeed sensor through the Py_WebSockets library of Dawn Robotics, can be found here:

https://bitbucket.org/RoboBasics/raspberry-robo-cars/src/d4fef2c5aad183ce186c378d9c89f618bddfd032/Handy%20stuff/usonic_Seeed.py?at=master

Enjoy!
Photo
Shared publicly