Issue with ESP32-C6 on zigbee and I2C component using light sleep

mycael
Posts: 2
Joined: Tue Jun 18, 2024 11:47 am

Issue with ESP32-C6 on zigbee and I2C component using light sleep

Postby mycael » Tue Jun 18, 2024 12:16 pm

Hello,
I'm a beginner in the ESP32 world and zigbee network and I encounter a problem when I want to use "light sleep" mode with the I2C interface.
I work with an ESP32-C6 and a SCD40 to measure the CO2 level in the air. It works in I2C. The information is sent over a Zigbee network. Everything works well.
But I want to use the "light sleep" mode because the module must be connected to the battery and that consumes a lot.
I was inspired by the "light sleep" example from the zigbee sdk content.
So I this is my app_main function:

Code: Select all

 esp_zb_platform_config_t config = {
 .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
 .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
 };
 ESP_ERROR_CHECK(nvs_flash_init());
 ESP_ERROR_CHECK(esp_zb_power_save_init());
 ESP_ERROR_CHECK(esp_zb_platform_config(&config));
 xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);

In the function void esp_zb_app_signal_handler(esp_zb_app_signal_t ​​*signal_struct), I added :

Code: Select all

case ESP_ZB_COMMON_SIGNAL_CAN_SLEEP:
 ESP_LOGI(TAG, "Zigbee can sleep");
 esp_zb_sleep_now();
 break;
In the function static void esp_zb_task(void *pvParameters), I added :

Code: Select all

 /* initialize Zigbee stack */
 esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
 esp_zb_sleep_enable(true);
 esp_zb_sleep_set_threshold(1000);
 esp_zb_init(&zb_nwk_cfg);
I place the whole code in attachement.
The code compiles without errors but the I2C read function returns the Timeout error code. The first I2C command sent to the SCD40 works well but the following failed.
Any idea why this behaviour ?
Maybe the I2C communication is interrupted prematurely because of sleep or something like that ?
Thank you for your help !
Attachments
HA_custom_co2.h
(3.55 KiB) Downloaded 29 times
HA_custom_co2.c
(18.1 KiB) Downloaded 32 times

Who is online

Users browsing this forum: Bing [Bot] and 194 guests