I build a simple HTTP GET request by SIM900. Here is it:
-----1-----
AT+CSQ
+CSQ: 25,0
OK
-----2-----
AT+CGATT?
+CGATT: 1
OK
-----3-----
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
-----4-----
AT+SAPBR=3,1,"APN","indosatgprs"
OK
-----5-----
AT+SAPBR=1,1
OK
-----6-----
AT+HTTPINIT
ERROR
-----6.1-----
AT+HTTPPARA="CID",1
OK
-----7-----
AT+HTTPPARA="URL","http://www.minimalsites.com"
OK
-----8-----
AT+HTTPACTION=0
OK
-----9-----
AT+HTTPREAD
OK
-----10-----
AT+HTTPTERM
ERROR
+HTTPACTION:0,200,1240
-----10.0-----
AT+SAPBR=0,1
OK
The step 9 AT+HTTPREAD I supposed to see some html from http://www.minimalsites.com. But i dont see anything, What wrong with me?
-
1Before you do anything HTTP you should do a "AT+SAPBR=2,1" and see if you are actually connected to the bearer. It should return "+SAPBR: 1,1,aa.bb.cc.dd"Majenko– Majenko2015年09月16日 09:41:15 +00:00Commented Sep 16, 2015 at 9:41
-
It return +SAPBR: 1,3,"0.0.0.0". What is that said?Tama– Tama2015年09月18日 02:04:37 +00:00Commented Sep 18, 2015 at 2:04
-
That means you are not connected.Jake C– Jake C2015年09月18日 03:13:14 +00:00Commented Sep 18, 2015 at 3:13
4 Answers 4
From what I can see in your results, it seems AT+HTTPINIT
returned an error. This means the HTTP service wasn't even successfully activated. So there's no way the commands you issued later would have been successful. From the AT command manual, AT+HTTPINIT is necessary before you can do any HTTP-related stuff.
You need to run the command AT+CGATT=1
to attach GPRS, even if your query shows its value is already 1.
It could also be that your APN requires authentication, using a username and password. So once you find out the username and password authorized by 'indosatgprs' (customer care?), you can use them in the following commands.
AT+SAPBR=3,1,"USER","Enter the username here"
AT+SAPBR=3,1,"PWD","Enter password"
Both commands should return OK if successful. To view all the parameters you have set, you can use AT+SAPBR=4,1
. If all the parameters are satisfactory, and you have sufficient airtime in the SIM, then you can attempt AT+HTTPINIT
. Only if this command returns OK, should you proceed to run AT+HTTPPARA
-related commands.
Check Your Connection Try Pinging the IP of Your Arduino and INstead of Using the AT commands use this library its easier and Nice https://github.com/amcewen/HttpClient
-
how to know my IP address? my device run by SIM cardTama– Tama2015年09月18日 02:08:37 +00:00Commented Sep 18, 2015 at 2:08
You have to wait after AT+HTTPACTION=0
for a while until you see something like +HTTPACTION:0,200,1240
Then continue to AT+HTTPREAD
, you will see the result.
Finally, terminate HTTP.
after days fighting with asynchronous and limit serial buffer size (64Bytes). I found this one.
this link help me out, it uses the standard library SoftwareSerial and my big txt file 1100 bytes or my html file (5814bytes) are download again & again with no issue!!
https://www.youtube.com/watch?v=cpgQOmQwUL8&t=1263s http://www.iforce2d.net/sketches/gsm_HTTPGet.zip nb: I change it to AltSoftSerial, no problem neither. Thanks iforce2d
ps: you can also use the "ModuleSerial-master" library, but I need to save the space for other code (which already uses 74% of 2KB RAM) so I stick to AltSoftSerial which already found in my sketch