I am trying two hours now to send some measurements over the web but can't make it happen.
I use arduino uno and I read from one analog input the measurements. I am sure I have mistakes in the client.println section of the code because when I go to the site all I get from apache is this:
Notice: Undefined index: measurements in panel_update.php on line 4
where line 4 is : echo $_GET["consumption"];
I was searching for examples and thought that the webclientrepeating example
will solve my questions but didn't had some chance.
Can someone help me out with my case?
What should I have in the client.println ?
I only want one variable to be send and it's declared above all as double measurements;
Thank you!
client.println("POST hxxp://yourdomain.com/SMSSite/XMLInterface/Postxml.aspx HTTP/1.0");
// add a header indicating you have content-data to send. If you set this too low, the server won't see it. If it is too high, the server may wait, or report an error.
client.print("content-length: ");
client.println(strlen(big_string));
// tell the server you are done with the header.
client.println();
// send the posted data.
client.print(big_string);
Thank you for the reply zoomkat, but what am I supposed to have in data variable?
If I understand right, my formkey is the consumption variable but data is for what?
Excuse me for my ingorance.
I have checked, via wireshark, the incoming packets I receive from the ethernet shield and I do have, between many others, packets with POST flag and the variable measurement. So, as I see, the error must be somewhere in my panel_update.php because the shield does really send the information. In the panel_update.php, all I have are these lines of code:
I selected a packet with POST information and followed the tcp stream from wireshark's options.
Surprisingly, I do receive the measurement as shown below
POST /panel/panel_update.php HTTP/1.1
Host: 192.168.2.6
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 17
measurement=30.81
HTTP/1.1 200 OK
Date: Sun, 09 Jun 2013 15:26:48 GMT
Server: Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4
X-Powered-By: PHP/5.4.4
Set-Cookie: PHPSESSID=09hv89qopikk3cabphet4ttk66; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 33
Connection: close
Content-Type: text/html
updateValue([{"measurement":"30.81"}]);
I just noticed it but when I hit on panel_update.php I get this error:
Notice: Undefined index: measurement in C:\xampp\htdocs\panel\panel_update.php on line 8
If I understand right, when I hit on the panel_update.php I get this error because that time the shield doesn't send anything, maybe?
Anyway, all I want to have as output to the panel_update.php is a json-like format of
updateValue([{"measurement":"30.81"}]);
so to fetch the measurement value and post it via javascript to panel.php
How can I make it happen?