Making a DIY Optocoupler

by taste_the_code in Circuits > Electronics

8324 Views, 80 Favorites, 0 Comments

Making a DIY Optocoupler

Super simple DIY optocoupler - Adding optical isolation in electronic circuits
20221229_092135.jpg
MVI_0709.MP4.00_00_01_13.Still001.jpg

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

MVI_0717.MP4.00_00_05_02.Still001.jpg

Prepare the LED and the LDR

MVI_0708.MP4.00_00_11_15.Still001.jpg
MVI_0708.MP4.00_00_21_22.Still002.jpg
MVI_0708.MP4.00_01_13_00.Still003.jpg

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

MVI_0708.MP4.00_01_39_11.Still004.jpg
MVI_0708.MP4.00_01_48_21.Still005.jpg
MVI_0708.MP4.00_01_52_22.Still006.jpg
MVI_0708.MP4.00_02_05_02.Still007.jpg

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

MVI_0708.MP4.00_03_30_21.Still008.jpg
MVI_0708.MP4.00_04_37_19.Still009.jpg
MVI_0708.MP4.00_04_46_10.Still010.jpg

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

MVI_0721.MP4.00_00_20_13.Still001.jpg

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.