ESPhome compilation error 74HC595

I have a problem compiling a piece of code that I copied right off the 74HC595 documentation page:

esphome:
  name: esphome-web-2fe91c
  friendly_name: ESP32WROOM-Licht14

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "b2gHYVp8V4sUOscpEdJzw718DFLBy34Z5kP5nRrz1j0="

ota:


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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-2Fe91C"
    password: "SfqTpbv5GbM6"

captive_portal:

sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: D5 #naar SER
    clock_pin: D8 #naar SRCLK
    latch_pin: D7 #
    oe_pin: D6
    sr_count: 1

switch:
  - platform: gpio
    name: "OUT 04"
    id: OUT04
    pin: 
      sn74hc595: sn74hc595_hub
      number: 3
      inverted: false

In the editor the first section is already marked with the red waves for errors and when compliling I got the following error:

INFO ESPHome 2023.11.6
INFO Reading configuration /config/esphome/esphome-web-2fe91c.yaml...
Failed config

sn74hc595: [source /config/esphome/esphome-web-2fe91c.yaml:33]
  
  Either "data_pin" and "clock_pin" must be set or "spi_id" must be set.
  - id: sn74hc595_hub
    data_pin: D5
    clock_pin: D8
    latch_pin: D7
    oe_pin: D6
    sr_count: 1

Any clue what I’m doing wrong?

Additional question:
Can 75HC595 be used as imput, e.g. for binary sensors?

Thanks for any help

The problem lies in that you’re using an ESP32 and the example at ESPHome.io is using an ESP8266 - as you can see by it’s using D5, D6, D7 and D8 pins.

I don’t know what pins you want to use but changing the pins to something like:

sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: 16
    clock_pin: 17
    latch_pin: 18
    oe_pin: 19
    sr_count: 1

Doesn’t give any errors.

PS. You can see more about which pins to use here:

and yes, you should be able to use the output of the SN74HC595 as input for a GPIO Binary Sensor.

1 Like