Comments on: Arduino – HTTP Post Requests http://blog.protoneer.co.nz/arduino-http-post-requests/ Electronic Prototyping Specialists Tue, 27 Oct 2015 17:47:27 +0000 hourly 1 http://wordpress.org/?v=4.3.1 By: Bertus Kruger http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-707 Sat, 01 Mar 2014 06:06:25 +0000 http://blog.protoneer.co.nz/?p=275#comment-707 Hi…. I don’t have the DB structure at the moment but Google will point you in the right direction.

]]>
By: Jean-Christophe Duperron http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-686 Fri, 07 Feb 2014 05:54:48 +0000 http://blog.protoneer.co.nz/?p=275#comment-686 Ha ha! I like your response Bert!
People should know how PHP and forms work before trying to mix language and communications between!
Nice post by the asymmetric
A soon a get my ethernet sheild ill try posting to my local webserver too!
And i’ll check by an Ajax style my database and all is sensors data!

You have an exemple on how you design your database?

]]>
By: Bertus Kruger http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-650 Tue, 31 Dec 2013 06:02:13 +0000 http://blog.protoneer.co.nz/?p=275#comment-650 Hi.

I can’t answer your question but I can give you some clues to get to it. Use FireFox with FireBug. FireBug has a tab called “Net”. This tab displays the browser traffic. With Firebug open, you just click on the submit button of the form that you want to simulate and look in the “Net” tab to find the Post Request headers that was sent to google.

Other thing to keep in mind is that the request needs to end with an empty line. You example does not have that at the end. It only adds a new line char after print(data) but does not add an extra empty line)

Hope this helps.

]]>
By: Joao http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-647 Sat, 28 Dec 2013 10:57:28 +0000 http://blog.protoneer.co.nz/?p=275#comment-647 Hy Guys i want write data in Google Form ( No spreedshet):

My code is, but doesn work :(

client.println(“POST /forms/d/……../formResponse HTTP/1.1”);
client.println(“Host: docs.google.com”);
client.println(“Content-Type: application/x-www-form-urlencoded”);
client.println(“Connection: close”);
client.print(“Content-Length: “);
client.println(data.length());
client.println();
client.print(data);
client.println();

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-113 Fri, 10 May 2013 21:39:28 +0000 http://blog.protoneer.co.nz/?p=275#comment-113 If you tested the main PHP page with the test page and it returns 1’s then the main PHP is working. If you then look at the results the Arduino gets back form the main page and there are not 1’s in the HTML the Arduino received then there is an issue with the Arduino Code. It might be as simple as a variable name not aligning between the page and the Arduino Post request. What data are you getting back from the Arduino after adding a read loop? (It could also be that your read loop is not working correctly. That can be tested by going to a page like google and comparing the returned html to what a browser returns )

]]>
By: Guillaume http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-111 Fri, 10 May 2013 02:27:02 +0000 http://blog.protoneer.co.nz/?p=275#comment-111 My goal is also to make it write to a MySQL database. But if I don’t have the two echo 1 in the php page it means that something isn’t working with the POST request with Arduino. Isn’t It ?

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-110 Fri, 10 May 2013 02:16:27 +0000 http://blog.protoneer.co.nz/?p=275#comment-110 Instead of echo “1”; I usually make it write data to a MySQL database or make your PHP page send a success email.

Alternative is write code on the Arduino that prints the results from the post request on the serial port.(Make the Arduino print the 1’s 😉
Here are some example code of how to retrieve a webpage -> http://bildr.org/2011/06/arduino-ethernet-client/

It uses client.read();

]]>
By: Guillaume http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-109 Fri, 10 May 2013 02:04:50 +0000 http://blog.protoneer.co.nz/?p=275#comment-109 OK but how can I check if it’s working when I send a data from the Arduino to the server ?

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-108 Fri, 10 May 2013 01:47:04 +0000 http://blog.protoneer.co.nz/?p=275#comment-108 :) it won’t work by just going to the php page because your browser does not send the needed post data… :)

I have added a second PHP page that will similate what the Arduino is doing. Just make sure to point the second test page to the
correct URL on the line with : FORM action=”abovePage.php”.

]]>
By: Guillaume http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-107 Fri, 10 May 2013 00:57:51 +0000 http://blog.protoneer.co.nz/?p=275#comment-107 Yes PHP is working. I fixed the error 500 problem by writing by hand your script and not with a copied pasted like previously. Strange…
However it still doesn’t work. I don’t have the two “1” on my page (it is empty). So I think that the problem is on the Arduino side, more precisely with the POST request. The connection with my server is working but I don’t have any idea to know if the leftover of the request is working or not…

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-106 Thu, 09 May 2013 23:00:08 +0000 http://blog.protoneer.co.nz/?p=275#comment-106 Mmmmm… Are you sure PHP is working? Try :

< ?php echo 'test'; ?>

Are you running Apache or IIS?

I find that the best way to debug scripting languages is by using elimination. Remove parts of the script you think might be broken and re-test. If it does work without the stuff you took out, you know the part that is left is good(So the working bit has been eliminated). Then add bits back till you find the line with the issue. If you can enable PHP warnings it will be a huge help cause that will point you to the line that is not working.

This works for Arduino’s to. Serial.print’ing debugging info so you can get a better idea of what gets sent/received.

]]>
By: Guillaume http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-105 Thu, 09 May 2013 22:45:54 +0000 http://blog.protoneer.co.nz/?p=275#comment-105 Thanks for the script Bert but it doesn’t work with my server. The arduino side seems to work because I get all the POST informations on the serial terminal, but nothing is displayed at the url of the php file. In addition I even have an http 500 error by using chrome or internet explorer (with mozilla the page is empty).

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-104 Thu, 09 May 2013 20:59:19 +0000 http://blog.protoneer.co.nz/?p=275#comment-104 Hi Guillaume,

I have made some bug fixes on the sketch. It should now output the Post request on the serial port.

I have also added a PHP example of how it processes the data from the Arduino.

The PHP side works by looking at the Post Data. (That will be the data variable in our script). To retrieve
that in PHP you use the following command : $_POST[“data”] and $_POST[“submit”]

Does that answer your question?

]]>
By: Guillaume http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-103 Thu, 09 May 2013 12:54:57 +0000 http://blog.protoneer.co.nz/?p=275#comment-103 Hi Bert,
Thanks for sharing this nice work. However I have a problem with my php page for taking the data. Is it possible to know a bit more on this part ?

Sorry for my bad english ! :)

]]>
By: Bert http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-46 Sat, 26 Jan 2013 00:05:13 +0000 http://blog.protoneer.co.nz/?p=275#comment-46 Hi Brian,

Yes… I manged to get this working very well.
My setup:
# Arduino Duemilanove/Uno
# Wiznet ethernet brick. (Same setup as Arduino Ethernet Shield)
# A post request was sent to my webserver every 10 seconds.(Temp+Humid)
# The server page is PHP page that takes the post data and inserts it into a MySQL DB.
# JQuery Mobile + PHP + Google Charts to display the graphs on my production system.

Have you manually tested the post command before trying it on the Arduino?

]]>
By: Brian http://blog.protoneer.co.nz/arduino-http-post-requests/#comment-45 Fri, 25 Jan 2013 23:48:08 +0000 http://blog.protoneer.co.nz/?p=275#comment-45 Did you have any luck with this? I’m trying to figure out HTTP POST with the UNO. want it to send an http post (from a temp sensor) to a wifi thermostate on my local network.

]]>