user59392: How can i convert a String to IPAddress on arduino / esp ?
etc. "192.168.1.2"  -> IPAddress(192, 168, 1, 2)
Tried this 
void setup() {

  Serial.begin(115200);

  IPAddress apip;

  const char *apipch;
  apipch = "192.168.4.1";

Serial.println(apip.fromString(apipch));

}

void loop() {
  // put your main code here, to run repeatedly:
}

But i just get an output "1"

user45446: You could do this:
String myip="192.168.1.2"
IPAddress local_IP;
bool x= local_IP.fromString(myip);


user38721: The IPAddress class has a member function bool fromString(const char *address).
const char *apipch = "192.168.4.1";
IPAddress apip;

if (apip.fromString(apipch)) { // try to parse into the IPAddress
    Serial.println(apip); // print the parsed IPAddress 
} else {
    Serial.println("UnParsable IP");
}


59392: <p>How can i convert a String to IPAddress on arduino / esp ?</p>

<p>etc. "192.168.1.2"  -> IPAddress(192, 168, 1, 2)</p>

<p>Tried this </p>

<pre><code>void setup() {

  Serial.begin(115200);

  IPAddress apip;

  const char *apipch;
  apipch = "192.168.4.1";

Serial.println(apip.fromString(apipch));

}

void loop() {
  // put your main code here, to run repeatedly:
}
</code></pre>

<p>But i just get an output "1"</p>
 45446: <p>You could do this:</p>
<pre><code>String myip=&quot;192.168.1.2&quot;
IPAddress local_IP;
bool x= local_IP.fromString(myip);
</code></pre>
 38721: <p>The <code>IPAddress</code> class has a member function <code>bool fromString(const char *address)</code>.</p>
<pre class="lang-cpp prettyprint-override"><code>const char *apipch = &quot;192.168.4.1&quot;;
IPAddress apip;

if (apip.fromString(apipch)) { // try to parse into the IPAddress
    Serial.println(apip); // print the parsed IPAddress 
} else {
    Serial.println(&quot;UnParsable IP&quot;);
}
</code></pre>
