Saturday, March 24, 2012

Using the HY-SRF05 Ultrasonic Module with the Arduino

Next on the list of sensors to explore is the ultrasonic range sensor. I am hoping to use this for two things. First, a simple range detector for obstacle avoidance (if something is ahead of you stop and do something else). Second, use the information to improve localization and map building. The latter usage may be a little problematic as it depends on the quality and timeliness of the measurements.

I started to look around at (i.e., google) the various options. To keep things simple, decided on the HY-SRF05 mostly due to the cost and availability on Amazon Prime (that keeps shipping costs down as well). and availability of code out there to make measurements. The parts list for this experiment is very simple.

  1. HY-SRF05: https://www.virtuabotix.com/feed/?p=209
  2. Arduino UNO: http://www.sparkfun.com/products/11021
  3. Some wires:  http://www.sparkfun.com/products/9385
  4. Breadboard: http://www.sparkfun.com/products/9567
As I was looking, I found lots of code and examples about how to wire up the device.

Here is an image of the wiring


Then I setup the sensor and pointed it at a wall. I measured the distance to the wall as 0.381 meters. I collected about 1 minute of returns from the sensor and calculated the mean (0.3888) and standard deviation (3.3548e-04). So things seem pretty close. 


Here is a histogram of the values. 


This was by far the easiest of the sensors to find information about, connect, and get out sensible readings. The hardest part seems to be how to come up with a good way to mount the sensor. As usual, all the code is located on github at:
https://github.com/mark-r-stevens/Ardadv/tree/master/device/sensors/ultrasonic

No comments:

Post a Comment