ESPHome with any ESP8266 Relay board?

I am looking at buying a 8 channel ESP8266 relay board. Am I correct to assume that as long as they have a ESP8266 chip I will be able to integrate it easily with ESPHome? The documentation that comes with these relays is minimal or non existent. Some come with firmware others not, some mention they integrate with Arduino but not much else.

I am looking at something like this:
https://www.aliexpress.com/item/1005003624371963.html

Relay Board

Looks like each relay is connected to a GPIO on the top PCB layer. So it should not be too difficult to create a configuration for once you have traced out the connections.

Thanks. So I can do this in all ESPHome? Just need to make some basic changes to the yaml file? And ESPHome will recognize the ESP8266 chip?

Yes. They even labelled the serial connections for you.

Thanks! Much appreciated.

Hm…i’d rather buy some board with I/O chip (mcp23xxx,…). Many users complain that power-up relay flickering is a big problem…

@Robufz i am using that exact relay with ESPhome. Just had to flash it using ftdi 2 serial adapter first.

Do you have any relay flickering at power-on? On esp8266 i think there are only 2 or 3 pins who don’t have “odd” signals at boot… (link… )
Ok, it’s not a big deal if light flickers, but bigger problem can be any complex electronic device - such surge can destroy some devices…

They do. I have it for watering system, so I am not really crazy about it. For the time it opens, water doesn’t even exit sprinkler

1 Like

Thanks for your help. Much appreciated.
I have finally received the board from China. it has a ESP 12F chip.
There is no usb port for flashing it from ESPHome.
How am I supposed to flash it?
Use a serial to USB cable and connect the serial wires to the pins?
If so to which pins from the db9 serial cable?

So when I said this:

It meant that it has to be programmed with a serial adaptor. These are quite cheap. Search for “USB to 3.3V serial uart adaptor”.

Something like this: https://www.aliexpress.com/item/1005004947119178.html

That one has a fancy case and can be switched between 3.3v and 5v. There are cheaper simpler versions.

Connect:
Tx → Rx
Rx → Tx
GND → GND
Vcc → 3.3V

Thanks.
I will have to order one.
I am quite keen to flash this today though.
Any reason I cannot flash it with a USB to DB9 serial cable and then the serial cable pins I connect to the board. And also supply 5v.

@Robufz the adaptor mentioned above does the required conversion on the adaptor chip. This is not just a cable. No shortcuts. I had to buy one to flash sonofff relays. Works well for me.

1 Like

That outputs RS232 voltages, up to +/- 15 V! Do not connect it.

Ordered from Aliexpress. Thanks

For others doing a similar thing, I used a similar board as part of my workshop install:

This one is useful as it has a built in 230v PSU, so doesn’t need an external power supply when installed as I’ve done it. Not sure if there’s a version which supports more relays. As mentioned above, you need a USB/TTL adapter to flash whatever you get. I used one of these which worked well. Once the first image is on it, you can update OTA and I’ve not touched mine with a USB lead since the first time it was flashed.

Outputs easily defined in ESPHome:

output:

  - platform: gpio
    pin: GPIO16
    id: 'front_security_light'
    
  - platform: gpio
    pin: GPIO14
    id: 'garage_patio_lights'
    
  - platform: gpio
    pin: GPIO12
    id: 'garage_heater_front'
    
  - platform: gpio
    pin: GPIO13
    id: 'garage_heater_rear'

…and mapped to switches, e.g.:

  - platform: output
    output: 'front_security_light'
    name: "Front Security Light"
    on_turn_on:
    - logger.log: "Security Light turned on"
    on_turn_off:
    - logger.log: "Security Light turned off"

Note: I don’t consider the isolation barriers particularly good on this design, but as I’m using it to switch 230v anyway, there’s not a lot that can go wrong. Also be wary of the relay ratings - they claim 10A, but I wouldn’t want to run more than a few hundred mA through them. In my case, they are switching heaters, lights and the garage door motor, but all of the actual current is run through the DIN contactors (which are proper kit, not sourced from banggood!) at the LHS of the consumer unit board shown above. The relays on the board only have to switch these contactors, so the risk of overload is negligible.

2 Likes

If you want to use this board, then follow the suggestion by @tom_l and trace which GPIO pin on the ESP is connected to which relay. You have all the pins you need to flash the board, but you must use a UART adapter.

The ESP is a 3.3V device but this board has a 3.3V regulator and provides for a 5V input. Make sure your UART adapter is 5V, but don’t ever use it on a bare ESP module. Some FTDI chips were not recognized by Windows, so I recommend an adapter that has the CP2102 chip. Just Google “5V UART Adapter CP2102”. If you don’t already have them, you’ll need an assortment of DuPont wires.

I have finally got my hands on the usb to tty.
Just cannot get it to flash.
Problem is I am not sure of the connections. I have tried so many different variations. And also pressing the reset button. The PC recognises the usb ttl as com4 serial. But always fails to flash. I am using Esp web tools to flash.

That looks ok to me.

The switch on the side of your dongle is at 5V :white_check_mark:
RXD connects to TXD :white_check_mark:
TXD connects to RXD :white_check_mark:
5V connects to 5V :white_check_mark:
GND connects to GND :white_check_mark:
IO0 connects to GND :question:

Power off then on, then remove the IO0 → GND connection. See if you can connect.

There are other connections required for bootload mode. Make sure they are connected on the PCB, particularly CH_PD and GPIO15, like this:

https://buger.dread.cz/flash-nodemcu-firmware-into-esp-12-f.html

Yes switch is on 5v
yes rxd to txd
yes txd to rxd
yes 5v to 5v
yes gnd to gnd

I put a jumper between IO0 and GND as I saw it in this video.

In the video the guy does not press the reset button or remover the jumper. But I have tried with and without jumper and with and without reset button.
If I power on the board without the jumper it goes a bit crazy and all of the relay boards come on and off in sequence!

There are no other places I can connect like in the link you sent me.
What else can I try?
When I try to flash I get the error: Failed to download manifest