That sounds like a plan.
But..... (sorry)
This is an extract from the code which I use and this gets the IP address.
Ok, first off this is THE line:
Serial.println(WiFi.localIP());
And this is how it is in the bigger picture.
(bit more maybe of interest at the bottom though)
void setup_wifi()
{
delay(10);
byte l_count = 0;
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
if (l_count > 60)
{
Serial.println("");
l_count = 0;
//
// Need routine in here to show activity on display.
//
no_wap();
}
}
Serial.println("");
Serial.println("=================");
Serial.println("WiFi connected");
Serial.println("IP_Address: ");
Serial.println(WiFi.localIP());
Serial.println("=================");
This is a routine I call with the IP address:
It is a mess.
And I am not sure why byte is here.
void Show_IP_on_Display()
{
header(3);
char message[16];
uint8_t *IpPtr = &(WiFi.localIP()[0]);
sprintf(message, "%u.%u.%u.%u", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
//Serial.println(message);
byte x = format(message); ///// Why is byte here?
message_display();
Serial.println("Message displayed. Wiping display");
delay(600);
//post_message_wipe();
wipe(15);
}
//------------------------------------------------------------
/*
* This takes "message[] and formats it so it can be
* displayed on the 7 segment display with the decimal
* points (etc)
* returns "output_loop" in the correct format.
*/
byte format(char message[])
//void format(char message[])
//void format()
{
//
byte data; // Used to read IP address. Storage of value/s.
byte input_loop = 0;
byte output_loop = 0;
if (value_debug == 1)
{
//
Serial.println("Creating bmessage. Details below.");
Serial.println("Value received is ");
Serial.println(message);
}
while (message[input_loop] != '\0')
{
data = message[input_loop];
//
if (value_debug == 1)
{
Serial.print("Reading in from file ");
Serial.println(message[input_loop]);
}
//
if (data == '.')
{
//
// Decimal point detected.
//
if (value_debug == 1)
{
Serial.println("** Decimal place detected ** Editing this value");
Serial.println(message[input_loop-1]);
Serial.print(" at position --> ");
Serial.println(input_loop);
}
bmessage[output_loop-1] = (bmessage[output_loop-1] + 128);
input_loop = input_loop + 1;
} else
{
data = (data - '0' ); // Take "number" and make it a real value.
bmessage[output_loop] = data;
input_loop = input_loop + 1;
output_loop = output_loop + 1;
}
}
return output_loop;
}