I am working on a project in which, the mobile app/browser sends HTTP command to ESP8266 in AP mode. The default IP address of ESP is Therefore in order to connect the ESP to WiFi, the command goes like this :-

On connecting to router, the ESP goes into STA mode and Doesn't create AP until WiFi is not found to which it was connected earlier. Now when ESP is connected to router, the router assigns the IP to ESP through which HTTP command will be sent. On Serial monitor, it does show the IP address to which it is assigned, but what if app controls the ESP, there is no serial communication. How will app know the IP address assigned to particular ESP8266? Is there any way app can scan the router? Or any other way to do this? If there are multiple ESP connected to router, how can I identify the IP of particular ESP.


4 Answers 4


The de-facto standard way for devices to broadcast their IP address to clients is through the Multicast DNS system (mDNS). In this system the server sends a UDP message to a specific multicast group address and clients listen for it so they can work out what is where.

mDNS is also known as Zeroconf or Bonjour depending on who you talk to.

The ESP8266 Arduino core (if you are programming the ESP8266 directly) has mDNS examples with it. If you are using the AT command interface instead, then you will need to read the manual to find how to send UDP packets to multicast addresses.

  • Is it different from Multicast UDP by any chance?
    – MICRO
    Commented Nov 30, 2016 at 6:36
  • mDNS uses multicast UDP.
    – Majenko
    Commented Nov 30, 2016 at 8:40

Have the app send a broadcast UDP packet, and have the ESP listen for such broadcasts. Now the ESP knows the IP address of the device on which the app is running, and it can somehow let it know its own IP address: perhaps connecting to a particular socket on which the app will listen, or sending a UDP broadcast of its own.


You can hard-code the required IP address for ESP8266. (That may not be possible all the times). There's a sample code :https://www.arduino.cc/en/Reference/WiFiConfig

If you are not hard-coding IP address, you can read IP address of ESP by using WiFi.localIP() function in Arduino.

  • Please read question carefully before answering.
    – MICRO
    Commented Nov 29, 2016 at 18:59
  • The hardcoded IP can conflict with existing devices connected to router with same IP.
    – MICRO
    Commented Nov 29, 2016 at 19:00
  • The app has no way to know the the IP of devices, even after using the WiFi.localIP(). This can only be useful in serial.
    – MICRO
    Commented Nov 29, 2016 at 19:00
  • You can use sockets
    – Tejas
    Commented Nov 29, 2016 at 19:01
  • I know that, but question is different. Kindly do not provide vague answers.
    – MICRO
    Commented Nov 29, 2016 at 19:02

Regarding mDNS is the solution but unfortunately it has limitation just like currently not supported with Android Platform.

My Suggestion is to keep listen the UDP port on all range of IP address of network as of token and on when you found right reply of UPD packet along with that device IP/MAC/port inside of that replayed packet then you will good to go.

No doubt this will take bit time to done but its only one time or until the IP has been changed.

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.