# System sensors sensor: # 1. Total SRAM memory usage - platform: template name: "SRAM Usage" id: sram_usage icon: mdi:memory unit_of_measurement: "KB" device_class: data_size state_class: measurement accuracy_decimals: 1 update_interval: 10s lambda: |- // Total SRAM size for ESP32-S3 = 512KB const size_t total_sram = 512 * 1024; size_t free_sram = heap_caps_get_free_size(MALLOC_CAP_INTERNAL); size_t used_sram = total_sram - free_sram; return used_sram / 1024.0; // Return used memory in KB on_value: then: - lvgl.bar.update: id: sram_memory_bar value: !lambda |- const size_t total_sram = 512 * 1024; // 512KB for ESP32-S3 size_t free_sram = heap_caps_get_free_size(MALLOC_CAP_INTERNAL); size_t used_sram = total_sram - free_sram; return (int)(((double)used_sram / total_sram) * 100); - lvgl.label.update: id: sram_memory_label text: !lambda |- const size_t total_sram = 512 * 1024; size_t free_sram = heap_caps_get_free_size(MALLOC_CAP_INTERNAL); size_t used_sram = total_sram - free_sram; static char sram_buf[32]; snprintf(sram_buf, sizeof(sram_buf), "%.1f/%.0f KB", used_sram/1024.0, total_sram/1024.0); return sram_buf; # 2. Total PSRAM memory usage - platform: template name: "PSRAM Usage" id: psram_usage icon: mdi:memory unit_of_measurement: "MB" device_class: data_size state_class: measurement accuracy_decimals: 1 update_interval: 10s lambda: |- // Total PSRAM size = 8MB const size_t total_psram = 8 * 1024 * 1024; size_t free_psram = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); // If PSRAM is not available, return 0 if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) { return 0.0; } size_t used_psram = total_psram - free_psram; return used_psram / (1024.0 * 1024.0); // Return used memory in MB on_value: then: - lvgl.bar.update: id: psram_memory_bar value: !lambda |- const size_t total_psram = 8 * 1024 * 1024; // 8MB size_t free_psram = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) return 0; size_t used_psram = total_psram - free_psram; return (int)(((double)used_psram / total_psram) * 100); - lvgl.label.update: id: psram_memory_label text: !lambda |- const size_t total_psram = 8 * 1024 * 1024; size_t free_psram = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); static char psram_buf[32]; if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) { snprintf(psram_buf, sizeof(psram_buf), "No PSRAM"); } else { size_t used_psram = total_psram - free_psram; snprintf(psram_buf, sizeof(psram_buf), "%.1f/%.0f MB", used_psram/(1024.0*1024.0), total_psram/(1024.0*1024.0)); } return psram_buf; # 3. Chip temperature - platform: internal_temperature name: "ESP32 Internal Temperature" id: esp32_temperature update_interval: 30s on_value: then: - lvgl.label.update: id: chip_temperature_label text: format: "%.1f°C" args: [id(esp32_temperature).state] # 4. WiFi Signal Strength in dBm - platform: wifi_signal name: "WiFi Signal" id: wifi_signal_db update_interval: 30s unit_of_measurement: "dBm" on_value: then: - lvgl.label.update: id: wifi_signal_label text: format: "%.0f dBm" args: [id(wifi_signal_db).state] # Text sensors for WiFi information text_sensor: # 5. IP address - platform: wifi_info ip_address: name: "IP Address" id: wifi_ip_address on_value: then: - lvgl.label.update: id: ip_address_label text: !lambda return id(wifi_ip_address).state.c_str(); # 6. MAC address - platform: wifi_info mac_address: name: "WiFi MAC" id: wifi_mac_address on_value: then: - lvgl.label.update: id: wifi_mac_label text: !lambda return id(wifi_mac_address).state.c_str(); # 7. ESPHome version with compilation date - platform: template name: "ESPHome Version" id: esphome_version lambda: |- return {ESPHOME_VERSION}; on_value: then: - lvgl.label.update: id: esphome_version_label text: !lambda 'return id(esphome_version).state;' # LVGL interface for displaying system information lvgl: pages: - id: system_info_page bg_color: color_slate_blue_gray widgets: - obj: id: system_info_container x: 20 y: 20 width: 440 height: 340 align: TOP_LEFT pad_all: 0 bg_color: color_steel_blue bg_opa: 20% border_opa: TRANSP radius: 10 widgets: # SRAM memory (show used from total) - obj: y: 10 width: 400 height: 50 align: TOP_MID bg_opa: TRANSP pad_all: 0 border_opa: TRANSP widgets: - label: align: TOP_LEFT text: "SRAM Used:" text_font: nunito_16 text_color: color_misty_blue - label: id: sram_memory_label align: TOP_RIGHT text: "0/512 KB" text_font: nunito_16 text_color: color_green - bar: id: sram_memory_bar y: 30 width: 390 height: 12 align: TOP_MID pad_all: 0 min_value: 0 max_value: 100 value: 0 bg_color: color_gray bg_opa: 50% indicator: bg_color: color_green # PSRAM memory (show used from total) - obj: y: 70 width: 400 height: 50 align: TOP_MID bg_opa: TRANSP pad_all: 0 border_opa: TRANSP widgets: - label: align: TOP_LEFT text: "PSRAM Used:" text_font: nunito_16 text_color: color_misty_blue - label: id: psram_memory_label align: TOP_RIGHT text: "0/8 MB" text_font: nunito_16 text_color: color_blue - bar: id: psram_memory_bar y: 30 width: 390 height: 12 align: TOP_MID pad_all: 0 min_value: 0 max_value: 100 value: 0 bg_color: color_gray bg_opa: 50% indicator: bg_color: color_blue # Chip temperature - obj: y: 130 width: 400 height: 30 align: TOP_MID pad_all: 0 bg_opa: TRANSP border_opa: TRANSP widgets: - label: align: LEFT_MID text: "CPU Temperature:" text_font: nunito_16 text_color: color_misty_blue - label: id: chip_temperature_label align: RIGHT_MID text: "0°C" text_font: nunito_16 text_color: color_yellow # WiFi signal - obj: y: 170 width: 400 height: 30 align: TOP_MID pad_all: 0 bg_opa: TRANSP border_opa: TRANSP widgets: - label: align: LEFT_MID text: "WiFi Signal:" text_font: nunito_16 text_color: color_misty_blue - label: id: wifi_signal_label align: RIGHT_MID text: "0 dBm" text_font: nunito_16 text_color: color_misty_blue # IP Address - obj: y: 210 width: 400 height: 30 align: TOP_MID pad_all: 0 bg_opa: TRANSP border_opa: TRANSP widgets: - label: align: LEFT_MID text: "IP Address:" text_font: nunito_16 text_color: color_misty_blue - label: id: ip_address_label align: RIGHT_MID text: "192.168.3.3" text_font: nunito_16 text_color: color_misty_blue # MAC Address - obj: y: 250 width: 400 height: 30 align: TOP_MID pad_all: 0 bg_opa: TRANSP border_color: color_white border_width: 1 border_opa: TRANSP widgets: - label: align: LEFT_MID text: "MAC Address:" text_font: nunito_16 text_color: color_misty_blue - label: id: wifi_mac_label align: RIGHT_MID text: "11:22:A1:B2:C3:D4" text_font: nunito_16 text_color: color_misty_blue # ESPHome version - obj: y: 290 width: 400 height: 30 align: TOP_MID pad_all: 0 bg_opa: TRANSP border_opa: TRANSP widgets: - label: align: LEFT_MID text: "ESPHome Version:" text_font: nunito_16 text_color: color_misty_blue - label: id: esphome_version_label align: RIGHT_MID text: "2020.0.0" text_font: nunito_16 text_color: color_misty_blue # Interval for periodic logging interval: - interval: 60s then: - lambda: |- // Log real memory usage const size_t total_sram = 512 * 1024; const size_t total_psram = 8 * 1024 * 1024; size_t free_sram = heap_caps_get_free_size(MALLOC_CAP_INTERNAL); size_t used_sram = total_sram - free_sram; size_t free_psram = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); size_t used_psram = total_psram - free_psram; ESP_LOGI("system_info", "SRAM: %u/%u KB used (%.1f%%)", used_sram/1024, total_sram/1024, (used_sram * 100.0) / total_sram); if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) > 0) { ESP_LOGI("system_info", "PSRAM: %u/%u MB used (%.1f%%)", used_psram/(1024*1024), total_psram/(1024*1024), (used_psram * 100.0) / total_psram); } else { ESP_LOGI("system_info", "PSRAM: Not available"); }