makstech / esphome-es32a08-expansion-board-example

Example of how to integrate ESPHome with ES32A08 ESP32 8 CH Analog Relay Expansion Board
MIT License
1 stars 1 forks source link

Have you been able to figure out a good way to implement the 7 segment displays? #1

Open zacheryrodgers opened 1 month ago

zacheryrodgers commented 1 month ago

I have been struggling to figure out an elegant and simple way to make use of the display on this expansion board, but to no avail.

Feel free to use this as an example base yaml config in this repo

substitutions:
  device_name: es32a08
  device_board: esp32dev
  device_friendly_name: "ESP32A08 PLC Expansion an Relay Board"

esphome:
  name: ${device_name}
  friendly_name: ${device_friendly_name}

esp32:
  board: ${device_board}
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
ap:

web_server:

captive_portal:

sn74hc595:
  - id: 'output_hub'
    data_pin: GPIO13
    clock_pin: GPIO27
    latch_pin: GPIO14
    oe_pin: GPIO4
    sr_count: 3

sn74hc165:
  - id: 'input_hub'
    data_pin: GPIO5
    clock_pin: GPIO17
    load_pin: GPIO16

# Onboard Status LED
light: 
  - platform: status_led
    id: board_led
    name: "Board LED"
    pin: GPIO15
    internal: false

# 4 buttons located on board under display
binary_sensor:
  - platform: gpio
    id: key_1
    name: "Key 1"
    internal: false
    pin: 
      number: GPIO18
      inverted: true
      mode:
        input: true
        pullup: true
  - platform: gpio
    id: key_2
    name: "Key 2"
    internal: false
    pin: 
      number: GPIO19
      inverted: true
      mode:
        input: true
        pullup: true
  - platform: gpio
    id: key_3
    name: "Key 3"
    internal: False
    pin: 
      number: GPIO21
      inverted: true
      mode:
        input: true
        pullup: true
  - platform: gpio
    id: key_4
    name: "Key 4"
    internal: False
    pin: 
      number: GPIO23
      inverted: true
      mode:
        input: true
        pullup: true

# 8 Optoisolated Inputs via sn74hc165 
  - platform: gpio
    id: input_1
    name: "Input 1"
    pin: 
      sn74hc165: 'input_hub'
      number: 0
      inverted: true
  - platform: gpio
    id: input_2
    name: "Input 2"
    pin: 
      sn74hc165: 'input_hub'
      number: 1
      inverted: true
  - platform: gpio
    id: input_3
    name: "Input 3"
    pin: 
      sn74hc165: 'input_hub'
      number: 2
      inverted: true
  - platform: gpio
    id: input_4
    name: "Input 4"
    pin: 
      sn74hc165: 'input_hub'
      number: 3
      inverted: true
  - platform: gpio
    id: input_5
    name: "Input 5"
    pin: 
      sn74hc165: 'input_hub'
      number: 4
      inverted: true
  - platform: gpio
    id: input_6
    name: "Input 6"
    pin: 
      sn74hc165: 'input_hub'
      number: 5
      inverted: true
  - platform: gpio
    id: input_7
    name: "Input 7"
    pin: 
      sn74hc165: 'input_hub'
      number: 6
      inverted: true
  - platform: gpio
    id: input_8
    name: "Input 8"
    pin: 
      sn74hc165: 'input_hub'
      number: 7
      inverted: true

# Outputs via sn74hc595 - 8 Relays
switch:
  - platform: gpio
    id: relay_1
    name: "Relay 1"
    pin:
      sn74hc595: 'output_hub'
      number: 16
  - platform: gpio
    id: relay_2
    name: "Relay 2"
    pin:
      sn74hc595: 'output_hub'
      number: 17
  - platform: gpio
    id: relay_3
    name: "Relay 3"
    pin:
      sn74hc595: 'output_hub'
      number: 18
  - platform: gpio
    id: relay_4
    name: "Relay 4"
    pin:
      sn74hc595: 'output_hub'
      number: 19      
  - platform: gpio
    id: relay_5
    name: "Relay 5"
    pin:
      sn74hc595: 'output_hub'
      number: 20    
  - platform: gpio
    id: relay_6
    name: "Relay 6"
    pin:
      sn74hc595: 'output_hub'
      number: 21
  - platform: gpio
    id: relay_7
    name: "Relay 7"
    pin:
      sn74hc595: 'output_hub'
      number: 22
  - platform: gpio
    id: relay_8
    name: "Relay 8"
    pin:
      sn74hc595: 'output_hub'
      number: 23
makstech commented 1 month ago

Thanks! Yes, this far I have figured out, had pretty much an identical config myself.

And with seg display, also not really great progress. Using native ESPHome yaml-based config just doesn't cut it, as there is too much overhead with all the publishing and state updates. Because each letter needs to be updated multiple times a second to have 4 separate characters. This means a few hundred "switch" operations per second. Most likely, the only solution is a custom C++ component, which may or may not be a very complicated thing, but I didn't go down that rabbit hole yet.

zacheryrodgers commented 1 month ago

Aw man was hoping you had something cooked up for it. Its a shame that the manufacturer implemented the display this way rather than using one with an I2C interface or similar. I am debating just gluing a supported OLED display on top of the 7seg and and considering it an upgrade 🤣