Skip to content

Instantly share code, notes, and snippets.

@b2un0
Created November 13, 2025 10:26
Show Gist options
  • Select an option

  • Save b2un0/7f50989b0a22a626935492107be3c4b4 to your computer and use it in GitHub Desktop.

Select an option

Save b2un0/7f50989b0a22a626935492107be3c4b4 to your computer and use it in GitHub Desktop.
ESP8266 WIFI-Clock LED Matrix ESP21E
substitutions:
name: esp-matrix-02
friendly_name: ESP-Matrix-02
comment: "Matrix Display Wohnzimmer [ESP12-E] [WIFI]"
scl_pin: GPIO4
sda_pin: GPIO5
clk_pin: GPIO14
mosi_pin: GPIO13
cs_pin: GPIO15
status_led_pin: GPIO2
download_button_pin: GPIO0
rotation_pin: GPIO16
ha_sensor_data: sensor.energymeter_sml_power_curr
esphome:
name: $name
comment: "$comment"
esp8266:
board: esp12e
packages:
default_all: !include includes/default_all.yaml
default_wifi: !include includes/default_wifi.yaml
captive_portal:
logger:
level: ERROR
font:
- file: fonts/MatrixLight8X.ttf
id: message_font
size: 8
glyphs: "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz"
sensor:
- platform: homeassistant
id: ha_sensor_data
entity_id: "${ha_sensor_data}"
text_sensor:
- platform: homeassistant
id: sensor_1_unit
entity_id: "${ha_sensor_data}"
attribute: unit_of_measurement
output:
- platform: esp8266_pwm
id: statusled
pin:
number: $status_led_pin
inverted: true
light:
- platform: monochromatic
id: led1
name: "Status LED"
output: statusled
internal: true
i2c:
sda: $sda_pin
scl: $scl_pin
scan: true
id: i2cbus
spi:
clk_pin: $clk_pin
mosi_pin: $mosi_pin
display:
- platform: max7219digit
id: matrix
cs_pin: $cs_pin
num_chips: 4
update_interval: 1s
lambda: |-
it.intensity(id(brightness_level));
if (id(rotation_mode).state == true) {
id(matrix)->set_reverse(0);
id(matrix)->set_chip_orientation(2);
} else {
id(matrix)->set_reverse(1);
id(matrix)->set_chip_orientation(0);
}
if (!id(ha_sensor_data).has_state()) {
it.print(it.get_width() / 2, 0, id(message_font), TextAlign::TOP_CENTER, "loading");
} else {
char buffer[20];
snprintf(buffer, sizeof(buffer), "%.0f %s", id(ha_sensor_data).state, id(sensor_1_unit).state.c_str());
it.printf(it.get_width() / 2, 0, id(message_font), TextAlign::TOP_CENTER, "%s", buffer);
}
globals:
- id: brightness_level
type: int
restore_value: true
initial_value: '1'
number:
- platform: template
name: "Brightness"
id: brightness_select
restore_value: true
optimistic: true
step: 1
min_value: 0
max_value: 15
initial_value: 1
mode: slider
set_action:
then:
lambda: |-
id(brightness_level) = x;
ESP_LOGD("main", "Brightness: %d", id(brightness_level));
binary_sensor:
- platform: gpio
pin:
number: $rotation_pin
inverted: true
name: "Rotation Mode"
id: rotation_mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment