5V sensor to Raspberry PI

If I have a sensor which has 5V ouptut:

1. I can't plug it directly to Raspberry PI, right?
2. If so, what would I need to do so I would be able to do so?

I would like to connect it via input pins.

• Also, I'd suggest some googling as I see many answers to this already. – nerdwaller Nov 12 '13 at 1:14

You can use two or three resistors to form a voltage divider

Input----[ 1k ]-----[ 2k ]---GND
|
|
|
GPIO PIN

If your wires aren't too long, you can use higher resistors - say 10k & 20k

If you can't find 2k resistor, you can connect 2 1k resistors in series

Input----[ 1k ]-----[ 1k ]-----[ 1k ]---GND
|
|
|
GPIO PIN
• Can you also use a logic level shifter? – Steve Robillard Nov 12 '13 at 5:07
• @SteveRobillard, that would be another way. You could also use an optoisolater if the output of the sensor can source/sink enough current. – John La Rooy Nov 12 '13 at 5:09
• Might I suggest you expand your answer to include those for completeness. Maybe including links to adafruit.com/products/757 and adafruit.com/products/395 Assuming you do I will delete my conmments. – Steve Robillard Nov 12 '13 at 5:24
• I'm curious about when to use 1k/2k resistors versus using 10k/20k. I know that thanks to Ohms law, V=IR, therefore using higher value resistors will lower the current. Is the idea to use sufficient resistance to lower the current to the lowest acceptable range to minimize power consumption? – HeatfanJohn Nov 12 '13 at 15:26
• @HeatfanJohn, There is a compromise between the current and noise immunity. Without knowing anything about the sensor's output impedance, the frequency or the length of wires, 1k/2k resistors is a reasonable starting point. – John La Rooy Nov 12 '13 at 18:57

It is correct that you cannot directly connect a 5V sensor to the Raspberry Pi as it provides 3.3V. There's a great new cape for the Pi on kickstarter that allows you to use 5V sensors using GVS connections. Here's a link: https://www.kickstarter.com/projects/1546666383/gvs-board-for-raspberry-pi?ref=discovery

This is a great alternative to painful wiring.