Skip to content

Instantly share code, notes, and snippets.

@BenGriffiths
Last active August 29, 2015 14:09
Show Gist options
  • Save BenGriffiths/4380b5ea89ab3e4b4d6f to your computer and use it in GitHub Desktop.
Save BenGriffiths/4380b5ea89ab3e4b4d6f to your computer and use it in GitHub Desktop.
void sendData() {
lcd.clear();
lcd.setCursor(0,0); lcd.print("Connecting...");
// Turn the float to a string
dtostrf(tempCurrent, 4, 2, tempBuffer);
// Build the GET request
String getRequest = "GET /homemonitor/log.php?temperature=";
getRequest += URLEncode(tempBuffer);
getRequest += " HTTP/1.1";
if (client.connect(server, 80)) {
lcd.clear();
lcd.setCursor(0,0); lcd.print("Connected");
lcd.setCursor(0,1); lcd.print(server);
// Call the server with our GET request
client.println(getRequest);
client.print( "Host: " );
client.println(server);
client.println("User-Agent: Arduino-Box");
client.println();
client.stop();
client.flush();
delay(4000);
}
else {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Connection");
lcd.setCursor(0,1);
lcd.print("Failed! :(");
delay(5000);
}
lcd.clear();
lcd.begin(16, 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment