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 ");
Serial.println(myserver);
client.print("GET /arduino/controller.php?");
client.print("air_temp=");
client.print(DS18B20_temperature);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(myserver);
client.println("Connection: close");
client.println();
client.println();
} 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?
char myserver[] = "www.myserver.com/";
tochar myserver[] = "www.myserver.com";
(so without tailing slash)Host
header. So create a second variable, without the slash and use that one in line behind Host...client.connect
needs the slash at the end, whileHost:
required no slash at the end.