SN74HC595 I/O Expander (shift register)

The SN74HC595 component allows you to use SN74HC595 shift registers as I/O expanders (datasheet, SparkFun) in ESPHome. It uses 3 wires (optionally 4) for communication.

Once configured, you can use any of the 8 pins for your projects. Up-to 4 shift registers can be daisy-chained to provide more pins, without using more GPIO pins on the controller.

Use of the OE pin is optional. If used, the pin should be pulled up externally.

../_images/sn74hc595-full.jpg

SN74HC595 I/O Expander (shift register).

# Example configuration entry
sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: D5
    clock_pin: D8
    latch_pin: D7
    oe_pin: D6
    sr_count: 2

# Individual outputs
switch:
  - platform: gpio
    name: "SN74HC595 Pin #0"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 0
      number: 0
      inverted: False

Configuration variables:

  • id (Required, ID): The id to use for this SN74HC595 component.

  • data_pin (Required, Pin Schema): Pin connected to SN74HC595 SER input.

  • clock_pin (Required, Pin Schema): Pin connected to SN74HC595 SRCLK pin

  • latch_pin (Required, Pin Schema): Pin connected to SN74HC595 RCLK pin

  • oe_pin (Optional, Pin Schema): Pin connected to SN74HC595 OE pin

  • sr_count (Optional, int): Number of daisy-chained shift registers, up-to 4. Defaults to 1.

See Also