HC-SR04 Sonar & APM 2.8

I have seen mixed answers on whether or not I can use HC-SR04 Sonar with my APM 2.8. It is not in the list of supported sensors but I’m pretty sure it gives out an analog voltage so shouldn’t it work? I would like to use it for forward facing anti-collision. I have attached a wiring diagram that I made and would like to know if it is correct. Also, what settings would I have to change to enable it? Thanks,

The HC-SR04 doesn’t work with the APM for some reasons:

  1. It doesn’t return an analog voltage.
  2. It works by sending a signal at trigger and awaiting a return at echo. And here is the second problem: You would have to use the pulseIn() function which stops the code until the signal is received, so the copter wouldn’t react to changes and crash.

There are boards with a small arduino that convert the signal from the HC-SR04 to a analog voltage, but in my experience this don’t work really well…

1 Like

Those questions pop up time and time again. The HC-SR04 is cheap, but that is about all that speaks for it. You will have to buy additional hardware to make it work with an autopilot that is not supported anymore. So you are investing in a dead end. There are low cost flightcontrollers available today, which will support the latest firmwares and lidar sensors, which are also not as expensive as they used to be.


1 Like

Yeah, I already have the APM 2.8 and I would like to keep using as it is a decent board. I have seen a few videos and articles of people using them on APM though? I am just hoping to be able to use some cheap gear I already have. Thanks,
Ex, https://www.dronetrest.com/t/using-sonar-hc-sr04-to-avoid-ground-collision/6000
Ex2, https://www.youtube.com/watch?v=aNZLQPg6CEE

The performance is so bad as to not be worth the effort. But for $4 it will make a interesting Christmas tree ornament.