Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)
User avatar
By ith
#68556 Hi All,

The D1 mini is configured to access point mode. I connect to it with my laptop and expect to receive UDP messages at a fixed rate.

The code is super simple - setup the AP, and send a UDP message every 500 milliseconds.

My problem: the messages come at an unstable rate - anything from 400ms to 800ms. Tried it with 3 units so far - same result. I've used similar codes before, on a generic ESP8266 and on Adafruit WICED - and never got such an unstable transmission!

Am I doing something wrong?
Is it a hardware limitation specific to WeMos D1?
Has anyone ever come across similar problems?

Thanks a million,

ith
User avatar
By rudy
#68564
I've used similar codes before, on a generic ESP8266 and on Adafruit WICED - and never got such an unstable transmission!


Similar is not the same. Can you try a sketch that did give you consistent results? And if that works as you want then you may want to post your code since it is hard to figure out what a problem could be with nothing to work with.
User avatar
By ith
#68583 Hi Rudy, thanks for the quick reply!

I'm posting the code below, as you'll see it's very basic.
When measuring the time between incoming UDP messages on my computer (with WireShark) I can tell that are transmitted irregularly, in intervals of 400-700 milliseconds, but the timer I put in the code reports 501-502 ms between transmissions.

Thanks so much for any help!
ith

here's the code:
-----------------------------------------------------------------------------------

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


//*** Soft Ap variables ***
const char *APssid = "ESPbase";
const char *APpassword = ""; // No password for the AP
IPAddress APlocal_IP(192, 168, 4, 1);
IPAddress APgateway(192, 168, 4, 1);
IPAddress APsubnet(255, 255, 255, 0);

int counter = 0;

long timer;
long timerPrev;
int timeDiff;

WiFiUDP udp;

void setup() {

Serial.begin(115200); //fire up the serial port
delay(5000);

WiFi.mode(WIFI_AP);

Serial.println("ESP8266 AP & Station & UDP System test");
Serial.print("Soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(APlocal_IP, APgateway, APsubnet) ? "OK" : "Failed!"); // configure network
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(APssid, APpassword) ? "OK" : "Failed!"); // Setup the Access Point
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP()); // Confirm AP IP address

udp.begin(4210);

}

void loop() {

timer = millis();

timeDiff = (int)(timer - timerPrev);

OSCBundle bndl;

bndl.add("counter: ").add(counter).add(" difference: ").add(timeDiff);

udp.beginPacket("192.168.4.100",4210);
bndl.send(udp);
udp.endPacket();

Serial.println("counter:" + counter + " difference: " + timerDiff);
counter++;
timerPrev = timer;
delay(500);
}
User avatar
By ith
#68584 oops, missed one line in the code :/
(the bndl.empty() command)

here's the full and correct version, any help will be much appreciated !
ith

-------------------------------------------------------------------------------------------

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


//*** Soft Ap variables ***
const char *APssid = "ESPbase";
const char *APpassword = ""; // No password for the AP
IPAddress APlocal_IP(192, 168, 4, 1);
IPAddress APgateway(192, 168, 4, 1);
IPAddress APsubnet(255, 255, 255, 0);

int counter = 0;

long timer;
long timerPrev;
int timeDiff;

WiFiUDP udp;

void setup() {

Serial.begin(115200); //fire up the serial port
delay(5000);

WiFi.mode(WIFI_AP);

Serial.println("ESP8266 AP & Station & UDP System test");
Serial.print("Soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(APlocal_IP, APgateway, APsubnet) ? "OK" : "Failed!"); // configure network
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(APssid, APpassword) ? "OK" : "Failed!"); // Setup the Access Point
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP()); // Confirm AP IP address

udp.begin(4210);

}

void loop() {

timer = millis();

timeDiff = (int)(timer - timerPrev);

OSCBundle bndl;

bndl.add("counter: ").add(counter).add(" difference: ").add(timeDiff);

udp.beginPacket("192.168.4.100",4210);
bndl.send(udp);
udp.endPacket();

bndl.empty();

Serial.println("counter:" + counter + " difference: " + timerDiff);
counter++;
timerPrev = timer;

delay(500);
}