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

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

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

Postby mycael » Wed Jun 19, 2024 9:33 am

Hello !
I am a beginner in the world of ESP and zigbee and I am building a CO2 measurement system using the zigbee network for home automation. I use an ESP32-C6 and an SCD40 component which works in I2C. So far, everything is working perfectly. The component joins the zigbee network well and regularly reports the values measured by the sensor and read by I2C. Since I would like the system to run on battery power, I want to use "light sleep" mode. I was inspired by the example provided in ESP-IDF: "Sleepy End Device Example".

In the app_main function, I added the call to the function:

Code: Select all

esp_zb_power_save_init();
With this function identical to the example:

Code: Select all

static esp_err_t esp_zb_power_save_init(void)
{
 esp_err_t rc = ESP_OK;
#ifdef CONFIG_PM_ENABLE
 int cur_cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ;
 esp_pm_config_t pm_config = {
 .max_freq_mhz = cur_cpu_freq_mhz,
 .min_freq_mhz = cur_cpu_freq_mhz,
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
 .light_sleep_enable = true
#endif
 };
 rc = esp_pm_configure(&pm_config);
#endif
 return rc;
}
In the function static void esp_zb_task(void *pvParameters):

Code: Select all

/* initialize Zigbee stack */
 esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
 esp_zb_sleep_enable(true);
 esp_zb_init(&zb_nwk_cfg);
In the function void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct):

Code: Select all

case ESP_ZB_COMMON_SIGNAL_CAN_SLEEP:
 ESP_LOGI(TAG, "Zigbee can sleep");
 esp_zb_sleep_now();
 break;
The ESP switches to "light sleep" mode since I have the information on the console: "Zigbee can sleep" and I see that consumption is dropping. But the I2C communication no longer works and the reading functions return a timeout error code.

I use the old I2C driver (i2c.h) and not the new one (i2c_master.h). Is the new one likely to work better?

I must be missing something, but I don't see what... Any suggestions?

Thank you for your help !

Who is online

Users browsing this forum: No registered users and 25 guests