I have a Arduino uploading data to a MySql database but the data is not getting through. The code to upload the data is a client code sending a GET HTML link to a file called updat_db.php. the code is below.
void sendGET() //client function to send/receive GET request data.
{
Serial.println ("send data");
if (client.connect(serverName, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.print("GET /update_db.php?panel=");//send panel = to server
client.print(panelin);//add panelin temperature to above line note no println in code
client.print("&lower=");
client.print(lowerin);
client.print("&upper=");
client.print(upperin);
client.print("&rayburn=");
client.print(rayburnin);
client.println(" HTTP/1.0");// add to end of GET send with println
client.println("Host: stevehomecontrol.ddns.net");// my web host address
client.println(); //end of get request
Serial.println ("end send data");
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
return;
}
what i get back from the serial terminal is below
send data
connected
end send data
HTTP/1.1 302 Found
Date: Mon 05 Jan 2015 09:41:41 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Location: http://86.173.99.233:8080/update_db.php?panel=9&lower=26&upper=41&rayburn=49
content-Length: 0
Connection: close
Content-Type: text/html; charset=UFT-8
disconnected
Now if i type the above http:// address in a browser the update-db file is called and mySql is up dated correctly, so the address and php file are all correct. According the the serial feed back the arduino is outputting this address but the data base is not updating when the arduino does this.
Any one got any ideas why this does not work. If you need more information please let me know.
Just to note the address in the arduino code goes to a no-ip DNS account which then send the data to a raspberry pi which is running apache2 server. The ip address changing.
Ive tried changing the web address to the ip address of my server but this just did not connect. My port is on 8080 so i assume I need to change this is the arduino code.
If i connect through the local ip address 192.168.1.99 it does not connect but i know it needs 8080 on the address to bring up the index page.
Can any one tell me is the client.print making up the web page address. if so then on the 6th line of the code why is GET in there, could i change this with my web address
any one got any ideas as ive tried a lot now and may need to redo all this another way
Not sure this will make a difference, I can give it a go. Post is just another way to send the data which is not visual in the address line. GET should work the same way.
Seeing as GET function works when i put the address direct in my browser address line, I would expect the GET function in the arduino code to work the same.
I also used this exact code to upload data to a different online HOST with worked all ok.
Im thinking the problem could be with either the Pi running Linux and apache, or the ports are 8080 not 80. or it could be I need to register a proper Domain name. however the last theory should not be a problem.
I've been doing a lot of google searching and I cant see where anyone has done this.
looking at the 302 code I could have a big problem. From what I have read this is where the original HTTP address sent by the Arduino has been redirected, I assume to my ip address which is what is being sent back in the serial data.
when this happens i loose the data in the GET HTTP line. would POST stop this?
or I have a problem with the server which i can't find any way around.
No. You are not connecting to the server or sending the right host information/ Without seeing all of your code, we'd only be guessing what you are doing wrong. I, for one, am not into guessing games.