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.
To build a similar digital display, you need the following components:
WS2812B
. Bigger display may draw higher power, choose higher votage model can reduce current requirement. 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.
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
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.
ref
: can either be a branch name (such as main
) or a tag name (such as v0.1.0
)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
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
The display component is exposed as a light to Home Assistant, but it references the FastLED light.
platform
: must be addressable_light_digital_display
id
: ID of the displaylight_id
: ID of the display lightname
: (Optional) Readable name of the displayicon
: (Optional) MDI icon IDaddressable_light_id
: FastLED light ID defined aboverestore_mode
: (Optional) Recommended to set it to ALWAYS_ON
otherwise, you need to turn it on in Home Assistant before it can display anything.default_transition_length
: (Optional) Recommended to set it to 0s
.led_map
: A string that maps LED to the 7 segments (shown below) and special symbols. From left to right, the map string starts from the first LED to the last LED. Each character in this string map to a LED, space is used as a delimiter. A
to G
is used to map a LED to corresponding segment of 7-segment, .
and :
are used to map corresponding symbols. These characters can be repeated. For example, if 3 LEDs are used to represent Segment B and 3 are used for Segment A, then map string is BBBAAA
.reverse
: (Optional) Content order. If true, the first led maps to right most character of content string, otherwise, the first LED maps the left most character. True, by default.lambda
: C++ code to formulate display content.
For more information about print API, please read printable.h.
For more information about suported characters, please read ascii_to_raw.h
To print time, time
component is required.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());