Reference.WiFiLocalIP History

Hide minor edits - Show changes to markup

November 22, 2011, at 07:24 AM by Scott Fitzgerald -
Changed lines 27-35 from:

//SSID of your network char ssid[] = "yourNetwork"; //password of your WPA Network char pass[] = "secretPassword";

IPAddress ip; IPAddress subnet; IPAddress gateway;

to:

char ssid[] = "yourNetwork"; //SSID of your network

int status = WL_IDLE_STATUS; // the Wifi radio's status

IPAddress ip; // the IP address of your shield

Changed lines 35-36 from:
 WiFi.begin(ssid, pass);
to:
 // initialize serial:
 Serial.begin(9600);

 WiFi.begin(ssid);
Changed lines 46-49 from:
 //print the IP address
  Serial.print("IP: ");
  Serial.println(WiFi.localIP());
to:
 //print the local IP address
  ip = WiFi.localIP();
  Serial.println(ip);
November 22, 2011, at 07:20 AM by Scott Fitzgerald -
Changed lines 19-20 from:

An array containing the IP address of the shield

to:

the IP address of the shield

Changed line 46 from:
  ip = WiFi.localIP();
to:
 //print the IP address
Changed lines 48-77 from:
  Serial.print(ip[0]);
  Serial.print(".");
  Serial.print(ip[1]);
  Serial.print(".");
  Serial.print(ip[2]);
  Serial.print(".");
  Serial.println(ip[3]);

  // print your subnet mask:
  subnet = WiFi.subnetMask();
  Serial.print("NETMASK: ");
  Serial.print(subnet[0]);
  Serial.print(".");
  Serial.print(subnet[1]);
  Serial.print(".");
  Serial.print(subnet[2]);
  Serial.print(".");
  Serial.println(subnet[3]);

  // print your gateway address:
  gateway = WiFi.gatewayIP();
  Serial.print("GATEWAY: ");
  Serial.print(gateway[0]);
  Serial.print(".");
  Serial.print(gateway[1]);
  Serial.print(".");
  Serial.print(gateway[2]);
  Serial.print(".");
  Serial.println(gateway[3]);
to:
  Serial.println(WiFi.localIP());
November 22, 2011, at 07:17 AM by Scott Fitzgerald -
Changed lines 23-24 from:

[@

to:
Changed line 82 from:

@]

to:
November 22, 2011, at 03:53 AM by Scott Fitzgerald -
Added lines 1-81:

WiFi

WiFi.localIP()

Description

Gets the WiFi shield's IP address

Syntax

WiFi.localIP();

Parameters

none

Returns

An array containing the IP address of the shield

Example

#include <WiFi.h>

//SSID of your network 
char ssid[] = "yourNetwork";
//password of your WPA Network 
char pass[] = "secretPassword";

IPAddress ip;
IPAddress subnet;
IPAddress gateway;

void setup()
{
 WiFi.begin(ssid, pass);

  if ( status != WL_CONNECTED) { 
    Serial.println("Couldn't get a wifi connection");
    while(true);
  } 
  // if you are connected, print out info about the connection:
  else {
  ip = WiFi.localIP();
  Serial.print("IP: ");
  Serial.print(ip[0]);
  Serial.print(".");
  Serial.print(ip[1]);
  Serial.print(".");
  Serial.print(ip[2]);
  Serial.print(".");
  Serial.println(ip[3]);

  // print your subnet mask:
  subnet = WiFi.subnetMask();
  Serial.print("NETMASK: ");
  Serial.print(subnet[0]);
  Serial.print(".");
  Serial.print(subnet[1]);
  Serial.print(".");
  Serial.print(subnet[2]);
  Serial.print(".");
  Serial.println(subnet[3]);

  // print your gateway address:
  gateway = WiFi.gatewayIP();
  Serial.print("GATEWAY: ");
  Serial.print(gateway[0]);
  Serial.print(".");
  Serial.print(gateway[1]);
  Serial.print(".");
  Serial.print(gateway[2]);
  Serial.print(".");
  Serial.println(gateway[3]);

  }
}

void loop () {}

Share