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
WiFi - I2C conflict : problem of tasks priorities ?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: WiFi - I2C conflict : problem of tasks priorities ?
The I2C peripheral, once started, can handle an I2C transmission very much by itself, so theoretically it being interrupted by WiFi or anything else should not lead to issues. Could you show us your code, ideally whittled down to the minimum program that still displays the issue?
Re: WiFi - I2C conflict : problem of tasks priorities ?
Hi, Have you found a solution to this problem? I came to the same conclusion as you did. I'm using a MAX7219 led matrix. As soon as I enable wifi things seem to go wrong. Text won't display properly (random characters are displayed)
Without wifi all goes correct.
You mentioned you assigned some tasks to different cores, how did you do that?
kr,
Patrik
Without wifi all goes correct.
You mentioned you assigned some tasks to different cores, how did you do that?
kr,
Patrik
-
- Posts: 1
- Joined: Wed Aug 10, 2022 4:40 am
Re: WiFi - I2C conflict : problem of tasks priorities ?
Hi, Im having the same issue but worse.
Im using an MCP3208 (ADC via SPI), handled by the second core, it is constantly making readings and calculations as quickly as possible.
The SPI communications is bitbanged (not using a library but setting the pins high and low and reading them manually to increase speed.)
The first core handles WiFi and other stuff.
When no wifi is avavilable the ESP32 works ok and does the ADC readings properly.
When the ESP32 detects a wifi and connects to it, the ADC readings take twice as long and the readings are wrong. I noticed this because I am readding a sine wave and it messes up the shape as well as the period.
When I send data or perform a ping(); then the ADC works OK ffor a while (2 sec) then it goes back to a faulty mood.
I cannot figure out how to make the wifi not interfere with my ADC readings, and I am even more confused as to why to stops interfering when I actually send data back and forth via wifi.
Using WiFi.disconnect does not work, it only works if I shut down the modem or hotspot.
Im using an MCP3208 (ADC via SPI), handled by the second core, it is constantly making readings and calculations as quickly as possible.
The SPI communications is bitbanged (not using a library but setting the pins high and low and reading them manually to increase speed.)
The first core handles WiFi and other stuff.
When no wifi is avavilable the ESP32 works ok and does the ADC readings properly.
When the ESP32 detects a wifi and connects to it, the ADC readings take twice as long and the readings are wrong. I noticed this because I am readding a sine wave and it messes up the shape as well as the period.
When I send data or perform a ping(); then the ADC works OK ffor a while (2 sec) then it goes back to a faulty mood.
I cannot figure out how to make the wifi not interfere with my ADC readings, and I am even more confused as to why to stops interfering when I actually send data back and forth via wifi.
Using WiFi.disconnect does not work, it only works if I shut down the modem or hotspot.
Who is online
Users browsing this forum: Baidu [Spider] and 40 guests