I am connecting an ESP8266 to my home network (WiFi). After successful connection, an IP is assigned to it. I am sending commands to the ESP8266 from an Android app.

What can I do to find the ESP8266 on any network where my Android app is also connected? I ask this because whenever I change the network, a new IP is assigned to the ESP8266 and I have to manually change the IP in the Android app.

I just need to find the ESP8266 on the network, get its IP address and send commands to it.

Thanks in advance.

  • This question may have an answer that helps: arduino.stackexchange.com/questions/38092/…
    – TomG
    Dec 26, 2017 at 20:01
  • 3
    That's what mDNS is for. The ESP866 API has examples that show you how to use it.
    – Majenko
    Dec 26, 2017 at 20:11
  • @Majenko : Usefull thing mDNS is, but i am having a lot of issues , to use it in my product. I will give a try to post a new issue regarding that. Btw thanks for the response, i really appreciate the help each time u contribute. Dec 28, 2017 at 6:49
  • i am using socket to communicate with the esp8266. hence needed the ip address. Dec 28, 2017 at 6:52
  • @Majenko : i have tried using mDNS but it doesn't work when the esp is in STA mode. Jun 21, 2018 at 10:40

2 Answers 2


The best way to do this if you are doing it for product is using SSDP protocol. It's Simple service discovery protocol which allows you to search for device in a network. It's implemented in many smart devices now a days with dlna or upnp.

Implement a SSDP server on esp8266 and Implement a SSDP client on Android device.

You can find many devices with this approach, using simple filter to result with your specific information you want from SSDP packet can allow you to only get desired devices from network.

All the documentation about SSDP is given on Arduino esp8266 GitHub page.

You can broadcast your IP in your SSDP packet and then use it in your app, But still your most imp problem of dynamic IP remains unsolved as your IP will always be changing and using IP for accessing a hardware like home automation is not proper way.

You can either use. 1) Static IP for this if you want offline access or 2) Use cloud based solutions, such as mqtt to access device anywhere without the worries of NAT, IP or anything.

But second option is more of commercial kind, you need multiple resources to implement it.

  • @KarmaCoding If you think I have answered your question then upvoting or marking it as accepted answer is good idea. I can add more info to it if you want.
    – Rajendra
    Apr 8, 2019 at 14:23

Some solutions that have worked for me:

  1. Reserved IP - use the router's DHCP reservation to give the same ESP the same IP each time.

  2. Static IP - Set the ESP to use the same IP each time, bypassing the DHCP feature altogether. This also boots the ESP slightly faster. WiFi.config(ip, gateway, subnet);

  3. Dump the IP address to Serial on boot, so that you can at least see what's assigned: Serial.println(WiFi.localIP());

  4. Give the STA a unique name that you can find in the router's DCHP clients page: WiFi.hostname("look_here");

  5. use mDNS to assign a domain-like local URL to the device: MDNS.begin("esp8266");// default to "http://esp8266.local/"

  • useful answer too. but i am finding something to implement on a product level with different custom working protocols for multiple devices to search them in a network , where only my devices will get listed, also it must be the fastest way. i am using socket to communicate with the esp8266. hence needed the ip address. Dec 28, 2017 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.