Network.localIP() to String (to get it via Spark.variable())

I am afraid that I don’t know much about the Arduino String class but redefining the name localIP from method to variable seems like a bad idea. Here is some code that worked fine for me.

  localAddr = WiFi.localIP();
  byte oct1 = localAddr[0];
  byte oct2 = localAddr[1];
  byte oct3 = localAddr[2];
  byte oct4 = localAddr[3];
  char s[16];  
  sprintf(s, "%d.%d.%d.%d", oct1, oct2, oct3, oct4);
  Serial1.print(s);

Hope this helps!

3 Likes