ESP-01 Relay board configuration

In case anyone struggles with the ESP-01 based relays like I did, here’s the configuration I found to be successful.

Here’s the item:
esp01

First, if you have a problem flashing these, check out my other post about that:
Flashing ESP-01 - Permission Error 13

I decided to post this final form as I feel like even though there’s a lot of information out there, for me it was very hard to find since I didn’t know what to look for (i.e. baud rate).

Here’s the working configuration:

esphome:
  name: boiler
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "xxxxx"
  password: "xxxxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "xxxxx"
    password: "xxxxx"

captive_portal:

# Enable logging
logger:
  hardware_uart: UART1

# Enable Home Assistant API
api:
  password: "password"

ota:
  password: "password"

web_server:
  port: 80

uart:
  baud_rate: 9600
  tx_pin: GPIO1
  rx_pin: GPIO3

switch:
  - platform: gpio
    name: "Boiler relay"
    id: "relay"

    pin: GPIO4 # using ESP module LED
    inverted: false
    on_turn_on:
      - uart.write: [0x0a0, 0x01, 0x01,0x0a2]
    on_turn_off:
      - uart.write: [0x0a0, 0x01, 0x00,0x0a1]
2 Likes

Oh thanks, this helps a lot! Resale site did mention baud rate but now I understand the use!

1 Like

Oh much thanks! I was so naive to guess that the relay is controlled by low/high voltage from GPIO0/2. Then I realized it has a STC15F104-SOP8 MCU on the board.

In case if anyone needs the diagram of the board

1 Like

Hello,
I tried to use the configuration in above. But it is still the relay not responding to the switch and the LED on the board continuously blinking.
Do you know what is the root cause of the issue?

Oh wow, thank you!
Maybe now I’ll fix my broken one :slight_smile: