I2C latency with enabled WiFi

supercachai
Posts: 3
Joined: Mon May 22, 2023 9:25 pm

I2C latency with enabled WiFi

Postby supercachai » Thu May 25, 2023 8:17 am

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

supercachai
Posts: 3
Joined: Mon May 22, 2023 9:25 pm

Re: I2C latency with enabled WiFi

Postby supercachai » Tue May 30, 2023 11:02 am

I tracked this down to `temp_sensor_read_celsius()`, removing it fixed the latency problem.

Who is online

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