I have a Raspberry Pi and a HC-SR04 integrated circuit for measuring distance. I have found many resources for how to connect the HC-SR04 to the GPIO of the Raspberry Pi, but because the HC-SR04 outputs at 5V, it is necessary to use two resistors to divide the voltage and everything I've found only shows how to connect the HC-SR04 to the RPi via a breadboard.

The schematic is not terribly complicated: enter image description here

I have the necessary resistors and numerous jumper wires, I'm just not sure how to wire it all up without a breadboard. Can anyone help?

  • Not really a Pi specific question.
    – joan
    May 17, 2018 at 16:51

1 Answer 1


The HC-SR04 is touted as a drop in replacement for the SN-SR04T. While I haven't tested this, I connect the SN-SR04T thusly

  • Pin 4 connects directly to the +5V connector
  • Pin 6 Connects directly to the GND connector, but is incorporated into the voltage divider for the Echo pin.
  • Pin 8 connects to the centre of the voltage divider.
  • Pin 10 connects directly to the Trig connector.

enter image description here

And the power supply connection can be seen a bit better here

enter image description here

See the book Raspberry Pi Computing: Ultrasonic Distance Measurement online for some extra details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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