Home > RaspberryPi > HC-SR04 with Raspberry Pi

02/20/2023

HC-SR04 with Raspberry Pi

Writing about HC-SR04 with Raspberry Pi for educational and informational purposes only. however, do not hesitate to use this information on your own risk as we make no warranty of any kind.

Demo how HC-SR04 works using a Raspberry Pi

Wiring
HC-SR04 comes with 4 pins, let's make it simple:
Connect VCC to 5V. Connect GND to ground. Now you need 2 GPIO of your choice, I'm using 7 and 11. Use one to connect to TRIG directly.
Now is the tricky part, you need 2 resistors (1K and 2K) to reduce the voltage down. I'm not going to get into the math of it here.
Connect the GND to the other GPIO via the 2K resistor.
Connect the ECHO to the 1K resistor then the 1K resistor to the 2k resistor which is already connected to the GND.

HC-SR04 with Raspberry Pi
All content and information on this web site is intended for educational and entertainment purposes only.