UDP dropping frames

Posts: 1
Joined: Mon Apr 16, 2018 11:38 pm

UDP dropping frames

Postby CollinK » Mon Apr 16, 2018 11:48 pm

I'm using the current master version of Arduino-ESP32. UPD performance seems to just plain be garbage. Oh, I can send rapidly if I want to but randomly it'll quit sending traffic. If I set to send a packet every 500ms it'll still drop randomly and sometimes not transmit anything for 2-8 seconds. If I set to 100ms it'll send great sometimes and have multi-second drops other times. Below is a very simple sketch that still seems to have this problem. I'm confirming this problem by using wireshark on my PC. I'm rather doubting that the problem is my PC dropping traffic, it seems more likely that the ESP32 isn't sending it properly. You can see in the below sketch that it is outputting
a star every time it sends. I can see weird pauses sometimes in the output of stars which probably correspond to the dropping of UDP frames. But, why?! That sketch does nothing but send UPD frames and wait around in between times. There's nothing running to bog it down.

This is all with a WROOM-32 module. I suspect that the PCB antenna might be garbage but this module is running on a board right next to the PC and the signal strength seems decent enough. Has anyone gotten UDP packets to reliably send from the ESP32? Yes, I know UDP is not reliable but it should be sending more than 75% of the packets. It ought to get to at least 95% of the packets delivered in this case, and probably closer to 99 - 99.9%. Instead I really am getting only like 75% or less through whether I send at 500ms or 100ms. I shudder to even attempt 10ms.

Code: Select all

#include <WiFi.h>

byte i = 0;

byte serialBuffer[2048];
int serialBufferLength = 0;
uint32_t lastFlushMicros = 0;

WiFiUDP wifiUDPServer;
IPAddress broadcastAddr(192,168,4,255);

void setup()

    WiFi.softAP("ESP32DUE", "1234PASSWORD");

    Serial.print("Wifi setup as SSID ");
    Serial.print("IP address: ");
    Serial.print("Done with init\n");

void loop()
    serialBufferLength = 400;
    //If the max time has passed or the buffer is almost filled then send a frame out
    //if ((micros() - lastFlushMicros > 100000) ) {
        wifiUDPServer.beginPacket(broadcastAddr, 17222);
        wifiUDPServer.write(serialBuffer, serialBufferLength);
        //lastFlushMicros = micros();

Who is online

Users browsing this forum: No registered users and 2 guests