WiFi - I2C conflict : problem of tasks priorities ?
Posted: Tue Jan 04, 2022 1:05 pm
Hi everyone.
On the ESP32 devkit C, I have the following problem: when WiFi is enabled, I2C communication is erratic. I have found this to be the case when sending data to an LCD via I2C which, when WiFi is not enabled, works fine.
You will tell me that the problem has already been formulated in the following topic: viewtopic.php?t=9348
I don't think it's a problem of spikes creating disturbances in the signal or power as supposed in this topic but rather a problem of task priority.
I use both cores of the ESP32. For my project, one core is specifically in charge of communications (WiFi, I2C, SPI, UART), the other core is in charge of the real-time management of several stepper motors via the Accestepper library.
I am obliged to proceed in this way because to have fluid movements with my stepper motors, I cannot manage the communications on the same core, otherwise the main loop is no longer executed at a sufficient frequency to send the pulses to the stepper motor drivers, which disturbs the fluidity of the motor movements.
The different communication tasks are therefore executed on the other core, all together.
I suspect that the WiFi task has such a high priority that as soon as it needs the core, it overrides the other running tasks, which induces errors in the data transmission via the other communication protocols and more specifically I2C in my case.
When I run the code for the I2C communication on a different core than the one WiFi is running on, then the problem disappears! Except that in this case, it's my stepper motors that don't move smoothly anymore, so I can't be satisfied with this situation.
Have you encountered similar problems? Do you think my approach to the problem is correct?
Many thanks for your answers. I will continue to search on my own and will keep you informed of the outcome of this research.
If you need more information, let me know.
Best wishes for the New Year!
Julien
On the ESP32 devkit C, I have the following problem: when WiFi is enabled, I2C communication is erratic. I have found this to be the case when sending data to an LCD via I2C which, when WiFi is not enabled, works fine.
You will tell me that the problem has already been formulated in the following topic: viewtopic.php?t=9348
I don't think it's a problem of spikes creating disturbances in the signal or power as supposed in this topic but rather a problem of task priority.
I use both cores of the ESP32. For my project, one core is specifically in charge of communications (WiFi, I2C, SPI, UART), the other core is in charge of the real-time management of several stepper motors via the Accestepper library.
I am obliged to proceed in this way because to have fluid movements with my stepper motors, I cannot manage the communications on the same core, otherwise the main loop is no longer executed at a sufficient frequency to send the pulses to the stepper motor drivers, which disturbs the fluidity of the motor movements.
The different communication tasks are therefore executed on the other core, all together.
I suspect that the WiFi task has such a high priority that as soon as it needs the core, it overrides the other running tasks, which induces errors in the data transmission via the other communication protocols and more specifically I2C in my case.
When I run the code for the I2C communication on a different core than the one WiFi is running on, then the problem disappears! Except that in this case, it's my stepper motors that don't move smoothly anymore, so I can't be satisfied with this situation.
Have you encountered similar problems? Do you think my approach to the problem is correct?
Many thanks for your answers. I will continue to search on my own and will keep you informed of the outcome of this research.
If you need more information, let me know.
Best wishes for the New Year!
Julien