ESP32 UDP Broadcasting and Android

Hello,

I have a sketch that runs OK on the ESP8266 but not so well on the ESP32. The sketch creates a SoftAP and then broadcasts an udp message using IP address 192.168.4.255. I receive the udp message on a Windows 10 PC and on an Android smartphone. The message has a length of about 75 characters and it is sent/repeated at a rate of 10 messages per second. Below you find both sketches. The result is the following:

a) on the PC I receive all the messages both with the ESP8266 or the ESP32

b) on all the Android devices that I tested I receive all the messages on the PC but less than half on the Android. The only way that I found for the Android to receive all the messages is to go to unicast (say using 192.168.4.2 if the Android gets that IP)

Any ideas will be much appreciated

This is the sketch for the ESP8266. Both PC and Android receive all data!

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

char nmea[] = "$GPRMC,120000.03,A,3905.84900,N,02633.42800,E,0000.0,330.0,011019,0.0,W,A,S*60";
WiFiUDP udp;
IPAddress udp_ip(192, 168, 4, 255);

void setup() {
  WiFi.softAP("TEST_NETWORK", "12345678");
  udp.begin(2000);
}

void loop() {
  udp.beginPacket(udp_ip, 2000 );
  udp.println( nmea );
  udp.endPacket();
  delay(100);
}

This is the sketch for the ESP32. Only PC receives all data!

#include <WiFi.h>
#include <WiFiUdp.h>

char nmea[] = "$GPRMC,120000.03,A,3905.84900,N,02633.42800,E,0000.0,330.0,011019,0.0,W,A,S*60";
WiFiUDP udp;
IPAddress udp_ip(192,168,4,255);

void setup() {
  WiFi.softAP("TEST_NETWORK", "12345678");
  udp.begin(2000);
}

void loop() {
  udp.beginPacket(udp_ip, 2000 );
  udp.println( nmea );
  udp.endPacket();
  delay(100);
}

PROBLEM SOLVED!!!

Hello,

I found that I could use the alternative <Esp.h> library instead of <WiFiUdp.h> but the loss of packets was even worst. Because of the delay(100) in the sketches I should receive between 9 and 10 messages per second. With <WiFiUdp.h> I was getting a variable rate between 3 or 4 messages per second with periods of no receiving. With <Esp.h> it was much worst with less than 1 message per second. I used several apps to receive UDP from the Google store. All of this was using Arduino IDE 1.8.7 and the ESP32 core by Expressif version 1.0.0.

So I updated today the Arduino IDE to version 1.8.10 and updated the ESP32 core to 1.0.4. The exact same sketch produced a rate of messages arriving to the Android of about 9.5 messages per second. Both referred 2 libraries produced same results.

Best Regards, Vladis