So I'm using the HC-SR04 modules to get the distance to objects, the problem is that if it's not a perpendicular surface I dont get any reading, and I assume that the reason is that the ultrasounds get reflected in another direction, so they don't come back to the sensor. What's the way to get over this issue?

Thanks in advance

  • To use a completely different sensor. Jan 14, 2015 at 17:01
  • I'm guessing that the sensor sends only one column of sound, thus it would bounce off to another angle. I'm not sure how a light sensor would work... Jan 14, 2015 at 21:49
  • SO what sensor would it be?
    – Dane411
    Jan 15, 2015 at 12:35
  • What is the surface made of & what sort of range are we considering? Jan 15, 2015 at 13:45
  • The ideal scenario would be a room inside a building, so the range would be from some cm to a few meters. The surface any kind of material I'd say
    – Dane411
    Jan 15, 2015 at 15:08

3 Answers 3


Use a Infrared Proximity Sensor enter image description here


Something like a LidarLite enter image description here

They measures distance by measuring the offset (parallax) from a projected point of light. This will not suffer from echo restrictions, like Ultrasonic Sensors do.


You mean to say that you get proper reading when the surfaces are FLAT? Ultrasonic sensors have this property that the waves emitted from then are only 15 degree from the line of sight, but this means that you can surely calculate distance of objects having a curved shape. The only condition is the object should be directly in a straight line

  • 2
    That's not the issue. Rather, when the surface is sufficiently canted, most of the energy bounces off in some other direction and not back at the transducer, meaning no echo is measured. It's not entirely different from a mirror, or bouncing a ball off a wall. Feb 6, 2015 at 13:49

Coming in late but seeing no solutions offered yet, I'll take a stab at it:

Assume your vehicle is traveling obliquely toward the wall. Assume you can find and measure the perpendicular distance to the wall. Then you can calculate the travel distance from those two measurements:

enter image description here

Next we need to find the angle between the vehicle's heading (center-line) and the perpendicular. A rotating sensor that senses return-signal strength could probably give good results but is mechanically more complicated. Given that the ultrasonic sensors have a somewhat broad sensing angle, 3 or 5 fixed sensors (1 straight ahead and 1 or 2 to either side) may work well enough if you're just trying to avoid hitting the wall. In that case you could measure with all of the sensors, take the least distance measurement as 'p' and the known angle of that sensor as 'theta'.

What's left is to decide how to make the calculation and work with cosines. For the rotating sensor case, you'll have to find the angle of the sensor at the time of it's smallest reading, and look up in a table (or calculate) the cosine of that angle. For the multiple fixed sensors case, you already know the sensors' angles and therefore, their cosines.

If you have enough code memory it would easy to write your calculations in floating point, certainly for some quick and dirty testing. If not, or you need to speed up the calculations, you can do it in fixed point with less code. it's a little bit harder for the programmer but much easier and quicker for the MCU.

  • Please note that ultrasonic sensors tend to interfere with eachother depending on environments and how close they are pointed to eachother in degrees and how close a wall is
    – benathon
    May 11, 2015 at 13:04
  • Yes, they would need to be pinged sequentially, and the smallest reading taken.
    – JRobert
    May 11, 2015 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.