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);
}