Electronic – Accurately measuring distance using ultrasonic rangefinder

range-detectorultrasound

I need to measure the distance to an unknown object, which can be made out of any material. The solution should be low-cost, so I assumed using a HC-SR04 sensor would be a good choice.

Would an ultrasonic sensor like that be able to measure the distance to any object accurately (with a maximum error of 1cm) without knowing what material that object is made out of?

The distance I have to measure is approximately a range of 0-0.5m.

As an alternative, I could possibly also settle for the ability to detect if an object is present between the sensor and a known background pane for example. Measuring the distance would be preferable, but that might also work.

Best Answer

Short answer:

Probably not.

Long answer:

Ultrasonic sensors are very sensive to the shape and surface of the object distance to which is being measured. If the surface is relatively flat and very large (book, wall etc.) and is parallel to the sensor lineup you could have some good results after calibration and taking the average of many measurements. However not even then an error of 1cm or less can be expected at all times on a distance of 50cm. Additionally, if your surface if uneven with irregularities of +-1cm or so, you will have additional fault introduced. From my experience you will have hard time implementing a system of this precision cheaply using ultra-sound. My advice would be to lower the expectations of the precision of the system. You could also try out some cheap infra-red sensors, they can be more accurate under some circumstances.

A general hint is that the object you want to measure the distance to should have a decent area exposed to the sensor. At a distance of 50cm using a cheap sensor we are talking at least 5-10 centimeters or more in order to get any reasonable reading.