Connecting Raspberry Pi to a USB sonar sensor
There is yet another way to sense the presence of objects: using a sonar sensor. But before you add this capability to your system, here's a little tutorial on sonar sensors. This type of sensor uses ultrasonic sound to calculate the distance from an object. The sound wave travels out from the sensor, as illustrated in the following figure:
The device sends out a sound wave 10 times a second. If an object is in the path of these waves, then the waves reflect off the object, sending waves that return to the sensor, as shown in the following figure:
The sensor then measures any return. It uses the time difference between when the sound wave was sent out and when it returned to measure the distance from the object.
Note
Sonar sensors are also quite accurate, normally with low percentage errors, and are not affected by the lighting or color in the environment.
There are several choices if you want to use a sonar sensor to sense the distance. The...