Using Optocouplers with the Raspberry Pi
Why Raspberry Pi Stack Exchange recommends it
Raspberry Pi Stack Exchange answerers point people to it when they need to isolate the Pi's GPIO from motors, pumps or higher-voltage circuits.
Recommended by 4 people across 4 different months, 2014 to 2020.
What it is
A short 2013 tutorial by Gaven MacDonald on using an optocoupler (opto-isolator) to protect the Raspberry Pi's GPIO pins. It explains the concept and shows how to wire one so the Pi can switch or sense another circuit without a direct electrical connection.
What people said
Recommends Simon Berka · 2014-07 · Raspberry Pi Stack Exchange · on “Powering a 3-12V water pump on raspberry pi”
The simplest thing you can do is to use optocoupler. This allows you to power the pump with whatever voltage you like without any electrical connection between your Pi and pump and you will be still able to control it from Pi. Check this video for example: [this video]
Recommends Steve Robillard · 2017-10 · Raspberry Pi Stack Exchange · on “Why optocoupler (4N35) needs resistor?”
Inside the optocoupler is an IR LED on one side (between pins 1 and 2) in the image below and a phototransistor on the other (pins 4, 5 and 6). [LINK] And so the resistor is there for exactly the same reason it is in every other LED circuit to limit the current and thereby protect the LED, as this quote from the tutorial you are following makes clear: To protect the LED from burning, usually a resistor (about 1K) is connected to pin 1. These two youtube videos do a good job of describing how an optocoupler works: How an Optocoupler (Optoisolator) Works [LINK] Using Optocouplers with the Raspberry Pi [this video] Note: that while the too optocouplers used in the above videos are different (and hav
Recommends Ziomuś Gorliczanin · 2019-09 · Raspberry Pi Stack Exchange · on “Wiring GPIO pins to press hardware button on USB MOUSE”
i have soldered out buttons and replaced them with wired in USB mouse. Mouse itself is connected to device. Is it possible to wire those cables to GPIO in Raspberry PI model 2. And control clicks via python? I have little project to do but must be used hardware click. I am attaching photos what i have done so far. And this page for reference: [LINK] How can i put it all together? What else would i need? Thanks for any tips. What i was thinking is connect ground to grd pin in rpi gpio and use pin 18 and resistor for left button wire to control it via python. Current in button is 2.7V. I am newbie please shine some light over it for me. I dont want to burn my PI on first try that is why im ask
Recommends Mats Karlsson · 2020-09 · Raspberry Pi Stack Exchange · on “How to detect an electric current in a secondary circuit (12v)?”
I would recommend that you use a Opto Coupler. An Opto coupler consist of a LED (Light Emitting Diode) and a Photo sensitive transistor. That will create a safety isolation between your motor that creates nasty electrical spikes and your precious Raspberry Pi. Take a look at the Youtube video for more detailed info [this video] If you really want to measure the current then is a ACS712 (Current Hall sensor) and since the Raspberry Pi doesn't have a Analog input a ADS1115 (Analog to Digital converter) that has a I2C interface that Raspberry Pi understand.