Triggering ESP32 and Optocoupler together

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?

Hi high_impact. Welcome to the forum!

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.

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.

See diagram. Not a regular relay.

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

Appreciate the replies to my 1st post