Interference between ESP8266 WiFi and ADC

Hi, I am developing a web server project to monitor my home electrical panel. I use an ESP-12E platform under Arduino IDE 2.0.3. To put it simply, if you start from the code ESP8266WebServer -> AdvancedWebServer example and add a very simple acquisition loop (here burst of 400 values), we see that the time of the analogRead instruction can vary from simple to double randomly. But in the same batch it is constant. Does anyone know why and how to fix it?
Thanks.

Sampling instructions added in the Arduino loop code :
int lecture[400];
unsigned long times[400];

for (int k=0;k<400;k++){
times[k] = micros();
lecture[k] = analogRead(A0);
times[k] += micros();
delayMicroseconds(10);
}
Serial.print("Total duration for sampling = ");
Serial.println((times[399] - times[0])/2);

Result for example :
Total duration for sampling = 43138
Total duration for sampling = 43371
Total duration for sampling = 21555
Total duration for sampling = 21549
Total duration for sampling = 43478
Total duration for sampling = 21572
Total duration for sampling = 21579 etc ...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.