7 segment clock by random1101 for ESPHome

7 segment clock by random1101 for ESPHome

thingiverse

This is the electronics remix for the [7 segment clock made by random1101](https://www.thingiverse.com/thing:3437127). It uses the ESP-01s for everything. Once it connected to the Home Assistant it may be controlled over the entity card. It supports separate color, brightness and on/off for hours, minutes and colon parts of the clock. Current time is synchronized with SNTP servers. Note: if you prefer to use static IP it's important to configure at least 1 DNS server in a WIFI section of the config (in my case I use the IP of my router). _WARNING_ There're 2 modifications of ESP-01: one has 1MB of flash memory and one with only 512kb. The firmware compiled from this configuration takes about 36kb of RAM and 404.5kb of Flash memory. If you have a 512kb there will be no room for the firmware for OTA updates. Electronics BOM: 1) ESP-01s 2) 5v to 3.3v downshifter to power ESP-01s [like this](https://aliexpress.ru/item/32555282571.html?spm=a2g0s.9042311.0.0.46f933edNvOZb6&_ga=2.179512935.236757223.1608283098-301929085.1605773963&sku_id=58848067671) 3) Any 5v wall plug power supply with about 1 amp of current PS, I'm still a noob in electronics. Please feel free in pointing me if there's any mistake in wiring schematics. Thanks PPS: Note that in a newer versions of ESPHome the ESPColor class was replaced with Color class. Thank's @Pulsaro for pointing on this. ---- ##ESPHome configuration ```yaml substitutions: device_name: led_clock esphome: name: $device_name platform: ESP8266 board: esp01_1m on_boot: - light.turn_on: id: led_strip brightness: 100% red: 0 green: 0 blue: 0 effect: "${device_name} Time effect" wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "${device_name} Fallback Hotspot" password: !secret wifi_fallback_api_password logger: level: DEBUG # Enable Home Assistant API api: password: !secret hassio_api_password ota: password: !secret ota_password globals: - id: hours_red_value type: int restore_value: yes initial_value: '0' - id: hours_green_value type: int restore_value: yes initial_value: '0' - id: hours_blue_value type: int restore_value: yes initial_value: '0' - id: minutes_red_value type: int restore_value: yes initial_value: '0' - id: minutes_green_value type: int restore_value: yes initial_value: '0' - id: minutes_blue_value type: int restore_value: yes initial_value: '0' - id: dots_red_value type: int restore_value: yes initial_value: '0' - id: dots_green_value type: int restore_value: yes initial_value: '0' - id: dots_blue_value type: int restore_value: yes initial_value: '0' output: #======== Hours ============ - platform: template id: hours_red_output type: float write_action: lambda: |- id(hours_red_value) = 255.0 * state; - platform: template id: hours_green_output type: float write_action: - lambda: |- id(hours_green_value) = 255.0 * state; - platform: template id: hours_blue_output type: float write_action: lambda: |- id(hours_blue_value) = 255.0 * state; #========= Minutes =========== - platform: template id: minutes_red_output type: float write_action: lambda: |- id(minutes_red_value) = 255.0 * state; - platform: template id: minutes_green_output type: float write_action: lambda: |- id(minutes_green_value) = 255.0 * state; - platform: template id: minutes_blue_output type: float write_action: lambda: |- id(minutes_blue_value) = 255.0 * state; #========= dots =========== - platform: template id: dots_red_output type: float write_action: lambda: |- id(dots_red_value) = 255.0 * state; - platform: template id: dots_green_output type: float write_action: lambda: |- id(dots_green_value) = 255.0 * state; - platform: template id: dots_blue_output type: float write_action: lambda: |- id(dots_blue_value) = 255.0 * state; time: - platform: sntp id: sntp_time timezone: "Europe/Moscow" servers: - 0.pool.ntp.org - 1.pool.ntp.org - 2.pool.ntp.org light: - platform: rgb name: "${device_name} hours lights" id: 'hours_lights' red: hours_red_output green: hours_green_output blue: hours_blue_output - platform: rgb name: "${device_name} minutes lights" id: 'minutes_lights' red: minutes_red_output green: minutes_green_output blue: minutes_blue_output - platform: rgb name: "${device_name} dots lights" id: 'dots_lights' red: dots_red_output green: dots_green_output blue: dots_blue_output #--------- LED strip ---------------- - platform: fastled_clockless id: led_strip name: "Led strip" internal: True pin: GPIO3 num_leds: 30 chipset: WS2812B rgb_order: GRB effects: - addressable_lambda: name: "${device_name} Time effect" update_interval: 200ms lambda: |- const int ledsInDigitCount = 7; const int digitsCount = 4; int digitsLeds[10][ledsInDigitCount] = { {1,1,0,1,1,1,1}, {0,0,0,1,0,0,1}, {1,1,1,1,1,0,0}, {1,0,1,1,1,0,1}, {0,0,1,1,0,1,1}, {1,0,1,0,1,1,1}, {1,1,1,0,1,1,1}, {0,0,0,1,1,0,1}, {1,1,1,1,1,1,1}, {1,0,1,1,1,1,1} }; int ledOffsets[digitsCount] = {23 , 16, 7, 0}; auto time = id(sntp_time).now(); int colors[4][3] = { {id(hours_red_value), id(hours_green_value), id(hours_blue_value)}, {id(hours_red_value), id(hours_green_value), id(hours_blue_value)}, {id(minutes_red_value), id(minutes_green_value), id(minutes_blue_value)}, {id(minutes_red_value), id(minutes_green_value), id(minutes_blue_value)} }; int values[digitsCount] = {}; values[0] = time.hour / 10; values[1] = time.hour % 10; values[2] = time.minute / 10; values[3] = time.minute % 10; it.all() = Color(0,0,0); if ((time.second % 2) > 0) { it[14] = Color(id(dots_red_value), id(dots_green_value), id(dots_blue_value)); it[15] = Color(id(dots_red_value), id(dots_green_value), id(dots_blue_value)); } for (int valueI = 0; valueI < digitsCount; valueI++) { int ledsOffset = ledOffsets[valueI]; int timeValue = values[valueI]; int *color = colors[valueI]; int *leds = digitsLeds[timeValue]; for (int ledI = 0; ledI < ledsInDigitCount; ledI++) { if(leds[ledI] > 0) { int ledIndex = ledI + ledsOffset; it[ledIndex] = Color(color[0], color[1], color[2]); } } } ```

Download Model from thingiverse

With this file you will be able to print 7 segment clock by random1101 for ESPHome with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on 7 segment clock by random1101 for ESPHome.