-->
Page 1 of 3

UDP Client+Server example

PostPosted: Sun Apr 12, 2015 7:15 am
by gerardwr
Now that the bug in the UDP library is fixed (ref http://www.esp8266.com/viewtopic.php?f=29&t=2390) here's a basic working sketch for bidirectional UDP communication. The ESP displays the content of the received packet in the Serial Monitor and sends a confirmation message back to the UDP sender.

Below you will find:
- screen dump, upper part = Serial Monitor ESP, lower part is from Mac OS using netcat/nc as counterpart for the ESP.
- the example sketch

Schermafbeelding 2015-04-12 om 13.46.45.png


UdpClientServer.ino.zip

Re: UDP Client+Server example

PostPosted: Tue Apr 28, 2015 3:08 pm
by Sunspot
Many thanks for this
I have a Mac as you do
but
from the Mac I get "Your UDP packet was received OK" with no delay
but on the serial monitor there is a delay of 2 to 10 seconds to show the string I typed on the Mac

The ESP8266 is 2 m from my wifi router.
Can you say how to speed things up?

Re: UDP Client+Server example

PostPosted: Wed Apr 29, 2015 3:06 am
by Sunspot
Reference my delay above.
After leaving the Mac ESP on all night I now find almost no delay receiving in the Arduino WinXP VMware terminal
Odd?

Re: UDP Client+Server example

PostPosted: Tue May 12, 2015 2:00 pm
by notrub
I've been trying to play with UDP on my ESP8266, and keep getting stuck: the reply only happens once. I have tried a few different examples people have posted, including this one, and the problem is always the same. After a reset on the chip, it will again receive 1 message and send 1 reply, but stop there. Any help that can be offered would be appreciated. Thanks in advanced.

EDIT:
I got it working! After more searching, the problem was in the IDE. I found the solution in this post:
http://www.esp8266.com/viewtopic.php?f=29&t=2222#p16377
I updated my Arduino IDE to 1.6.4, then added the ESP hardware folder again, and all is working.