Making a DIY Optocoupler
by taste_the_code in Circuits > Electronics
8324 Views, 80 Favorites, 0 Comments
Making a DIY Optocoupler
When I was working on my garage door opener, I had trouble controlling a 12V relay from a 3.3V NodeMCU board and at the time, I did not have any optocouplers available. Hence, I had to resort to using a 5V relay.
While looking at what I could do, I came to the idea of making my own optocoupler just out of curiosity so I could see if the idea would work and I must say that it worked better than I thought it will.
By using an LED and an LDR, I constructed a simple optocoupler that I then used to control a 12V relay from a 5V power supply.
Supplies
- Light dependent resistor LDR - https://s.click.aliexpress.com/e/_DmG4odt
- White LEDs - https://s.click.aliexpress.com/e/_DeCCVnv
- Heat shrink tube - https://s.click.aliexpress.com/e/_DDc3xKf
- Resistors - https://s.click.aliexpress.com/e/_DDgMeK7
- Electrical Tape - https://s.click.aliexpress.com/e/_DkCqaP5
- Wire snips - https://s.click.aliexpress.com/e/_Dks0H4b
- Needle nose pliers - https://s.click.aliexpress.com/e/_DFIzTKR
- Multimeter - https://s.click.aliexpress.com/e/_Dm3Eo7V
Prepare the LED and the LDR
Both of the devices will be enclosed with heat-shrink tubing as close as possible to each other so it is very important that we make proper electrical isolation in the LED and LDR leads.
To do this, I used the smallest heat-shrink tube that I had and I added it to the legs of the LED and the LDR. This will provide that electrical separation within the component.
Construct the Optocoupler
To construct the optocoupler, I used a 5mm heat shrink tube and I first placed the light-dependent resistor inside, making sure to cut off the excess so there is only enough heat shrink for the LED body.
The LED has a small lip at the end that was not able to fit the tube but we will handle this in the next step.
Minimize Light Leakage
To make sure that the optocoupler is not affected by external light, it is critical that we isolate it from external light as best as we can. Since the LED has one side exposed, I've cut and placed a small piece of electrical tape over it and then I also covered the entire optocoupler with one more heat shrink tube.
Since I only had yellow heat shrink, the end result was not perfect so in the end, I also wrapped the entire optocoupler with one more piece of electrical tape.
Test the Optocoupler
To make sure the optocoupler works, I made a circuit where I had its LED connected to a 5V power supply with a 100 Ohm resistor in series. This will provide around 20mA of current through the LED, making it sufficiently bright.
On the other end, I had the relay connected to 12V where the signal pin was connected with a 4.7kOhm resistor to 12V and to ground through the LDR.
When no light shines on the LDR, its resistance is very high, so the 4.7kOhm resistor keeps the signal pin high and the relay is off. As soon as we turn on the LED, the resistance of the LDR will drop and it will pull the relay signal pin to 0V so the relay will turn on.
This worked surprisingly well so I can say that the experiment was successful and I'm quite happy with the results.
If you thought that this is interesting, be sure to check my other Instructables and also my YouTube channel. The entire build and testing of the DIY optocoupler can be seen in the build video.