Esphome - esp8266 and relay

hello, please I have a request, I am trying to switch relays via ESP8266 via Home Assistant and ESPHome. Below is the yaml file, I have it connected to D5 and I feed the relay with a source with 5V of course. Still it won’t switch the relay for me. please see where i am doing wrong? Thank you

esphome:
name: esp8266-03-rele
friendly_name: ESP8266_03_rele

esp8266:
board: esp01_1m

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “O4suvQERKeIhFfAMzFQWV7WptJ5lT/7lfPgPDlWexzc=”

ota:

  • platform: esphome
    password: “7ccf8ea31c3859502cab80ed41615faf”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Esp8266-03-Rele Fallback Hotspot”
password: “X48mE3q4fiSK”

switch:

  • platform: gpio
    id: relay
    name: “Rele svetlo venku”
    pin: GPIO14
    inverted: true # Inverted logic

Can you share your yaml using the preformatted text option. while you are typing your post you can see </> above your typing window. This will help anyone trying to help you. Check whether your relay is high or low triggered. Some of the relays give you option to choose high or low value triggered. You may try to comment the inverted: true option during testing. If the relay works without the inverted option, you may remove it from yaml.

2 Likes

Post an image or link to your relay. Some relays are tricky with 3.3V input.

1 Like

I have this
https://www.gme.cz/v/1509173/rele-modul-5v-1x-10a-250v-low-trigger?srsltid=AfmBOoqeWlBqt38idCf4diiYKUCmXjdeoOE9awu_4NFr4SPFJwlWq39D

esphome:
  name: esp8266-03-rele
  friendly_name: ESP8266_03_rele

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "O4suvQERKeIhFfAMzFQWV7WptJ5lT/7lfPgPDlWexzc="

ota:
  - platform: esphome
    password: "7ccf8ea31c3859502cab80ed41615faf"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp8266-03-Rele Fallback Hotspot"
    password: "X48mE3q4fiSK"

switch:
  - platform: gpio
    id: relay
    name: "Rele svetlo venku"    
    pin: GPIO14
    inverted: true  # Inverted logic


Remove the jumper, then connect 5V to JD-vcc leaving the vcc pin unoccupied.
On the 3-pin header connect 3.3V (VCC), Gpio14(IN1), GND.

and correct your board, whatever it is,
esp01 goesn’t have gpio14 exposed

Thank you, but here is gpio14 https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2019/05/ESP8266-NodeMCU-kit-12-E-pinout-gpio-pin.png?w=817&quality=100&strip=all&ssl=1 on D5

Not on Esp01

What you have? D1 mini? Nodemcu?

But i have esp 8266 nodemcu like on the picture

then it should be:
board: nodemcu

1 Like