Ultrasonic sensor comparison part 2
In my previous post, I posted some comparisons of some expensive $30 ultrasonic sensors (the Parallax Ping and the RadioShack Range Finder) and some cheap HC-SR04 sensors. I came to the conclusion that the HC-SR04 sensors were not as accurate but it turns out my testing approach was deeply flawed and my results and conclusions were completely incorrect.
These tests had me confused for a while. I set up a test where I would have two sensors side by side on a breadboard and I would take a reading from sensor 1 (a RadioShack module) and then a reading from sensor 2 (an HC-SR04 module) and then show the results. The test repeated once every 1 second.
With an icstation HC-SR04, I saw identical results (around 145 cm) from both sensors when pointing them at the ceiling in my office. However, when repeating the test with an iTEAD Studio HC-SR04 sensor, the HC-SR04 was always reporting a reading around 100 cm instead of 145 cm. This was very consistent. Based on this, I assumed that each sensor varied in its accuracy, so I decided to do a more formal test of each of the sensors I had available, so I tested each sensor individual for distances ranging from 1" to 60" and put the results in a table:
As you can see from this test, the results are actually very similar with all sensors and doesn't reflect what I saw in my side-by-side comparison. At this point I realized that the issue was most likely interference between the sensors, maybe in the form of echoed sound, so I repeated my original test and added a delay between taking readings with the two sensors. Suddenly the two sensors were now giving near identical results.
Some sensors were more sensitive than others, but adding a delay meant I could get the same readings from any of these sensors. In this particular test, the minimum delay between readings that gave consistent results was 15 milliseconds. This resulted in 42 readings per second with the iTEAD Studio sensor compared to 131 readings per second with the icstation one, which didn't need a delay at all. Even the high end Parallax Ping sensor required a delay between readings to get accurate results.
In my previous tests I had always taken a reading from an expensive sensor first and then immediately taken a reading from the cheap one before waiting one second before repeating the test. This meant I was never seeing interference with the expensive sensors and I had skewed the test results.
So my new conclusion is that these cheap HC-SR04 sensors are every bit as good as the $30 versions I had previously been using. The RadioShack module even appears to use the same schematic as the HC-SR04 except for the fact that it has 3 pins instead of 4. Is RadioShack really manufacturing these modules for $1 and selling them for a 30 x multiple of that cost? That is a pretty shocking markup.
I will be placing another order direct with China this week for more of these sensors for sure.