daweizhangau / esphome_addressable_light_digital_display

MIT License
32 stars 1 forks source link

ESPHome Component: Addressable Light Digital Display

drawing drawing drawing

This component enables ESPHome to drive an eight-segment display made from FastLED strip with simple configuration.

Comparing to LED matrix and traditional 7-segment display, this display has unique advantages.

It's an ESPHome-based general digital display, it can be used for different purposes. For example, it can display date, time, room temperature, noise level etc. Data can also be pulled from Home Assistant.

This project is inspired by the following DIY solutions.

DIY advices

Preparation

To build a similar digital display, you need the following components:

Design

The display below uses 30 LEDs (WS2812B) and one NodeMCU ESP32, which can be powered directly via USB 5V 2A power adapter. (5V 1A power is not enough for maximum brightness.)

For each digit to display, LED sequence doesn't matter, because you can configure it later, but it's better to keep the sequence consistent across all digits.

Besides 7-segment symbols, you can also add special symbols to the display. Currently period . and colon : are supported.

drawing

In this case, for each digit, LEDs are connected in the sequence of BAFEDCG. The green and blue wires are for data, starting from right to left.

      A
     ---
  F |   | B
     -G-
  E |   | C
     ---
      D

Wiring

Connect the LED in serial way, starting from RIGHT to LEFT of the display. There should be only 3 to 4 wires, 2 of which connect to power supply. Connect the rest to microcontroller. GND is shared by both power supply and microcontroller.

Configuration

Examples

Import display component

Read more about external components here.

external_components:
  - source:
      type: git
      url: https://github.com/daweizhangau/esphome_addressable_light_digital_display
      ref: main
    refresh: 0s

Light component

id is required for display component to reference. Make sure correct chipset, pin, num_leds and rgb_order is set. This light doesn't need to expose to Home Assistant, so internal: true.

light:
  - platform: fastled_clockless
    internal: true
    id: internal_light_state
    chipset: WS2812B
    pin: GPIO33
    num_leds: 90
    rgb_order: GRB

Display component

The display component is exposed as a light to Home Assistant, but it references the FastLED light.

display:
  - platform: addressable_light_digital_display
    id: digital_clock
    light_id: digital_display_light
    name: Digital Clock
    addressable_light_id: internal_light_state
    icon: "mdi:clock-digital"
    restore_mode: ALWAYS_ON
    default_transition_length: 0s
    led_map: ". CCCDDDEEEFFFAAABBBGGG . CCCDDDEEEFFFAAABBBGGG :: . CCCDDDEEEFFFAAABBBGGG . CCCDDDEEEFFFAAABBBGGG"
    reverse: true
    update_interval: 500ms
    lambda: |-
      if (millis() % 1000 < 500)
        it.strftime("%H:%M", sntp_time->now());
      else
        it.strftime("%H %M", sntp_time->now());