-->
Page 1 of 4

UDP Packet sending, time delays of about 150ms

PostPosted: Sat Aug 19, 2017 5:00 am
by MM596
Hello!

I am using a NodeMCU with the Arduino IDE to send some real time data, via UDP packets.

I am sending these packets every 50ms (I've checked this, every 50ms the UDP.beginPacket, ... endPacket are executed), but if I am using wireshark to see the packets arriving, I can see that there are delays of about 150ms, sometimes 200ms.

Is there a possibility to speed this up?

Thank you very much
Regards

Re: UDP Packet sending, time delays of about 150ms

PostPosted: Sat Aug 19, 2017 8:20 am
by schufti
reduce traffic - and interference from other stations - on your wifi?

Re: UDP Packet sending, time delays of about 150ms

PostPosted: Sat Aug 19, 2017 9:58 am
by MM596
I have only one WiFi network in the near area, so I don't think it's an interference problem.

Has some ever checked the transmission times of the ESP8266?
Or does anyone run "real time" transmissions with this µC and can give me some hints or suggestions?

Re: UDP Packet sending, time delays of about 150ms

PostPosted: Sat Aug 19, 2017 10:46 am
by rudy
MM596 wrote:Has some ever checked the transmission times of the ESP8266?


I didn't think what you are seeing is anything relating to a problem with the UDP routines, so I performed the following test.

I used two ESP-12 boards. One as a sender, the other as a receiver.

Sender code
Code: Select allvoid loop()
{
  digitalWrite(led4, LOW);
 
  wifiUdp.beginPacket(RemoteIpadr, RmoteUdpPort);
  wifiUdp.write("from ESP8266");   
  wifiUdp.endPacket();
 
  digitalWrite(led4, HIGH); 

  Serial.println(counter);
  delay(50);
  counter=counter+1;
}


Receiver code
Code: Select allvoid loop() {
  int packetSize = udp.parsePacket();

  if (packetSize > 0)
  {
  digitalWrite(led15, LOW);
   
    Serial.print("  Data was - ");
    int len = udp.read(packetBuffer, 255); 
    Serial.println(packetBuffer);   

  digitalWrite(led15, HIGH);   
  }
}


I used a logic analyzer to measure the delay between the send and the receive. I typically get about 1mS delay, max of 2mS. I am not seeing any significant delays.

The routines are good. You did not post your code so it is either you are doing something wrong in your code or your problem is elsewhere.