HC-SR04 is crap and there is nothing you can do about it…

Only few days ago I mentioned that I started to reintroduce sonar support to INAV. When DigitalEntity told me that popular HC-SR04 is crap I did not belived him. I expected that “official” 4m range on a noise-machine aka quadcopter is unrealistic, but data I recorded today clearly shows: HC-SR04 is crap and is absolutely not suited for quadcopters and probably other UAVs. Why? Because it goes nuts and starts to pick background noise instead of surface.

Let’s take a look here:

Bottom trace shows pseudo Signal-to-Noise-Ratio (SNR) while top one shows raw HC-SR04 altitude and INAV position estimator altitude (GPS, barometer and accelerometer combined). As you can see, it’s not that bad. There is a correlation between both of altitudes and SNR is pretty low.

Same thing is happening here. Quadcopter descended to land, both altitudes went down to finally meet at zero. SNR is low too. Nice.

But, very bad things starts to happen as soon as altitude crosses 1.5m. Not only SNR goes up, but HC-SR04 starts to report completely unreliable data! If it was reporting out-of-range state, it would be fine. But no, it keeps reporting something between 1 and 2 meters while real altitude is much higher. Total crap.

Conclusion is simple: HC-SR04 can be used on multirotors but only on very low altitudes. Something like 0.75m over concrete. Or 0.5m above short grass. Or even less over long grass. Definitely not good enough for terrain following flight mode.

Next week I will test US-100 ultrasonic rangefinder. It is supposed to give much better results. I hope so…

3 thoughts on “HC-SR04 is crap and there is nothing you can do about it…

  1. Great, please keep us posted. I would like to see this operating in iNav, something like DJI can use it on the Mavic.

    1. Found in some Arduino forum:
      “… Basically, the difference (between HC-SR04 and UCS-100) is that the US-100 sends the measured distance over a serial connection rather than requiring the connected Arduino to measure the duration of a toggled pin (a method that does nothing for accuracy or precision)…”

      “…the reasons for the inaccuracies:
      1) Inaccuracy in measuring the echo timings
      2) Temperature variation
      US-100 avoids both of these issues. It has temperature compensation natively when used in serial mode. It avoids the need for precise measuring of the timing of pin state changed by sending the measured distance to a UART on the microcontroller. Result: improved accuracy and precision…”

      Source: https://forum.arduino.cc/index.php?topic=413624.0

Leave a Reply

Your email address will not be published.