I need to send a string from the arduino to the web form on that page http://ift.tt/2az5roz and submits the form. This is the current code of my arduino, what is wrong, or what is missing..
void SubmitHttpRequest()
{
mySerial.println("AT+CSQ");
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
mySerial.println("AT+CGATT?");
delay(100);
ShowSerialData();
mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
delay(5000);
ShowSerialData();
mySerial.println("AT+SAPBR=3,1,\"APN\",\"internet.vodafone.net \"");//setting the APN, the second need you fill in your local apn server
delay(8000);
ShowSerialData();
mySerial.println("AT+SAPBR=0,1");//setting the SAPBR, for detail you can refer to the AT command mamual
delay(5000);
ShowSerialData();
mySerial.println("AT+SAPBR=1,1");//setting the SAPBR, for detail you can refer to the AT command mamual
delay(8000);
ShowSerialData();
mySerial.println("AT+HTTPTERM"); //term the HTTP request
delay(5000);
mySerial.println("AT+HTTPINIT"); //init the HTTP request
delay(5000);
ShowSerialData();
mySerial.println("AT+HTTPPARA=\"URL\",\"http://ift.tt/2aAYyQm\"");// setting the httppara, the second parameter is the website you want to access
delay(5000);
ShowSerialData();
mySerial.println("AT+HTTPDATA=1000,10000"); //100 refers to how many bytes you're sending. You'll probably have to tweak or just put a large #
delay(10000);
ShowSerialData();
mySerial.println("[\"id\": \"01\",\"current_value\": \"" "\",");
delay(500);
mySerial.println("TEST from Arduino"); //ie latitude,longitude,etc...
delay(5000);
ShowSerialData();
mySerial.println("AT+HTTPACTION=1");//submit the request
delay(5000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
while(!mySerial.available());
ShowSerialData();
mySerial.println("finish");
delay(100);
mySerial.println("[\"id\": \"01\",\"current_value\": \"" "\",");
delay(500);
ShowSerialData();
}
Aucun commentaire:
Enregistrer un commentaire