Hi all,
I'm using Arduino UNO with SIM900 shield.
Currently I try to send HTTP POST request using AT command to my server.
Here is some of my code where inputString is a string in a JSON format.
void loop() {
if (millis() - tempo > Period) {
sendLocInfo(jsonString);
tempo = millis();
}
while (ConnectSerial.available()) {
Serial.println(ConnectSerial.read());
}
}
void sendLocInfo(char * inputString) {
ConnectSerial.println("AT+SAPBR=1,1"); // Enable GPRS
delay(1000);
ConnectSerial.println("AT+HTTPINIT"); // Enable HTTP
delay(100);
ConnectSerial.println("AT+HTTPPARA=\"CID\",1"); // Set up the HTTP bearer profile identifier
delay(100);
ConnectSerial.println("AT+HTTPPARA=\"URL\",\"http://call1669.cpe.kmutt.ac.th/var/www/html/easylocate/calculate.php\""); //Set the URL
delay(100);
ConnectSerial.println("AT+HTTPPARA=\"CONTENT\",\"application/json\""); // Set the content type to JSON
delay(100);
ConnectSerial.print("AT+HTTPDATA=");
ConnectSerial.print(sizeof(inputString));
ConnectSerial.println(",10000");
delay(2000);
ConnectSerial.println(inputString);
delay(100);
ConnectSerial.println("AT+HTTPACTION=1"); // Start the HTTP POST session
delay(1000);
ConnectSerial.println("AT+HTTPREAD"); // Read the received data
delay(100);
}
I got a response with a bunch of number.
I thought they were hex or ascii so I try to put them on some conversion website but there is no meaning.
65
84
43
71
83
78
13
10
13
10
48
49
51
57
53
48
48
48
55
49
50
49
49
50
51
13
10
13
10
79
75
13
10
Although they are different in each loop but this is the first set the response produced.
However, I have some problem to show the URL page on the server which when I try GET method, it response with 404 error but that's fine right now.
The question is shouldn't I get the same response as GET? Is this numbers response already correct?
How can I modify the code to get the correct result?
Cheers