I am trying to upload sensor data to the database server.
I am using PHP and MySQL on the server. I am trying to upload data through direct URL and it works, but when I try to upload data from Arduino it shows server connected but when I check no database table no insert into my table. I am sharing Arduino program sketch below. Can anyone help me with this issue?
byte mac[] = { U_orgAttribute.mac[0], U_orgAttribute.mac[1], U_orgAttribute.mac[2], U_orgAttribute.mac[3], U_orgAttribute.mac[4], U_orgAttribute.mac[5] };
byte localip[] = {192, 168, 1, 7 }; //Enter the IP of ethernet shield
char server[] = {"www.nayeen.info"} ; //Enter the IPv4 address or webhost address
EthernetClient cliente;
void datasend() {
float temp = U_ccmList[CCMID_InAirTemp].value; //Reading the humidity and storing in hum
float hum = U_ccmList[CCMID_InAirHumid].value; //Reading the temperature as Celsius and storing in temp
if (cliente.connect(server, 80)) { //Connecting at the IP address and port we saved before
Serial.println("connected");
cliente.print("GET /ethernet/data.php?"); //Connecting and Sending values to database
cliente.print("temperature=");
cliente.print(temp);
cliente.print("&humidity=");
cliente.print(hum);
//Printing the values on the serial monitor
Serial.print("Temperature= ");
Serial.println(temp);
Serial.print("Humidity= ");
Serial.println(hum);
cliente.stop(); //Closing the connection
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(1000);
}