Hi
how can I open an URL with my Arduino ? I have to send data (temperature, ecc.) to my web site (www.mysite.com/data.php?....) and I can't use the IP of the server but the URL
Thanx from Modena (IT)
Hi
how can I open an URL with my Arduino ? I have to send data (temperature, ecc.) to my web site (www.mysite.com/data.php?....) and I can't use the IP of the server but the URL
Thanx from Modena (IT)
You must include the "Host:" parameter in the request.
char serverName[] = "www.mysite.com";
if(client.connect(serverName,80))
{
Serial.println(F("connected"));
client.println(F("GET /data.php HTTP/1.1"));
client.print(F("Host: ")):
client.println(serverName);
client.println(F("Connection: close\r\n"));
}
else
{
Serial.println(F("failed"));
return 0;
}
You must have a valid dns server ip in the Ethernet.begin() call or the connection will fail.