-->
Page 1 of 1

UDP Without Static IP Addresses Arduino

PostPosted: Mon Jul 11, 2016 4:26 pm
by mitmell
I'm using the ESP8266WiFi library for arduino for Udp communications. It has been working well so far, but right now I have to hardcode in the IP address of the client/computer I'm sending UDP packets to.

I'm wondering if anyone knows of a way (preferably using ESP8266WiFi.h library) to eliminate the need for me to hardcode in the IP address of the client and on the client code side hardcode the IP address of the ESP.

I'm aware that you if you have a client send a packet to the ESP then you can get the IP address of whatever sent you the packet. For instance:

Code: Select all    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write("UDP packet received");
    Udp.endPacket();


This is a partial solution because it requires that I know the IP address of the ESP8266 to send it an initial packet from the client. In my particular usage the client is a pc running come UDP matlab code.

I've read a little bit about UDP multicasting and am wondering maybe this would be the right route to a solution. Perhaps I can multicast send messages from the ESP and receive them with the matlab code and then send a response to the ESP? Unfortunately I'm fairly unfamiliar with multicasting in general.

In another situation I would just use a static IP (so I wouldn't worry about the IP address of the ESP and Client changing), but I'm using the wifi at my school.

Thanks everyone, any suggestions/advice would be appreciated :) I'll post my solution once I figure this out

EDIT: I ended up using Dynamic DNS to use hostnames instead of static IPs. Here is my updated code. It implements a UDP serial bridge with dynamic dns.

Re: UDP Without Static IP Addresses Arduino

PostPosted: Mon Jul 11, 2016 7:40 pm
by mrburnette
AP w/ DHCP & UDP broadcasts:

http://www.hackster.io/rayburne/tardis-time-esp8266-ap-webserver-gps-6b5d2a

The attic unit has been up 7x24 since last September! Always 2 clients, sometime 3.

Ray

Re: UDP Without Static IP Addresses Arduino

PostPosted: Thu Jul 14, 2016 2:07 pm
by mitmell
mrburnette wrote:AP w/ DHCP & UDP broadcasts:

http://www.hackster.io/rayburne/tardis-time-esp8266-ap-webserver-gps-6b5d2a

The attic unit has been up 7x24 since last September! Always 2 clients, sometime 3.

Ray


I ended up doing something else, but thanks for your help Ray