我需要将arduino中的字符串发送到该页面https://vibrant-bastille-64033.herokuapp.com/上的Web表单并提交表单。 这是我的arduino的当前代码,有什么不对,或者缺少什么..
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\",\"vibrant-bastille-64033.herokuapp.com/create\"");// 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();
}