Pages: [1]   Go Down
Author Topic: Upen URL with Ethernet Shield  (Read 395 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Miramar Beach, Florida
Online Online
Faraday Member
**
Karma: 115
Posts: 5370
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You must include the "Host:" parameter in the request.
Code:
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.
Logged

Pages: [1]   Go Up
Jump to: