Skip to content

Instantly share code, notes, and snippets.

@loosak
Created June 27, 2015 17:35
Show Gist options
  • Save loosak/76019faaefd5409fca67 to your computer and use it in GitHub Desktop.
Save loosak/76019faaefd5409fca67 to your computer and use it in GitHub Desktop.
WiFi.localIP() to string
char buf[16];
sprintf(buf, "IP:%d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3] );
@zzxjl1
Copy link

zzxjl1 commented Nov 26, 2018

Then how to reverse that?

@fitorec
Copy link

fitorec commented May 14, 2019

a simple snippet in some function:

String ip2Str(IPAddress ip){
  String s="";
  for (int i=0; i<4; i++) {
    s += i  ? "." + String(ip[i]) : String(ip[i]);
  }
  return s;
}

good luck!

@gns5280
Copy link

gns5280 commented Apr 18, 2024

But, then how to pass/assign "s" to be used as a String in other parts of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment