# Triggering ESP32 and Optocoupler together

**URL:** <https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033>\
**Category:** General Guidance\
**Created:** [September 1, 2025, 6:07pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033 "2025-09-01T18:07:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![high\_impact](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@high\_impact](https://forum.arduino.cc/u/high_impact)\
**Post date:** [September 1, 2025, 6:07pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/1 "2025-09-01T18:07:54Z")

</div>

I want to trigger both a GPIO pin on an ESP32 and an optocoupler relay by using just one ground signal. Is it possible to hard wire the GPIO input pin to the input of the relay, and then ground that connection when I want them both to trigger? Otherwise would I have to add a separate GPIO output to drive the relay?

---

<div class="post-metadata">

**Author:** ![BitSeeker](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bitseeker/32/1241632_2.png) [@BitSeeker](https://forum.arduino.cc/u/BitSeeker)\
**Post date:** [September 1, 2025, 6:34pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/2 "2025-09-01T18:34:39Z")

</div>

Hi high\_impact. Welcome to the forum!

> [@high\_impact](#):
>
> I want to trigger both a GPIO pin on an ESP32 and an optocoupler relay by using just one ground signal.

No quite sure what you mean by this as ground is generally common? Perhaps you could provide a wiring diagram of what you intend to do? It can be a photo of a hand drawn diagram.

> [@high\_impact](#):
>
> Is it possible to hard wire the GPIO input pin to the input of the relay, and then ground that connection when I want them both to trigger?

If you mean to drive the relay then NO! Do not wire GPIO pins direct to a relay drive coil. Driving a relay requires back EMF protection using a diode. In addition, the current from the GPIO is unlikely to be anywhere near enough to drive the relay and will result in a fried GPIO, and possibly further damage to the MCU. You will will need a drive transistor, FET, or a driver/controller board.

---

<div class="post-metadata">

**Author:** ![high\_impact](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@high\_impact](https://forum.arduino.cc/u/high_impact)\
**Post date:** [September 1, 2025, 7:30pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/3 "2025-09-01T19:30:43Z")

</div>

See diagram. Not a regular relay.

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

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [September 1, 2025, 8:30pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/4 "2025-09-01T20:30:25Z")

</div>

Should work if relay input jumper is set to "L", though GPIO18 will be pulled up through R1 and opto LED.

---

<div class="post-metadata">

**Author:** ![high\_impact](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@high\_impact](https://forum.arduino.cc/u/high_impact)\
**Post date:** [September 1, 2025, 8:44pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/5 "2025-09-01T20:44:24Z")

</div>

Appreciate the replies to my 1st post

---

<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:** [February 28, 2026, 8:44pm UTC](https://forum.arduino.cc/t/triggering-esp32-and-optocoupler-together/1405033/6 "2026-02-28T20:44:37Z")

</div>

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