Author Topic: 12v car power to gpio input - opto isolator?  (Read 285 times)

Offline n8huntsman

  • Newbie
  • *
  • Join Date: Jan 2015
  • Location:
  • Posts: 32
  • Kudos: 1
12v car power to gpio input - opto isolator?
« on: January 11, 2019, 01:00:36 PM »
Im running an rpi with pi cap on my RZR Offroad utility vehicle. Im going to pull a +12v wire from the brake light circuit to control a gpio input.


I think I need an opto isolator like this circuit: https://www.raspberrypi.org/forums/viewtopic.php?t=177841#p1133968
It needs to be pretty tough because of all the bouncing around it will experience so Id like to find a breakout board thats already made. If not I can make it but would rather not.
Has anyone found something like that?
Will I need the debouncing cap?
Am I missing a simpler solution?
Thanks
« Last Edit: January 18, 2019, 05:29:32 PM by n8huntsman »

Offline n8huntsman

  • Newbie
  • *
  • Join Date: Jan 2015
  • Location:
  • Posts: 32
  • Kudos: 1
Re: 12v car power to gpio input - opto isolator?
« Reply #1 on: January 18, 2019, 11:57:13 AM »
Anyone?

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,798
  • Kudos: 208
Re: 12v car power to gpio input - opto isolator?
« Reply #2 on: January 18, 2019, 12:19:58 PM »
I think what you are describing would work, here's another example without the debouncing cap:  https://www.raspberrypi.org/forums/viewtopic.php?t=173362#p1108927

The only other thing that I can think of would be a relay, but I'm not sure that is simpler and it could be bouncing around when offroad. :) You may be able to find a small pre-made board with an opto isolator on it on sparkfun somewhere.  I saw several when googling for a solution but didn't look at the details on them.
-
Chris

Offline n8huntsman

  • Newbie
  • *
  • Join Date: Jan 2015
  • Location:
  • Posts: 32
  • Kudos: 1
Re: 12v car power to gpio input - opto isolator?
« Reply #3 on: January 18, 2019, 01:00:46 PM »
I've looked over there and this is the closest thing I can find: https://www.sparkfun.com/products/9118
Not sure if it would work or not; because the extra transistors are confusing me.  The schematic is here: https://www.sparkfun.com/datasheets/BreakoutBoards/Optoisolator-v12.pdf




I'm leaning towards just building it myself on a proto-board and using a couple 6N137 opto's.  I need at least two inputs to control the falcon player.

Offline David_AVD

  • Jr. Member
  • **
  • Join Date: Jul 2014
  • Location: Victoria Point (QLD - Australia)
  • Posts: 71
  • Kudos: 1
    • da-Share
Re: 12v car power to gpio input - opto isolator?
« Reply #4 on: January 18, 2019, 04:14:12 PM »
I've done up a quick schematic that is similar to the one you linked to, but with revised values.


da-share.com - the home of da_Tester and other handy stuff

Offline n8huntsman

  • Newbie
  • *
  • Join Date: Jan 2015
  • Location:
  • Posts: 32
  • Kudos: 1
Re: 12v car power to gpio input - opto isolator?
« Reply #5 on: January 18, 2019, 04:25:34 PM »
Is your circuit 24v (+12v and -12v) or is that -12v intended to be a ground?


The more I stare at the spark fun gizmo above I think it would work.  Looks like it designed to use the GPIO's as outputs not inputs.  Not sure if it would work the other way around.

Offline n8huntsman

  • Newbie
  • *
  • Join Date: Jan 2015
  • Location:
  • Posts: 32
  • Kudos: 1
Re: 12v car power to gpio input - opto isolator?
« Reply #6 on: January 18, 2019, 07:26:40 PM »
https://www.amazon.com/Voltage-Level-Converter-12V-3-3V/dp/B01EY7626K/ref=sr_1_fkmrnull_1?keywords=Optoisolator%2B12v%2Bto%2B3.3v&qid=1547865453&sr=8-1-fkmrnull&th=1#customerReviews


I think this would work.  Probably add a 560Ω resistor to the GPIO to protect it in case, for whatever reason, it turns itself into a 3.3v output while the opto is pulling it to ground, as recommended on the RPI forum.
Is there any downside to the GPIO being pulled high and my 12v circuit pulling it low?  False triggering or anything?  How about debouncing diodes?  Anyone know if I need it?
Thanks
« Last Edit: January 18, 2019, 07:48:48 PM by n8huntsman »

Offline David_AVD

  • Jr. Member
  • **
  • Join Date: Jul 2014
  • Location: Victoria Point (QLD - Australia)
  • Posts: 71
  • Kudos: 1
    • da-Share
Re: 12v car power to gpio input - opto isolator?
« Reply #7 on: January 19, 2019, 02:42:24 PM »
You can certainly add a resistor (1K) between the output of my circuit above and the pi's GPIO pin.

The input to the opto is 12V.  I just marked them as + and - but can see how that can be confusing.

 

Back to top