diff --git a/esphome/components/wifi/__init__.py b/esphome/components/wifi/__init__.py index 8cb784233f..4e1d2998f6 100644 --- a/esphome/components/wifi/__init__.py +++ b/esphome/components/wifi/__init__.py @@ -1,6 +1,7 @@ from esphome import automation from esphome.automation import Condition import esphome.codegen as cg +from esphome.components.const import CONF_USE_PSRAM from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant from esphome.components.network import IPAddress from esphome.config_helpers import filter_source_files_from_platform @@ -334,6 +335,9 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_ON_DISCONNECT): automation.validate_automation( single=True ), + cv.Optional(CONF_USE_PSRAM): cv.All( + cv.requires_component("psram"), cv.boolean + ), } ), _validate, @@ -454,6 +458,8 @@ async def to_code(config): if config[CONF_ENABLE_RRM]: cg.add(var.set_rrm(config[CONF_ENABLE_RRM])) + if config.get(CONF_USE_PSRAM): + add_idf_sdkconfig_option("CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP", True) cg.add_define("USE_WIFI") # must register before OTA safe mode check diff --git a/tests/components/wifi/test.esp32-idf.yaml b/tests/components/wifi/test.esp32-idf.yaml index dade44d145..91e235b9ce 100644 --- a/tests/components/wifi/test.esp32-idf.yaml +++ b/tests/components/wifi/test.esp32-idf.yaml @@ -1 +1,7 @@ -<<: !include common.yaml +psram: + +wifi: + use_psram: true + +packages: + - !include common.yaml