I have an example web client that can connect to a predefined website .. but how do I configure this to input variables?
ie here :
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.print("GET /Admin/Update.php?page=update&key=17&name=Test&temp=15&light=99 HTTP/1.1");
client.println("Host: www.test.com");
client.println("Connection: close");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
instead of using predefined values for temp and light ... I want to use variables temp and light .. but if I just type the name there then it sends just the name and not the variable value.
instead of using predefined values for temp and light ... I want to use variables temp and light .. but if I just type the name there then it sends just the name and not the variable value.
See those double quotes on the ends? They mean send everything from here to here AS IS. Since that's not what you want, you need to re-enroll in CS100, and learn about sprintf().
That is a five packet send. That is 48 bytes of overhead per packet. Mine is one packet. Some servers have problems with that. And that last should be a client.println().
@Nick: I got the point. I was offering a reason to spend the 100 bytes of SRAM instead of sending a bunch of packets. Most servers do not have a problem with receiving the GET line in multiple packets, but some do, and I'm not sure which.
Thanks that helps a lot. Should I put my client code in a seperate function and then call it each time I want to upload variables? Then I can stick all my sensor functions within the void loop with a delay at the end.
Then I can stick all my sensor functions within the void loop with a delay at the end.
No don't do that. Look at the blink without delay example.
...or look at my client code with the new "wait 30 seconds without delay()" code. http://playground.arduino.cc/Code/WebClient
The timeout feature still uses delay(1), but the loop uses millis() now.