I am trying to send data via GET to my PHP server from my Ethernet Shield2. This is part of my sketch:

char myserver[] = "www.myserver.com/";
if (client.connect(myserver, 80)) {
  Serial.print("Connected to ");
  client.print("GET /arduino/controller.php?");
  client.println(" HTTP/1.1");
  client.print("Host: ");
  client.println("Connection: close");
} else {
  // if you didn't get a connection to the server:
  Serial.println("Connection failed to Server");

The serial monitor displays "Connect to myserver.com" but my PHP code doesn't seem to receive the air_temp value from DS18B20_temperature. I checked this value and it's true.

However, when I try myserver.com/arduino/controller.php?air_temp=25 in my browser, the PHP code is running well.

What's going wrong with my code?

  • Try changing char myserver[] = "www.myserver.com/"; to char myserver[] = "www.myserver.com"; (so without tailing slash)
    – Gerben
    Jan 28, 2017 at 14:21
  • Hi, I changed the line with char myserver[] = "www.myserver.com"; and now the serial monitor send "Connection failed to Server". :(
    – Teddol
    Jan 29, 2017 at 13:37
  • There shouldn't be a slash in the Host header. So create a second variable, without the slash and use that one in line behind Host...
    – Gerben
    Jan 29, 2017 at 15:03
  • Why create another variable ? Theproblem is that my shield does not connect to my server, Why ?
    – Teddol
    Jan 29, 2017 at 18:56
  • Apparently client.connect needs the slash at the end, while Host: required no slash at the end.
    – Gerben
    Jan 29, 2017 at 19:10

1 Answer 1


I just removed the line server.begin() and it's works !!! Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.