I am trying to post an HTTP URL with data to a website.
I tested it first on Cosm and it works on Cosm, but I want to emulate an entry in the address bar of IE.
How do I do the same with AT commands?
I am not sure if there need to be extra ""
I am using a SIM900 with Software Serial witch has a 64 Byte buffer.
I have tried the following:
AT+SAPBR=3,1,"APN","internet"
OK
AT+CIFSR
41.18.131.13
AT+CIPSPRT=0
OK
AT+CIPSTART="TCP","http:/www.mysite.com","80"
OK
CONNECT OK
AT+CIPSEND
http:/www.mysite.com/test/gettempdata.php?TI=25.5&TO=20.9&TR=16.7
SEND OK
AT+CIPCLOSE
AT+CIPSHUT=0
CLOSE OK
and
AT+CSQ
AT+CGATT?
AT+SAPBR=3,1,"CONTYPE","GPRS"
+CSQ: 12,0
AT+SAPBR=3,1,"APN","internet"
OK
AT+HTTPPARA="URL","http:/www.mysite.com/test/gettempdata.php?TI=25.5&TO=20.9&TR=16.7"
OK
AT+HTTPACTION=0
OK
+HTTPACTION:0,603,0
AT+HTTPREAD
OK
When I use HTTPPARA I do not get response, if I use HTTPPARA with www.google.com I get a response when I run HTTPREAD
Any help would be appreciated.
Please let me know if I need to post the code as well.
Based on a quick reading of the datasheet, I don't think the SIM900 supports HTTP. You'll have to establish a TCP connection and then manually negotiate the HTTP.
Do any one of you know where I can find an example on the server side to accept POSTs with PHP, similar than Cosm.
I want to store the data on my own site, Cosm only keeps data for 3 months.
AT+SAPBR=3,1,"APN","internet"
OK
AT+CIFSR
41.15.5.196
AT+CIPSPRT=0
OK
AT+CIPSTART="TCP","www.Mysite.com","80"
OK
CONNEC
AT+CIPSEND
PUT /test/gettempdata.php?TI=19.12&TO=21.75&TR=32.63 HTTP/1.1
Host: www.Mysite.com
Connection: keep-alive
AT+CIPCLOSE
AT+CIPSHUT=0
CLOSE OK
As requested here is the code on the Arduino
I chanced the code from a Pachube example.
It still needs to be cleaned up and tested a few times.
Have a great day
void Send2Pachube()
{
mySerial.println("AT+CGATT?"); //Attach or Detach from GPRS Service (Result 1 = Attach , 2 = Detached )
delay(300);
ShowSerialData();
//mySerial.println("AT+CIPMUX=0");
//delay(300);
//ShowSerialData();
//mySerial.println("AT+CIPMODE=0");
//delay(300);
//ShowSerialData();
mySerial.println("AT+CIPSHUT=0"); //Close TCP Connection
delay(300);
ShowSerialData();
//mySerial.println("AT+CSTT=\"internet\"");//start task and setting the APN,
//delay(1000);
//ShowSerialData();
mySerial.println("AT+SAPBR=3,1,\"APN\",\"internet\"");//setting the APN, the second need you fill in your local apn server
delay(1000);
ShowSerialData();
//mySerial.println("AT+CIICR");//bring up wireless connection
//delay(300);
//ShowSerialData();
//mySerial.println("AT+CIFSR");//get local IP adress
//delay(2000);
//ShowSerialData();
mySerial.println("AT+CIPSPRT=0");
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSTART=\"TCP\",\"www.mysite.com\",\"80\"");//start up the connection
delay(2000);
ShowSerialData();
Serial.println();
mySerial.println("AT+CIPSEND");//begin send data to remote server
delay(4500);
ShowSerialData();
mySerial.print("PUT /test/gettempdatatime.php?");//here is the feed you apply from pachube
delay(500);
ShowSerialData();
mySerial.print("TI="); //DATA feed name
mySerial.print(GetAVG_TempOnOnePin( A0 )); //DATA to send
delay(10);
ShowSerialData();
mySerial.print("&TO="); //DATA feed name
mySerial.print(GetAVG_TempOnOnePin( A1 )); //DATA to send
delay(10);
ShowSerialData();
mySerial.print("&TR="); //DATA feed name
mySerial.print(GetAVG_TempOnOnePin( A2 )); //DATA to send
delay(10);
ShowSerialData();
mySerial.print(" HTTP/1.1\r\n");
delay(500);
ShowSerialData();
mySerial.print("Host: www.mysite.com\r\n");
delay(500);
ShowSerialData();
//mySerial.print("Connection: keep-alive"); //working
mySerial.print("Connection: close"); //working as well
mySerial.print("\r\n");
mySerial.print("\r\n");
//mySerial.println();
delay(500);
ShowSerialData();
//mySerial.println((char)26);//sending
mySerial.print(0x1A,BYTE);
delay(500);//waitting for reply, important! the time is base on the condition of internet
mySerial.println();
ShowSerialData();
mySerial.println("AT+CIPCLOSE");//close the connection
delay(100);
ShowSerialData();
mySerial.println("AT+CIPSHUT=0");
delay(100);
ShowSerialData();
}
No. You're not using either of the two functions I listed. Look at the examples in the links. Your checklist should be:
Declare an array large enough to hold the float's string.
Use dtostrf() to convert the float into a string
Declare an array large enough to hold your entire string
Use sprintf() to construct the string.
Furthermore, code should be posted using CODE tags.
Better, but still not correct. Why are you giving it the address of a pointer? Array's are already pointers, and sprintf() is expecting a pointer, not the pointer's reference. Arduino's modified libraries also don't include the %f format specifier, which is why I suggested using dtostrf().