2

Consider my loop() in Arduino be:

void loop(){
  for(int i = 0; i<100; i++){
   Value[i] = analogRead(A0);
   delayMicroseconds(62);
  }
   //delay(2) //when I use this line esp8266 works properly
   Udp.beginPacket(IP, Port);
   Udp.write(Value, 100);
   Udp.endPacket();
}

after analogRead() UDP can't send packets and crash occur after a moment. But when I use delay(2) line in the above code it works properly. I want to record samples of microphone with 16000 sample rate and I use 62 microseconds for this. Thus in my application it is not possible for delay 2 milliseconds. How can I fix this without delay?

3
  • 1
    hard use of A0 disturbs WiFi signal measuring done by SDK with the same ADC. use external ADC for continues measurement with esp8266
    – Juraj
    Apr 28, 2019 at 16:22
  • Thank you for replying.
    – mohammad
    Apr 28, 2019 at 16:55
  • +1 for the excellent answer Juraj. I did not know that hard use of the ADC would cause issues with the WiFi signal :)
    – VE7JRO
    Aug 29, 2021 at 0:02

0

Browse other questions tagged or ask your own question.