Page 1 of 1

I2C latency with enabled WiFi

Posted: Thu May 25, 2023 8:17 am
by supercachai
Hi,

I am trying to build a voltage regulator control loop, that reads voltages from an external ADC (ADS1015) connected via I2C.
The ESP32-S3 is connected to WiFi.

The loop works as follows:
The ADC notifies the ESP32-S3 through an ALERT pin interrupt, the ISR sets a ready flag.
The program then reads the ADC register in the main loop if the ready flag was set and adjusts the PWM signal.
I am not calling any networking functions (WiFi or sockets) within the loop, the WiFi connection just sits idle in the background.

With Wifi *disabled*, I get a control loop latency of ~6ms . Once Wifi is enabled, the latency can be a couple of seconds.
I guess the reason for the poor real-time performance is that WiFi & I2C share the same core0, and WiFi can block for seconds.

Do you have any ideas how to improve latency?
I thought about "moving" I2C handling to core1 and leave the choppy WiFi on core0?


Thanks

Re: I2C latency with enabled WiFi

Posted: Tue May 30, 2023 11:02 am
by supercachai
I tracked this down to `temp_sensor_read_celsius()`, removing it fixed the latency problem.