ESPHome Relay not working help please

Hi, I’m just wondering if anyone can help me on this, i have a relay that i bought (Link to my relay), that I’m trying to control with an esp32 wroom (Link to my ESP32), and i just cant seem to get it working, i thought that the relays were pretty straight forward as I’ve implemented a few single channel ones without an issue

I’ve just added this to the bottom of the yaml, i haven’t added anything else just left it as the standard yaml that is generated

switch:
  - platform: gpio
    name: "Sonos"
    pin: 27
  - platform: gpio
    name: "Record Player"
    pin: 26 
  - platform: gpio
    name: "3D Printer"
    pin: 25
  - platform: gpio
    name: "Preamp"
    pin: 33

I cant see any issue in the logs, it connects to wifi fine, i turn it on and off in home assistant while checking the logs and it seems to be triggering fine also

[09:23:27][I][ota:117]: Boot seems successful, resetting boot loop counter.
[09:23:27][D][esp32.preferences:114]: Saving 1 preferences to flash...
[09:23:27][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[09:29:51][D][switch:012]: '3D Printer' Turning ON.
[09:29:51][D][switch:055]: '3D Printer': Sending state ON
[09:29:56][D][switch:012]: 'Preamp' Turning ON.
[09:29:56][D][switch:055]: 'Preamp': Sending state ON
[09:29:58][D][switch:012]: 'Record Player' Turning ON.
[09:29:58][D][switch:055]: 'Record Player': Sending state ON
[09:30:00][D][switch:012]: 'Sonos' Turning ON.
[09:30:00][D][switch:055]: 'Sonos': Sending state ON
[09:30:08][D][switch:016]: '3D Printer' Turning OFF.
[09:30:08][D][switch:055]: '3D Printer': Sending state OFF
[09:30:10][D][switch:016]: 'Preamp' Turning OFF.
[09:30:10][D][switch:055]: 'Preamp': Sending state OFF
[09:30:12][D][switch:016]: 'Record Player' Turning OFF.
[09:30:12][D][switch:055]: 'Record Player': Sending state OFF
[09:30:13][D][switch:016]: 'Sonos' Turning OFF.
[09:30:13][D][switch:055]: 'Sonos': Sending state OFF

any help would be great thankyou

Just a guess here but looking at your vs mine, you might need to change pin: 26 to pin: GPIO26 etc.

thanks for the reply, just tested that out though still didn’t work

Both are valid.

That’s a 5V relay board. It may or may not work with the 3.3V logic the ESP uses.

To test, apply power (5V) and ground to the relay board. Then carefully touch 3.3V from your ESP to one of the relay board trigger input connections. Does the relay turn on?

If not, try 5V to the relay board trigger input. Does that switch?

If you find 3.3V is not enough to trigger your relays there are cheap level converter boards available.

The relay board specifications say this:

Screenshot 2024-01-28 at 10-54-06 Ks0058 keyestudio 4-channel Relay Module - Keyestudio Wiki

Which theoretically should work with 3.3V logic:

I say “Theoretically” because they may not understand this standard and just list “TTL voltage” thinking this means 5V.

thanks for the in depth reply, where i bought it from said it was 12v power, so i have been powering via a seperate 12v power supply, what ended up making it work for me was the bridged pins, ground and common, i ended up removing the bridge and plugging the ground from the esp32 into the ground on the board and that done the trick

1 Like

If this is true then you got a different model than the one you linked to.
The device you linked to is clearly shown connected to 5V on the Arduino board.

Anyway you got it working, that’s the main thing. :+1:

1 Like