I have stripped as much as I can out of this config. It seems like every time I take something else out, I get at least a .1% increase in fragmentation. It is not crashing, might eventually if I left it up and stopped screwing with it. I took a shot on working with a couple of AI engines to attempt to optimize the code, but nothing seems to help. I have numerous esp’s with the same basic base config and one of them is running a CC1101 and never sees fragmentation above 43% and has a much more complex config. I also have one other with the same display section that behaves perfectly…
Graph:
Config:
substitutions:
name: "home-tank"
friendly_name: ESPHome Tank
devicename: esphome_tank_test
esphome_board: esp32dev
esphome_project_name: "Matt.Ward Aquarium Monitor"
esphome_project_version: "aquarium-monitor-v.2"
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: $esphome_project_name
version: $esphome_project_version
on_boot:
if:
condition:
api.connected: null
then:
- logger.log: API is connected! Now we can trigger what we want!
esp32:
board: esp32dev
framework:
type: esp-idf
sdkconfig_options:
CONFIG_COMPILER_OPTIMIZATION_SIZE: y
CONFIG_COMPOSITE_HEAP_FREELIST: y # Better management of fragmented blocks
advanced:
minimum_chip_revision: "3.1"
sram1_as_iram: true
network:
# enable_ipv6: true
# min_ipv6_addr_count: 2
# enable_high_performance: true
status_led:
pin:
number: 02
inverted: false
# Enable logging
logger:
level: debug
initial_level: INFO
baud_rate: 0 # disable UART logging to save IRAM/heap
hardware_uart: UART0
select:
- platform: logger
name: "Logger select"
debug:
update_interval: 60s
# Enable Home Assistant API
api:
on_client_connected:
then:
- logger.log: "API connected!"
# Allow Over-The-Air updates
ota:
platform: esphome
# Allow provisioning Wi-Fi via serial
#improv_serial:
wifi:
domain: .home
ssid: !secret wifi_ssid
password: !secret wifi_password
# Set up a wifi access point
ap:
ssid: "${friendly_name}"
password: !secret wifi_ap_password
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
# To have a "next url" for improv serial
web_server:
version: 3
include_internal: true
sorting_groups:
- id: sorting_group_ip_settings
name: "IP Settings"
sorting_weight: 10
- id: sorting_group_wifi
name: "Wifi"
sorting_weight: 15
one_wire:
- platform: gpio
pin: GPIO4
i2c:
sda: GPIO21
scl: GPIO22
frequency: 200kHz
display:
- platform: lcd_pcf8574
id: mydisplay
dimensions: 16x2
address: 0x27
update_interval: 10s
lambda: |-
//Print tank temperature and heater state on row 0
it.printf(0,0,"T=%.1fF", id(esphome_tank_temp).state);
it.printf(10, 0, "H=%s", id(tank_heat).state.c_str());
// Print the current time on row 1
// it.strftime(1,1,"%I:%M%p %m/%d", id(my_time).now());
//it.strftime(0,1,"%I:%M%p", id(my_time).now());
it.printf(0,1, "home-tank.home");
if (id(tank_backlight).state) {
// Binary sensor is on
// Control backlight on mydisplay
// Binary sensor is on in HA
id(mydisplay).backlight();
} else {
// Binary sensor is off in HA
id(mydisplay).no_backlight();
}
time:
- platform: homeassistant
id: my_time
text_sensor:
- platform: homeassistant
id: tank_heat
name: "Tank Heater"
icon: mdi:heat-wave
entity_id: binary_sensor.tank_heating
web_server:
sorting_weight: 10
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: IP
id: IP
web_server:
sorting_group_id: sorting_group_ip_settings
sorting_weight: 5
ssid:
name: SSID
web_server:
sorting_group_id: sorting_group_ip_settings
sorting_weight: 25
sensor:
# Uptime sensor.
- platform: uptime
name: $friendly_name Raw Uptime
id: uptime_sensor
update_interval: 60s
internal: false
- platform: dallas_temp
address: 0x5a00000074ec5128 # Replace with your sensor's unique 64-bit address (omit this line if you only have 1 sensor)
name: "ESPHome Tank Temperature"
id: esphome_tank_temp
update_interval: 30s
unit_of_measurement: "°F"
accuracy_decimals: 2
web_server:
sorting_weight: 5
filters:
- lambda: return x * (9.0f/5.0f) + 32.0f + 1.98f; # combine conversion + offset
# - offset: 2.04
- sliding_window_moving_average:
window_size: 3
send_every: 1
- platform: debug
# free:
# name: "Free Memory"
# unit_of_measurement: "Bytes"
# icon: "mdi:memory"
fragmentation:
name: "Heap Fragmentation"
# block:
# name: "Largest Free RAM Block"
binary_sensor:
- platform: homeassistant
id: tank_backlight
name: "Backlight"
entity_id: input_boolean.esphome_backlight
internal: false
web_server:
sorting_weight: 15
- platform: status
name: "API Connected"
switch:
- platform: template
name: "Backlight"
id: backlight_switch
icon: "mdi:lightbulb"
web_server:
sorting_weight: 20
lambda: |-
return id(tank_backlight).state;
turn_on_action:
- homeassistant.service:
service: input_boolean.turn_on
data:
entity_id: input_boolean.esphome_backlight
turn_off_action:
- homeassistant.service:
service: input_boolean.turn_off
data:
entity_id: input_boolean.esphome_backlight
button:
- platform: restart
name: "Restart"
