relay issue

Laszlo
Posts: 2
Joined: Sat Jan 31, 2026 7:31 pm

relay issue

Postby Laszlo » Sun Feb 08, 2026 12:28 pm

Hello!
Sorry if I'm asking this question in the wrong place, but this is my first time here. I uploaded a picture of my relay. I want to control this relay with an esp32. I've tried all kinds of connections, but the relay doesn't work. I've already ruined an esp :)) The relay is powered by a 12V transformer, the esp is powered by 5V. I connected the + and - legs of the relay to the + and - legs of the transformer. I connected the ch legs to the Gipio legs. The previous relay, which was different, was connected in a similar way. I also tried leaving out the esp and trying to make it switch with only 5V, but it switched to both negative and positive. Maybe the relay is bad or I need more knowledge. Thanks for the help.
Attachments
Relay.jpg
Relay.jpg (2.93 MiB) Viewed 199 times

Sprite
Espressif staff
Espressif staff
Posts: 10644
Joined: Thu Nov 26, 2015 4:08 am

Re: relay issue

Postby Sprite » Mon Feb 09, 2026 1:12 am

You also need to connect COM to the negative of the ESP32.

Laszlo
Posts: 2
Joined: Sat Jan 31, 2026 7:31 pm

Re: relay issue

Postby Laszlo » Sun Feb 15, 2026 8:10 am

Thanks for your reply.
I think I already tried that and the ESP was broken. Could I try the relay without the ESP by connecting 12V to the relay, 5V negative to COM, and 5V positive to one of the relays? Would this connection work?

Sprite
Espressif staff
Espressif staff
Posts: 10644
Joined: Thu Nov 26, 2015 4:08 am

Re: relay issue

Postby Sprite » Tue Feb 17, 2026 6:11 am

Should work I think yes. Depends a bit on the circuitry on that relais PCB, but I wouldn't expect any issues.

eriksl
Posts: 232
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: relay issue

Postby eriksl » Fri Jul 31, 2026 9:14 am

If at all possible I'd really try to avoid using relays at all. If you get the control right, they still may generate so much EMI that your ESP crashes nonetheless.

If really want to use a relay then pay attention to these points:
- always add a flyback diode to the relay's coil, otherwise the induced voltage WILL destroy your gpio
- even better to use a MOSFET gate driver. It's not it's primary use, but it's designed to handle quite large currents

If you're switching large currents with the relay, expect arcs to occur. These will generate EMI and will probably crash your ESP.

mikemoy
Posts: 694
Joined: Fri Jan 12, 2018 9:10 pm

Re: relay issue

Postby mikemoy » Fri Aug 07, 2026 6:29 am

First you need to know what is the circuit driving the relay.
That circuit may require more than a GPIO pin can supply.
Also, even though the ESP32 is powered by 5V, does not mean your going to get 5V on a GPIO pin. The ESP32 itself is a 3.3v only device.
If you're switching large currents with the relay, expect arcs to occur. These will generate EMI and will probably crash your ESP.
Ya, for the relays you have this wont be a issue. maybe if your switching a contactor with 240vac to some insane load.

Who is online

Users browsing this forum: No registered users and 0 guests