Hi all,
I’m posting my integrations with a 4 channel relay board which is both cheap and easy to configure.
Board can be found here link to banggood
It hosts a detachable ESP-01 (8266EX) with 1M memory.
issue is that the ESP8266 is not using GPIO pins to trigger the relays, an additional processor is on board to do that called an STC15L101EW
From the datasheet it turns our that this chip uses UART to communicate with the ESP8266.
So steps to get this working with esphome.
-
get a usb flash programmer (left one)
-
make sure you solder the wire bridge as shown here. You cannot flash the ESP8266 when this is not present.
-
create a new device using the esp01_1m profile
add this to your configuration file:
- an esphome stanza and logger, wifi ota items should be there already
- Modify the logger entry to include **baud_rate: 0 ** this will disable local logging messing up the ESP8266 uart, which we need to communicate with the STC15L101EW board
# Enable logging
logger:
baud_rate: 0 #need this to free up UART pins
uart:
baud_rate: 115200 # speed to STC15L101EW
tx_pin: GPIO1
rx_pin: GPIO3
switch:
- platform: uart
name: "A1on"
data: [0xA0, 0x01, 0x01, 0xA2]
- platform: uart
name: "A1off"
data: [0xA0, 0x01, 0x00, 0xA1]
- platform: uart
name: "A2on"
data: [0xA0, 0x02, 0x01, 0xA3]
- platform: uart
name: "A2off"
data: [0xA0, 0x02, 0x00, 0xA2]
- platform: uart
name: "A3on"
data: [0xA0, 0x03, 0x01, 0xA4]
- platform: uart
name: "A3off"
data: [0xA0, 0x03, 0x00, 0xA3]
- platform: uart
name: "A4on"
data: [0xA0, 0x04, 0x01, 0xA5]
- platform: uart
name: "A4off"
data: [0xA0, 0x04, 0x00, 0xA4]
- platform: restart
name: "4switch_a Restart"
-
save and validate, compile, download binary and
-
use esphome-flasher to flash the ESP8266 module with the firmware you just compiled.
-
when done disconnect usb flasher from computer and put esp module into relay board.
-
wait a minute, esp8266 takes a fair bit of time to start up.
-
add an integration for this board into home-assistant and you’re good to go.
ps. the beauty of this board is that relay states won’t be changed when upgrading the esphome firmware (as they are controlled by the second chip) and the relays have both a NO and NC connection making this board ideal for hotel (or failsafe) wiring setup.