Can not control 4ch relay with esphome

I purchased this wifi board from Amazon.

I was able to flash creating the bin file from esphome in HA and the esphome-flasher tool on my mac. I have used esp8266/esp01_01m and esp8266/esp8285. The generic firmware loads and the board boots up onto my network and I can view the log from esphome/HA.

I have tried the configurations posted online as well as that of another brand 4ch/wifi board I orderred a a few months ago that works fine. For some reason these configs don’t work. I can turn on the blue light, the buttons on the board switch the relays, but I cant turn them on/or from HA.

Here is the current config in hopes of some help:

esphome:
  name: test-8285

esp8266:
  board: esp8285

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "REDACTED"

wifi:
  ssid: "REDACTED"
  password: “REDACTED”

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test-8285 Fallback Hotspot"
    password: “REDACTED”

captive_portal:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff 4CH Button 1"
  - platform: gpio
    pin:
      number: GPIO9
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff 4CH Button 2"
  - platform: gpio
    pin:
      number: GPIO10
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff 4CH Button 3"
  - platform: gpio
    pin:
      number: GPIO14
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff 4CH Button 4"
  - platform: status
    name: "Sonoff 4CH Status"

switch:
  - platform: gpio
    name: "Sonoff 4CH Relay 1"
    pin: GPIO12
  - platform: gpio
    name: "Sonoff 4CH Relay 2"
    pin: GPIO5
  - platform: gpio
    name: "Sonoff 4CH Relay 3"
    pin: GPIO4
  - platform: gpio
    name: "Sonoff 4CH Relay 4"
    pin: GPIO15

Why binary sensors instead of gpio switches? It would also be an output signal.

And GPIO0 is not a good idea.
Choose another GPIO.

Honestly guys I am copying configs from what I can find online and trying to figure it out as I go.

This is my reference for this one:
Using With Sonoff 4CH — ESPHome. It claims gpio0 is correct for button one and it seems correct.

The sensors are for the onboard buttons and they react accordingly to the state of the button press on the board.

Its the switches that do not do anything.

If I press the button on the board the relay switches correctly and the sensor in HA reflects the change.

If I toggle the HA switch nothing happens yet the log for the device (viewed wirelessly through esphome) show the switch change.

Do I have the wrong gpio’s? If so how do I figure out the right ones?

I found a reference to another chinese board like this that switched via uarts. I tried that config as well to no avail.

Sorry.
I didn’t see that it was a board with an ESP on it. I thought it was a relay board connected to an ESP.

The documentation you are following is for an Sonoff relay board, the one you linked to on Amazon is not an Sonoff.

You probably need four more pins in the configuration.
The ones you have (luckily) was correct given that it was the configuration of a different board.
Perhaps you can follow the traces on the board, or guess with another four pins and see if something happens.

Unlike the sonoff this has a physical button to change the behavior of the relays. The binary sensors correspond to the leds on the sonoff not the action of the switch.

To control the relays the binaries are not necessary, I’d comment them out for now and focus on the switches. I would also try the pins that you have assigned to the binaries as switches. Typical relays, the led and relay are tied together and not independent like the sonoff.

The Sonoff also has a physical button to control the behavior of the relays. I have another similar Chinese board that worked with this config.

I have tried what I believe are all the GPIO’s and no response on the relays.

This one for some reason is not responding…perhaps it’s defective, yet it responds to the button presses.

Is the relays latching type?
That could mean you need a different configuration.

Have you tried the multimeter to see if the GPIOs become high when you flip the switches in HA?

The Amazon page says it’s Tuya-compatible. Perhaps get and try the tuya-convert script?

Looks very similar to this and it has the same relay GPIO pin assignments as you have used:

It has no GPIO pins for the buttons, only the relays

I have been avoiding Tasmota thinking it needs a windows machine, right?

I didn’t mean for you to use Tasmota, just that your pin assignments look right

Looking here (Although it is Homekit) they too are having trouble with that board:

Ok, makes sense. That board looks similar. I also saw complaints on another site I cant find at the moment.

I thinks its time to take advantage of amazons return policy and try another one.

Just an fyi you can use the esphome flasher to flash tasmota firmware to an esp.

2 Likes

Hi there,

i just bought the same units, can I ask how did you manage to flash them ?
I’ve flashed a lot of different devices, and I just tested my FTDI usb adapter AND cable by reflashing another sonoff device.
Now I’m pretty sure I’m wiring it up correctly (GVRT on the J6), booting while keeping the CH1 button pressed (and the Wifi blue light is not blinking when booting like that), still esphome-flasher can’t talk to the device
Unexpected error: ESP Chip Auto-Detection failed: Failed to connect to Espressif device: No serial data received.
Like it wasn’t in flash boot mode.
Am I missing something here ?

Cheers

I gave up and returned the board.