tehinternet
Posts: 5
Joined: Sat Feb 23, 2013 12:22 pm

Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 12:54 pm

Hello,

I am looking to take 5v output from the pi and run it to a simple switch (e.g. a door open/closed sensor), back to the Pi's GPIO and detecting if there's voltage or not. I can do the programming, but I'm rusty on the actual wiring. If I understand it, the 5v needs to be be dropped down to 3.3v to not kill the GPIO.

I have done this once before...I have the "switch" dangling above my sump pump pit and if the water rises to high, it completes the circuit and the GPIO is seeing a different value than it normally sees. Problem is, I can't take a look at my current setup to do a new one for a friend.

Will this setup work without killing the pi, and allow the GPIO to listen for a 0 or 1?

Thanks.


Image

hippy
Posts: 7911
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 1:06 pm

Yes, that should work but it might be better to feed the switch with 3V3 from the Pi, or even have the switch shorting to 0V.

Code: Select all

         \
3V3 >---O O---.      3V3 -    1K
         __   |               __     \
I/O <---|__|--'      I/O <---|__|---O O---.
         1K                               |
 0V -                 0V >----------------'

tehinternet
Posts: 5
Joined: Sat Feb 23, 2013 12:22 pm

Re: Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 1:24 pm

hippy wrote:
Thu Aug 15, 2019 1:06 pm
Yes, that should work but it might be better to feed the switch with 3V3 from the Pi, or even have the switch shorting to 0V.

Code: Select all

         \
3V3 >---O O---.      3V3 -    1K
         __   |               __     \
I/O <---|__|--'      I/O <---|__|---O O---.
         1K                               |
 0V -                 0V >----------------'


Thanks. I am really rusty...rusty enough to forget the pi might offer 3.3v output. I want to make sure I am understanding your diagram correctly, especially the left one.

Is that 3.3 volts out, to the switch, to a 1k ohm resister to the GPIO? Is the 0v a GRD/Ground pin? Where does that fit into the picture? I'm not sure how to connect it.

As for the second ASCII drawing, is that: 3.3 volts to 1k ohm resister, one direction going to GPIO, the other to the switch and finally to ground?

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 1:48 pm

First do not connect 5v to the pi gpio or you will kill your pi, gpio is 3.3v and not 5v tolerant.

For pull-ip or pull-down using external resistors look at this web page it has both circuits shown

https://github.com/raspberrypilearning/ ... up_down.md

Looks like you want the pull-down circuit.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

tehinternet
Posts: 5
Joined: Sat Feb 23, 2013 12:22 pm

Re: Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 2:17 pm

pcmanbob wrote:
Thu Aug 15, 2019 1:48 pm
First do not connect 5v to the pi gpio or you will kill your pi, gpio is 3.3v and not 5v tolerant.

For pull-ip or pull-down using external resistors look at this web page it has both circuits shown

https://github.com/raspberrypilearning/ ... up_down.md

Looks like you want the pull-down circuit.
Thank you for that. That's a helpful site you linked to and helps get me back up to speed.

hippy
Posts: 7911
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using Pi's 5v Output and detecting it on a GPIO

Thu Aug 15, 2019 4:20 pm

tehinternet wrote:
Thu Aug 15, 2019 1:24 pm
Thanks. I am really rusty...
No problem. On the left in my diagram, 0V/GND not connected, on the right, 3V3 not connected.

Wire from I/O to 1K to switch to whichever, 3V3 or 0V.

Return to “General discussion”