HC-SR04 Sonar Rangefinder

How to connect the HC-SR04 Sonar rangefinder and Pixhawk. Should I connect it to the “SERIAL 4&5” port on the Pixharwk side?

Please refer to this page for how to connect it to the pixhawk:

I don’t know exactly where to put it on the flight controller.

Good day, HC-SR04 sonar is i2c…just take care with that sonar due the limitations of cones

Hey! It’s not I2C. It goes on servo pins. Have to set 2 GPIOs, one for trigger and one for receiving.

Where should I insert it on the servo pin?

I don’t quite understand this explanation.

the one I’ve tested before is i2c… maybe they have done different versions…

Should I connect it to the I2C connector?

Where do I connect the SCL and SDA of I2c?

Does it look like this?


If so it’s not I2C, you would configure 2 GPIO pins. The link to the Wiki is clear about how it’s connected and configured.

And then after you get this cheap sensor working performance will be very bad and you will remove it…


if you sensor is i2c you can find sda and scl written on the board and you can connect it on a i2c splitter, if its gpio you need follow the pinout of the board with the pinout of the fc.
what fc are you using?

The flight controller is pixhawk.

Is the HC-SR04 sonar rangefinder i2c? :question:
Is it GPIO :question:

just attach pls you rangefinder so we can help you

Doesn’t it require an attiny or something like that, to make the HC-SR04 talk i2c? I saw HC-SR04 sold prefitted with an attiny, but most of them should be GPIO.
Anyhow, as Dave said, just get a supported lidar like the tfmini and never look back.

a good option can be the tf mini s with a can node

I think you are right. I tried a couple of these cheap sonar units several years ago and you get what you pay for. These can be had for $1 on ebay, so there you have it.

1 Like

I have the HC-SR04 Sonar Rangefinder attached to my drone.
At the time of purchase, only HC-SR04 Sonar Rangefinder was included


This one have a i2c interfaceScreenshot_20200722-220518_Chrome

Right. That’s the one Sebastian was referring to.