Need help configuring 8 Way Relay Module ESP-12F with sn74hc595

I have this product (or a clone of it) and I need help configuring the relays with esphome. I succeeded to upload esphome and I do not know how to move forward.

It appears that relays are connected using expanders and I don’t have enough knowledge to work with them. Any help/ guidance is much appreciated

I found the answer in this forum:

sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: GPIO14
    clock_pin: GPIO13
    latch_pin: GPIO12
    oe_pin: GPIO05
    sr_count: 1

switch:
  - platform: gpio
    name: "Relay 1"
    pin:
      sn74hc595: sn74hc595_hub
      number: 0
      inverted: false

  - platform: gpio
    name: "Relay 2"
    pin:
      sn74hc595: sn74hc595_hub
      number: 1
      inverted: false

  - platform: gpio
    name: "Relay 3"
    pin:
      sn74hc595: sn74hc595_hub
      number: 2
      inverted: false

  - platform: gpio
    name: "Relay 4"
    pin:
      sn74hc595: sn74hc595_hub
      number: 3
      inverted: false

  - platform: gpio
    name: "Relay 5"
    pin:
      sn74hc595: sn74hc595_hub
      number: 4
      inverted: false

  - platform: gpio
    name: "Relay 6"
    pin:
      sn74hc595: sn74hc595_hub
      number: 5
      inverted: false

  - platform: gpio
    name: "Relay 7"
    pin:
      sn74hc595: sn74hc595_hub
      number: 6
      inverted: false

  - platform: gpio
    name: "Relay 8"
    pin:
      sn74hc595: sn74hc595_hub
      number: 7
      inverted: false

I would suggest adding ‘id:’ to each relay. Makes further coding easier.

2 Likes