-->
Page 1 of 1

Scan IP address of ESP8266

PostPosted: Tue Nov 29, 2016 1:51 pm
by anujmattoo
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 192.168.4.1. Therefore in order to connect the ESP to WiFi, the command goes like this :- 192.168.4.1/SSID=XYZ/Pass=XYZ.

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.

Re: Scan IP address of ESP8266

PostPosted: Tue Nov 29, 2016 11:39 pm
by chupo_cro
Assign a static IP address to the ESP8266 so you will know the address in advance. Example:

Code: Select allIPAddress ip(192,168,1,xx);               // desired IP address
IPAddress gateway(192,168,1,yy);          // IP address of the router
IPAddress subnet(255,255,255,0);

WiFi.begin(ssid, password);
WiFi.config(ip, gateway, subnet);

while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
}

Re: Scan IP address of ESP8266

PostPosted: Wed Nov 30, 2016 2:32 am
by eduperez
If you can, configure the DHCP server in the router to assign always the same IP address to each ESP device, then use that IP address; even better if you can configure the DNS server in the router, so they also have a domain name.

You can also explore service discovery protocols.