No WiFi after adding lvgl

Hi,
I’m out of options. Running into the issue that my esp32-S2 is not connecting to Wifi after I added the LVGL stuff. Removing this “package” and all works fine again (but useless without the display).

How Can I debug solve this?
I guess it has something to do with my config, can someone confirm?

thx in advance.

  • When trying to retrive some logging over USB, I see the device rebooting and logs on screen:
[16:09:04][W][wifi_esp32:094]: Setting WiFi mode failed!
[16:09:04][C][wifi:263]: Setting up AP...
[16:09:04][C][wifi:265]:   AP SSID: 'airmon2 Fallback Hotspot'
[16:09:04][C][wifi:266]:   AP Password: 'MySecretAP'
[16:09:04][D][esp-idf:000][wifi]: E (183989) wifi:
[16:09:04][D][esp-idf:000][wifi]: Expected to init 4 rx buffer, actual is 0
[16:09:04][D][esp-idf:000][wifi]: 

[16:09:04][W][wifi_esp32:094]: Setting WiFi mode failed!
[16:09:05][C][wifi:275]:   IP Address: 240.105.253.63
[16:09:05][I][wifi:182]: Starting fallback AP!
[16:09:05][D][esp-idf:000][wifi]: E (183996) wifi:
[16:09:05][D][esp-idf:000][wifi]: Expected to init 4 rx buffer, actual is 0
[16:09:05][D][esp-idf:000][wifi]: 

Both validation and compiling are oke.

Linking .pioenvs/airmon2/firmware.elf
RAM:   [=         ]  14.0% (used 45828 bytes from 327680 bytes)
Flash: [======    ]  63.9% (used 1173058 bytes from 1835008 bytes)
Building .pioenvs/airmon2/firmware.bin
Creating esp32s2 image...
Successfully created esp32s2 image.
esp32_create_combined_bin([".pioenvs/airmon2/firmware.bin"], [".pioenvs/airmon2/firmware.elf"])
Wrote 0x12e7e0 bytes to file /data/build/airmon2/.pioenvs/airmon2/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/airmon2/firmware.bin"], [".pioenvs/airmon2/firmware.elf"])
======================== [SUCCESS] Took 156.41 seconds ========================
INFO Successfully compiled program.
INFO Connecting to 192.168.40.33 port 3232...
INFO Connected to 192.168.40.33
INFO Uploading /data/build/airmon2/.pioenvs/airmon2/firmware.bin (1173472 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 22.44 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.40.33 using esphome API
WARNING Can't connect to ESPHome API for airmon2 @ 192.168.40.33: Timeout while connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.40.33', port=6053))] (TimeoutAPIError)
INFO Trying to connect to airmon2 @ 192.168.40.33 in the background

Airmon2.yaml

packages:
  device: !include common/board_esp32_s2_mini.yaml
  base: !include common/base.yaml
  display: !include common/display_gc9a01a_lvgl_BAC.yaml

substitutions:
  software_version: 20250203_v1
  device_nr: "2"
  devicename_name: airmon
  esphome_comment: AIR Monitor 
  esphome_project_name: JAYA.AIR Monitor

##############################################
#  DO NOT CHANGE ANYTHING BELOW THIS LINE  ###
##############################################
  esphome_name: "${devicename_name}${device_nr}"
  esphome_project_version: "${esphome_name}, ${software_version}"
  devicename: "${esphome_name}"
  upper_devicename: "${devicename}"
  sensor_update_frequency: 1s
  #log_level: info # Enable levels logging https://esphome.io/components/logger.html
  log_level: DEBUG

  # Config for status_led (on GPIO15):
light:
  - platform: status_led
    name: "Status LED"
    id: esp_status_led
    icon: "mdi:alarm-light"
    restore_mode: RESTORE_DEFAULT_OFF
    pin:
      number: GPIO15
      inverted: false 

# I2C-bus voor de SCD40 or other Air Quality Sensor
i2c:
  - id: i2c_bus0
    sda: 33
    scl: 35
    scan: true
    frequency: 200kHz

sensor:
    # CO2 Sensor, temperature and humidity  
    - platform: scd4x
      id: scd40
      co2:
        name: "${upper_devicename} CO2 concentratie"
        id: co2_value
        device_class: carbon_dioxide
        state_class: measurement
        on_value:
          then:
          - output.turn_on: data_led
          - delay: 100ms
          - output.turn_off: data_led
          # - lvgl.indicator.update:
          #     id: co2_needle
          #     value: !lambda return id(co2_value).state;
          # - lvgl.label.update:
              # id: co2value
              # text: 
              #   format: "%.0f"
              #   args: 
              #     - id(co2_value).state
      temperature:
        name: "${upper_devicename} Temperatuur"
        id: temperature_value
        device_class: temperature
        state_class: measurement
        #on_value:
        #  then:
        #  - lvgl.label.update:
        #      id: temperature
        #      text: !lambda |-
        #        return String(id(temperature_value).state, 1) + "°C";
      humidity:
        name: "${upper_devicename} Luchtvochtigheid"
        id: humidity_value
        device_class: humidity
        state_class: measurement
        #on_value:
        #  then:
        #    - lvgl.label.update:
        #        id: humidity
        #        text: !lambda |-
        #          return String(id(humidity_value).state, 0) + "% RH";

      update_interval: 60s
      measurement_mode: periodic
      #ambient_pressure_compensation: 1013.25  # Standard sea level pressure in hPa

output:
  - platform: gpio
    pin: 39
    id: data_led

board_esp32_s2_mini.yaml

esp32:
  board: esp32-s2-saola-1
  #board: lolin_s2_mini
  variant: ESP32S2
  flash_size: 4MB
  framework:
    type: arduino
    version: recommended

base.yaml

# Base include
# Define Project Details and ESP Board Type
esphome:
  name: ${esphome_name}
  comment: $esphome_comment
  project:
    name: ${esphome_project_name}
    version: ${esphome_project_version}

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esphome_name} Fallback Hotspot"
    password: !secret esphome_ap_password

logger:
  level: ${log_level}
  logs:
    component: error

###############################################
# Enable OTA updates
###############################################
ota:
  - platform: esphome
    password: !secret esphome_ota_password

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

###############################################
# Enable Home Assistant API
###############################################
api:
  encryption:
    key: !secret esphome_api_encrypt_key
  reboot_timeout: 0s

####################################################
# Switch Control to restart the system.
####################################################
switch:
  - platform: restart
    id: restart_device
    name: "Restart ${devicename}"
    entity_category: config

###############################################
# Text sensors with general information.
###############################################
text_sensor:
  - platform: version # Expose ESPHome version as sensor.
    name: "${upper_devicename} ESPHome Version"
    hide_timestamp: false
  - platform: wifi_info
    ip_address:
      name: "${upper_devicename} IP"
      id: wifi_ip_address
      icon: "mdi:wan"
      entity_category: "diagnostic"
    ssid:
      name: "${upper_devicename} SSID"
      icon: "mdi:wan"
      entity_category: "diagnostic"
    # bssid:
    #   name: "$esphome_name BSSID"
    mac_address:
      name: "${upper_devicename} Mac Wifi Address"
      entity_category: "diagnostic"

sensor:
  # Uptime sensor.
  - platform: uptime
    name: "${upper_devicename} Uptime"
    entity_category: "diagnostic"
    icon: "mdi:timer-outline"

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: "${upper_devicename} WiFi Signal"
    id: sensor_wifi
    update_interval: 60s
    entity_category: "diagnostic"

display_gc9a01a_lvgl_BAC.yaml

font:
  # - file: "fonts/arial.ttf"
  #   id: font_small
  #   size: 18
  # - file: "fonts/arial.ttf"
  #   id: font_large
  #   size: 36
  # - file: "fonts/Roboto-Medium.ttf"
  #   id: roboto_large
  #   size: 32 # Increased from 24 to 48
  - file: "fonts/Roboto-Medium.ttf"
    id: roboto_medium
    size: 56 # Increased from 24 to 48
    extras:
      - file: "fonts/materialdesignicons-webfont.ttf"
        glyphs: [
            "\U000F07E4", # mdi-molecule-co2
            "\U000F0F55", # mdi-home-thermometer-outline
          ]
  # - file: "fonts/Roboto-Medium.ttf"
  #   id: roboto_small
  #   size: 20 # Increased from 12 to 20
  - file: "fonts/ds-digi.ttf"
    id: font_digital
    size: 72 # Increased from 12 to 20

# # SPI-bus voor het GC9A01-display
spi:
  clk_pin: 5
  mosi_pin: 3

display:
  - platform: ili9xxx
    model: GC9A01A
    id: my_display
    dimensions:
      height: 240
      width: 240
    cs_pin: 7
    dc_pin: 9
    reset_pin: 11
    invert_colors: true
    rotation: 0
    auto_clear_enabled: false
    update_interval: never
    data_rate: 40MHz

lvgl:
  log_level: INFO
  color_depth: 16
  bg_color: 0x000000
  align: center
  pages:
    - id: co2_page

      widgets:
        - meter:
            height: 240
            width: 240
            align: center
            text_font: montserrat_14
            bg_opa: TRANSP
            text_color: 0x999999
            border_width: 0
            pad_all: 4

            scales:
              - ticks:
                  width: 2
                  count: 21
                  length: 15
                  color: 0x000000
                  major:
                    stride: 5
                    width: 6
                    length: 20
                    color: 0xFFFFFF
                    label_gap: 20
                range_from: 300
                range_to: 2300
                angle_range: 270
                rotation: 135

                indicators:
                  - line:
                      id: co2_needle
                      width: 8
                      color: 0xFF0000
                      r_mod: -5
                  - arc: # GREEN
                      color: 0x00FF00
                      width: 12
                      start_value: 300
                      end_value: 800
                  - arc: #YELLOW
                      color: 0xFFDE21
                      width: 12
                      start_value: 800
                      end_value: 1299
                  - arc: # ORANGE
                      color: 0xFF7518
                      width: 12
                      start_value: 1300
                      end_value: 1799
                  - arc: #RED
                      color: 0xF44336
                      width: 12
                      start_value: 1800
                      end_value: 2300

        - obj:
            # to cover the middle part of meter indicator line
            height: 118
            width: 118
            radius: 73
            align: CENTER
            border_width: 0
            bg_color: 0x000000
            pad_all: 0

        - label:
            id: co2_text
            text_font: roboto_medium
            align: center
            text_color: 0x999999
            bg_opa: TRANSP
            y: -35
            recolor: true
            text: "\U000F07E4"
        - label:
            id: co2value
            text_font: font_digital
            align: center
            text_color: 0xFFFFFF
            bg_opa: TRANSP
            y: +12
            text: "---"
        - label:
            id: ppm_text
            text_font: montserrat_24
            align: center
            text_color: 0x999999
            bg_opa: TRANSP
            y: +90
            text: "PPM"

Your log indicates you are programming OTA, which seems impossible if you device doesn’t work.

You need to connect via USB and program that way and look at the whole log from USB to see what is happening.

I really like the ability to do OTA updates (it is the whole reason I started and continue to use esphome) but a bad update can make it hard to recover if you don’t have easy physical access to the device.

Hi Neel-m
thx for the reply. When its “broken”, I do use USB upload.
I tried manual with command line ESPTOOLS and through HA. Both with same result as described.
When I upoad it through USB, the message is “Success” however, the device looks “dead”. The display is black (device not started correctly??) and USB logging is unavailable (log screen says black)

During compilation I get followng error:

WARNING buffer_size: may need to be reduced without PSRA

Error only occurs when I add LVGL stuff

That warning might be more like an error.

I tried using lvgl with my m5 stick and found that it appeared to run out of memory and not work. I did not debug it. Instead I went for a more basic approach, since the screen doesn’t have touch and I didn’t want to invest the time in understanding something that probably wasn’t better for my particular use case.

I hear you really should use an esp32 with PSRAM with LVGL. It is possible to make the example work without it for a small screen, but I don’t really know the limits/constraints.

There was a breaking change in 2025.2 that means for the ILI9xxx component you now need to manually turn on PSRAM. This could be your issue.

Try adding:

psram:

to your config.

1 Like

Hi @zoogara and thank you!
This did the trick.

I was searchin on this memory track, since I got the warning message.

NOw I understand why it “suddenly” did not work anymore as it worked that day… I did update ESPHOME directly as it came available in HA, which was on the same day…

1 Like