I am trying to connect a three pin ultrasonic sensor to my rPi Zero W.

I followed the tutorial to get the 4-pin ultrasonic sensor to work with my rPI Zero and was able to successfully connect. I am not sure how to get this same setup connected to a 3-pin ultrasonic sensor which has 5V, SIG, GND pin.

4-pin with rPI: https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi

Here is what I did for my 3-pin sensor. Used 1K and 2K resistors to split the voltage.

Link to my circuit: https://ibb.co/msE6DQ

NOTE: I am using 4 pin sensor for the diagram purposes since I couldn't find PING 3-pin sensor in Fritzing.

  • 1
    What does 5V to from raspberry actually mean? What device and how have you connected it?
    – Milliways
    Jun 28, 2017 at 23:48
  • There are dozens of ways in which one could connect a sensor to an RPi, and without a sketch of your connections it's impossible to tell what's wrong for sure. Jun 29, 2017 at 13:54

2 Answers 2


Yes. The something different is that the RPi uses 3.3v logic. You'll need some additional circuitry to translate that to the 5V your sensor needs.

The 5V pins on the RPi is for power only, and using that directly is not recommended as it bypasses the polyfuse..


According to me you do not want any additional circuitry for your ping ultrasonic sensor except a voltage divider. The physical pin 2 and 4 of Raspberry Pi zero give you 5V power and you can expect pull about 1.5A from these pins. But you only want 30mA to 35mA for the working of this sensor according to datasheet. So we can assume that there is no problem with connecting physical pin 2 or 4 of your Pi to Vdd of ping ultrasonic sensor directly. You can connect Pi's physical pin 6 (ground) also directly to ground of ping sensor. Then the problem begins.

Now you want to make signal(SIG) pin as input. From datasheet it is clear that signal pin output can have up to 5V. But the 5V as an input to GPIO pin can harm your Raspberry Pi. Since it GPIO pins are 3.3V(CMOS logic) tolerant. So you want to make a voltage divider between GND and SIG pin using two resistors R1 and R2.

If the resistances of R1 and R2 is same then the voltage splits in half(2.5V) since the maximum possible SIG is 5V. If the R2 is the twice the value of R1 then we get 3.33V approximately which is fine. So ideally we want R2 to be between R1 and R1 x 2. In this circuit we are using 330 Ω and 470 Ω resisistors. Alternatively you can use 270 Ω resistor and 330 Ω resistor or 1KΩ resistor and 1.5KΩ resistor. Then you can connect the SIG input to RasPi GPIO pin from junction of R1 and R2.

I am very new in Raspberry Pi. So you should critically think about this answer. I believes Raspberry Pi Stack Exchange community will help you to think critically about this answer.

  • I added my circuit diagram following your recommendation. Not sure if I did it right.
    – ed1t
    Jul 1, 2017 at 15:06
  • @ed1t HCSR04 echo pin is equivalent to ping's SIG pin. But no problem. That was only a schematic diagram. Make GPIO as input for connecting SIG pin. Find out the actual sensor settling time from datasheet. Measure the time elapsed between the SIG pin to be HIGH and low. Find out distance by using equation (time*speed of sound)/2. I am using HCSR04 but I still believes this will work.
    – Arun
    Jul 2, 2017 at 4:24

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.