Has anyone used Dingtian 8ch Ethernet Relay?

anymore information? Does this flash the current software on them? how do I install this?

Thanks in advance

I have 4 Dingtian relays (8 and 4 channels) working with Home Assistant with MQTT. Everything works fine, but I have a minor issue with the digital inputs:

When a relay loses network connection it triggers an OFF command on reconnection. I use the digital inputs to trigger automations (i.e. I don’t use the relay’s direct trigger of the relay) so on reconnection the automation is triggered. (Not sure if the relay considers network connection loss as a restart. My relay has the power failure recovery activated and defaulting to OFF)

Does anyone know how to avoid this? I am guessing the “IP WatchDog” in the relay UI could address it, but I don’t really understand the settings. Has anybody experimented with these settings? (BTW, I have NOT enabled the “IP WatchDog” on my relays)

have you tried to contact Stephen from Dingtian about this issue?

Will try. Thank you

I have one of the dingtian relay boards, and I asked them to ship it with dev firmware. Then, I was able to flash esphome, which I use to control it instead of mqtt.

Yeah, I you have the dev firmware you can flash esphome over it.

can you share it? or isn’t that possible?

Due to the way the IO expanders are wired & esphome’s implementation, you can only set up input OR output :confused:

substitutions:
  device_name: radiant_controller

esphome:
  name: radiant_controller
  friendly_name: Radiant Controller
  on_boot:
    then:
      pcf85063.read_time: # read RTC time once the system boots

esp32:
  board: esp32dev

api:

ota:

# see https://github.com/dtlzp/relay_dev_demo

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0

ethernet:
  type: JL1101
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  power_pin: GPIO12
  clk_mode: GPIO17_OUT
  phy_addr: 0

uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  stop_bits: 1

modbus:
  flow_control_pin: GPIO33
  id: modbus1

modbus_controller:
  id: modbus_ctl
  address: 0x1
  modbus_id: modbus1
  setup_priority: -10

i2c:
  scl: GPIO32
  sda: GPIO16
  scan: true
  id: i2c_bus

sn74hc595:
  - id: sn74hc595_hub
    data_pin: GPIO13 #SER
    clock_pin: GPIO14 #SRCLK
    latch_pin: GPIO15 #RCLK
    oe_pin: GPIO0
    sr_count: 2

#sn74hc165:
#  - id: sn74hc165_hub
#    clock_pin: GPIO14
#    data_pin: GPIO35
#    load_pin: GPIO0
#    clock_inhibit_pin: GPIO15
#    sr_count: 2

time:
  - platform: pcf85063
    update_interval: never # internal clock is fine for general use
  - platform: homeassistant
    on_time_sync:
      then:
        pcf85063.write_time: # sync RTC to HA when available


switch:
  - platform: gpio
    name: Factory LED
    pin:
      number: GPIO2
  - platform: gpio
    name: Relay 16 control
    id: relay16ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 0
      inverted: false
  - platform: gpio
    name: Relay 15 control
    id: relay15ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 1
      inverted: false
  - platform: gpio
    name: Relay 14 control
    id: relay14ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 2
      inverted: false
  - platform: gpio
    name: Relay 13 control
    id: relay13ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 3
      inverted: false
  - platform: gpio
    name: Relay 12 control
    id: relay12ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 4
      inverted: false
  - platform: gpio
    name: Relay 11 control
    id: relay11ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 5
      inverted: false
  - platform: gpio
    name: Relay 10 control
    id: relay10ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 6
      inverted: false
  - platform: gpio
    name: Relay 9 control
    id: relay9ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 7
      inverted: false
  - platform: gpio
    name: Relay 8 control
    id: relay8ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 8
      inverted: false
  - platform: gpio
    name: Relay 7 control
    id: relay7ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 9
      inverted: false
  - platform: gpio
    name: Relay 6 control
    id: relay6ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 10
      inverted: false
  - platform: gpio
    name: Relay 5 control
    id: relay5ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 11
      inverted: false
  - platform: gpio
    name: Relay 4 control
    id: relay4ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 12
      inverted: false
  - platform: gpio
    name: Relay 3 control
    id: relay3ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 13
      inverted: false
  - platform: gpio
    name: Relay 2 control
    id: relay2ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 14
      inverted: false
  - platform: gpio
    name: Relay 1 control
    id: relay1ctl
    pin:
      sn74hc595: sn74hc595_hub
      number: 15
      inverted: false

output:
  - platform: sigma_delta_output
    update_interval: 30s
    id: heater_room1
    turn_on_action:
      # TODO here we need to check that the floor isn't overheating
      # really should register intention in a template
      - switch.turn_on: relay1ctl
    turn_off_action:
      - switch.turn_off: relay1ctl

climate:
  platform: pid
  name: PID Climate Controller
  sensor: temp_room1
  default_target_temperature: 21
  heat_output: heater_room1
  control_parameters:
    kp: 0
    ki: 0
    kd: 0
    output_averaging_samples: 5
    derivative_averaging_samples: 5
  deadband_parameters:
    threshold_high: 0.5
    threshold_low: -0.5

binary_sensor:
  - platform: gpio
    name: Factory Button
    pin:
      number: GPIO34
      inverted: true
# - platform: gpio
#   name: input8
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 0
#     inverted: true
# - platform: gpio
#   name: input7
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 1
#     inverted: true
# - platform: gpio
#   name: input6
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 2
#     inverted: true
# - platform: gpio
#   name: input5
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 3
#     inverted: true
# - platform: gpio
#   name: input4
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 4
#     inverted: true
# - platform: gpio
#   name: input3
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 5
#     inverted: true
# - platform: gpio
#   name: input2
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 6
#     inverted: true
# - platform: gpio
#   name: input1
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 7
#     inverted: true
# - platform: gpio
#   name: input16
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 8
#     inverted: true
# - platform: gpio
#   name: input15
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 9
#     inverted: true
# - platform: gpio
#   name: input14
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 10
#     inverted: true
# - platform: gpio
#   name: input13
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 11
#     inverted: true
# - platform: gpio
#   name: input12
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 12
#     inverted: true
# - platform: gpio
#   name: input11
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 13
#     inverted: true
# - platform: gpio
#   name: input10
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 14
#     inverted: true
# - platform: gpio
#   name: input9
#   pin:
#     sn74hc165: sn74hc165_hub
#     number: 15
#     inverted: true

Hi,
Does anyone have the 4CH esphome config file? It doesn’t have any SN74HC ships.
I’ve used this with MQTT and Home Assistant but relay reset on connection reset and some other things make it unreliable, I did even have a problem where MQTT show relay is ON but it’s actually OFF!

Can you advise how you flashed it?
Via gui or do we need something else?
Thank you

I connected an esp programmer to the header on the board. They’re GitHub repo documents which pins are which on the header.

You can not flash it unless you have the dev version, the normal version have some sort of bootloader lock and even if you flash it, it won’t boot.
I’m trying to disolder the ESP32 chip and solder an other one!

You can find indpeth discussion here: Dingtian IOT Relay - Let's Control It

I’ve flashed 4CH version with ESPhome and it works! I had to flash it to a ESP32-WROM-32 chip (not even 32D like on original board) then removed 32D the board come with and soldered this one, i had some problems and was thinking it’s because i suck at soldering but turnout i had to remove i2c/clock config because this chip doesn’t have it.
This is the 4CH file, if anyone interested in:

substitutions:
  device_name: dtrelay
  upper_devicename: "DT 4CH Relay"

esphome:
  name: $device_name
  friendly_name: $upper_devicename
  # For debugging only
  # on_boot:
  #   then:
  #     switch.turn_on: relay1ctl 

status_led:
  pin:
    number: GPIO15 # red led, better to use it for status than reset
    # inverted: true #off when ok, but I'd rather keep it on if ok

esp32:
  board: esp32dev

api:
ota:
captive_portal:

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

  ap:
    ssid: "$upper_devicename Hotspot"
    password: !secret wifi_hotspot_password
    ap_timeout: 3min

# Enable logging
logger:
  level: DEBUG
  # baud_rate: 0

# ethernet:
#   type: JL1101
#   mdc_pin: GPIO23
#   mdio_pin: GPIO18
#   power_pin: GPIO0
#   clk_mode: GPIO17_OUT
#   phy_addr: 0

# uart:
#   tx_pin: GPIO1
#   rx_pin: GPIO3
#   baud_rate: 9600
#   stop_bits: 1

# modbus:
#   flow_control_pin: GPIO13
#   id: modbus1

# modbus_controller:
#   id: modbus_ctl
#   address: 0x1
#   modbus_id: modbus1
#   setup_priority: -10

# web_server:
#   port: 80

switch:
  - platform: gpio
    name: Relay 1 control
    id: relay1ctl
    pin: GPIO16
    inverted: false
  - platform: gpio
    name: Relay 2 control
    id: relay2ctl
    pin: GPIO2
    inverted: false
  - platform: gpio
    name: Relay 3 control
    id: relay3ctl
    pin: GPIO32
    inverted: false
  - platform: gpio
    name: Relay 4 control
    id: relay4ctl
    pin: GPIO12
    inverted: false

binary_sensor:
  - platform: gpio
    name: Factory Button
    pin:
      number: GPIO34
      inverted: true

  - platform: gpio
    name: Input 4
    pin:
      number: GPIO35
      inverted: true

  - platform: gpio
    name: Input 3
    pin:
      number: GPIO33
      inverted: true

  - platform: gpio
    name: Input 2
    pin:
      number: GPIO39
      inverted: true

  - platform: gpio
    name: Input 1
    pin:
      number: GPIO36
      inverted: true

Apologies if asking the obvious. But by esp programmer you mean a usb to ttl adapter like the one used to flash a sonoff or similar.?
Thank you

Yes, a usb to ttl (really, 3.3V) adapter.

Thank you very much

I also want to use a Dingtian 4ch card with Esphome. It seems to me that there is also an unlocked version since I’m not skilled with welding.
Have you tried to make the ethernet port and modbus work with Esphome?
Thank you

I did confirm with them they can send you an unlocked version, you just have to ask when making the order (they call it dev board and they are responsive on Aliexpress DMs)
Ethernet works but you have to select between using wifi or eth can’t use them both. I did try to make modbus work by reading values from a Solar Inverter but without success, I don’t have a reliable manual for the solar inverter so not sure if it’s the code/config or the actual onboard modubs converter problem.
Overall esphome is really stable on this hardware even with mqtt only

When you order, you must ask them for the debug/development version. I have the ethernet port and modbus working with ESPHome.

One problem is that you will only be able to the inputs OR the outputs–you can’t use both, unless you write new ESPHome drivers for the chips. The way they share I/O lines requires a combined driver for the inputs and outputs, and ESPHome has a separate driver for each chip.

I considered this module, but for the price it’s just not worth the faffing around.

The kincony.com module is a bit more expensive, but it’s easily programmable with tasmota or esphome and inputs outputs work.

https://a.aliexpress.com/_mP2NTr8

4CH version don’t need any driver or IO extender, is this problem unique to the other variants like 8+ channels?