# Help understanding optocoupler wiring

**URL:** <https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984>\
**Category:** General Electronics\
**Created:** [July 25, 2021, 10:22pm UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984 "2021-07-25T22:22:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morke](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/morke/32/618037_2.png) [@Morke](https://forum.arduino.cc/u/Morke)\
**Post date:** [July 25, 2021, 10:22pm UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/1 "2021-07-25T22:22:34Z")

</div>

Hi all  
I have a project with a 4 module optocoupler relay, controlled by an esp32 Arduino.  
I wired the project following the instructions to isolate the esp32 MCU and the relay, powering the relay with an external 5v psu from JD-Vcc and Ground, and then the VCC to the MCU.

I understand that having separate Grounds isolates the high voltage circuit from the MCU and thus protects it.

However, I fail to understand how this works since a common ground should always be there for a circuit to work, right?  
What's working as a common ground here? or why does it work without one?

The other thing I don't understand is why the VCC, even when you are powering the relay's JD-Vcc and Ground using an external PSU  
Why do I need to connect also VCC to the MCU?

Thank you in advance for the help

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [July 25, 2021, 10:40pm UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/2 "2021-07-25T22:40:18Z")

</div>

Show us a good schematic of your circuit.  
Show us a good image of your ‘actual’ wiring.  
Give links to components.

[![](https://europe1.discourse-cdn.com/arduino/original/4X/5/5/8/558230033b63f41df693e5ce7065e3ba2a297c55.jpeg) ](https://europe1.discourse-cdn.com/arduino/original/4X/5/5/8/558230033b63f41df693e5ce7065e3ba2a297c55.jpeg)

---

<div class="post-metadata">

**Author:** ![Paul\_B](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_b/32/216376_2.png) [@Paul\_B](https://forum.arduino.cc/u/Paul_B)\
**Post date:** [July 25, 2021, 10:58pm UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/3 "2021-07-25T22:58:24Z")

</div>

> [@Morke](#):
>
> However, I fail to understand how this works since a common ground should always be there for a circuit to work, right?

No.

An electrical circuit is just that - a **circuit**. There must be a complete path for the current to go from one part to another and _return_.

The matter explained in the [reference](https://forum.arduino.cc/t/common-ground-and-why-you-need-one/626215) is simply that when you connect one part to another, and specifically an input device, you must connect not **only** the "signal" line but the corresponding **return** from one to the other otherwise you do not have a _circuit_.

So you connect 5V and control line from the ESP32 to the relay module (with the VCC to JD-VCC link removed). The return is the 5 V, not ground.

---

<div class="post-metadata">

**Author:** ![drmpf](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drmpf/32/1126438_2.png) [@drmpf](https://forum.arduino.cc/u/drmpf)\
**Post date:** [July 26, 2021, 12:56am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/4 "2021-07-26T00:56:04Z")

</div>

[**How to add a Relay to Arduino**](https://www.forward.com.au/pfod/HomeAutomation/OnOffAddRelay/index.html) has some comments on this, but may not be as helpful as you would like.

---

<div class="post-metadata">

**Author:** ![Bjerknez](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bjerknez/32/645919_2.png) [@Bjerknez](https://forum.arduino.cc/u/Bjerknez)\
**Post date:** [July 26, 2021, 4:33am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/5 "2021-07-26T04:33:03Z")

</div>

![Schematic_Complete path_2021-07-26](https://europe1.discourse-cdn.com/arduino/original/4X/d/a/f/daf3e8f159904f617f9e318c3db98fa9a03ca38a.png)

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [July 26, 2021, 5:45am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/6 "2021-07-26T05:45:24Z")

</div>

The one and only purpose of an optocoupler is to  
**- electrically isolate**

## and

**- transfer a signal**

which is done **not** by electrity but instead

## by light

(the two arrows in the middle

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/4/a/5/4a528b85e762effe64fea7f42584809dcaa81fee.png)

To keep the **fully** electrical isolation the GND of the arduino must be kept **dis** -connected from the relais-boards ground

best regards Stefan

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [July 26, 2021, 7:26am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/7 "2021-07-26T07:26:29Z")

</div>

Imaging you had a light dependant resistor on an input pin.

Then you shine a flash light on it, the resistance changes and you can see that effect on the Arduino pin.

There is no connection between the batteries in your flash light and the Arduino.

---

<div class="post-metadata">

**Author:** ![Morke](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/morke/32/618037_2.png) [@Morke](https://forum.arduino.cc/u/Morke)\
**Post date:** [July 27, 2021, 12:30am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/8 "2021-07-27T00:30:11Z")

</div>

Thank you all for the replies.  
I think I get the idea now!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 24, 2021, 12:30am UTC](https://forum.arduino.cc/t/help-understanding-optocoupler-wiring/888984/9 "2021-11-24T00:30:52Z")

</div>

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
