How to convert a char read from txt on SD and the assign to Local IPAddress

I whant that the IPAddress of ther WebServer be assigned by an txt file on SD. I am reading the txt file on a buffer with exactly the form of the IP address for example (192, 168 , 1, 1).

The webserver uses "IPAddress ip(192, 168, 1, 1 ); "

Any idea of how to move the buffer value to the IPAddress?


You can use strtok() to parse the input. The below demonstrates (how you read from file is outside the scope of this)

void loop()
  // what you have read from file
  char data[16] = "";

  // ip address
  byte ip[4];

  char *token;
  int index = 0;

  /* get the first token */
  token = strtok(data, ".");

  /* walk through other tokens */
  while ( token != NULL && index < sizeof(ip))
    ip[index++] = atoi(token);
    token = strtok(NULL, ".");

  for (int cnt = 0; cnt < sizeof(ip); cnt++)


Instead of printing, you can use the 4 elements of the ip array in other ways where you need them.
Note that strtok is destructive, so the data variable no longer ‘contains’ the original ip address as text.