Using SIM 900 :
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","www.onewebsite.fr"
AT+HTTPDATA=lengthofpostdata, 10000
sending data
AT+HTTPACTION=1
AT_HTTPREAD=0, lengthofreceiveddata
Up to that point everything works OK
Then i send a new request :
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","www.onewebsite.fr"
AT+HTTPDATA=lengthofpostdata, 10000
sending data
AT+HTTPACTION=1
Then I received the message : +HTTPACTION=1,601,0
Any idea ?
601 is some custom implemented Error code, as an example
This is a "magic" status code that we use to signal that something wrong happened with the request that was so bad that we didn't even got a response back from the server. In this case the request timed out (more than 30 seconds to return any bytes).
source
Here is the list of standard HTTP Status codes
At times you would get this error if you are sending requests too often as well! try to increase the delay between the two requests!
. +HTTPACTION:0,601,0
The above AT response code (601) for HTTP session start indicates that
there is a network error. Then make sure that the PDP context is setup
properly.
source
I faced this problem and the solution is to open the bearer again before the second request.
Use
AT+SAPBR=1,1https://stackoverflow.com/questions
Some steps I have found to work:
Use the Adafruit FONA library if possible
Before every HTTP request check whether GPRS is enabled
If GPRS is enabled, check whether you have been assigned an IP Address
If 2 and 3 are true, proceed to make the HTTP request. If not, try to reconnect to GPRS until 2 and 3 are true
Related
When I send a HTTP request (AT+HTTPACTION=0) with my SIM808 it sometimes does not response with +HTTPACTION: 0,200,2. My goal is to check whether the SIM808 is still waiting for the response or is ready to send another one. Another solution would be to cancel and forgot the request. I don't care if the data wont reach the server (I'm sending them every 15 seconds).
I don't want to check error code 604 (STACK BUSSY) hence it could bring errors into my code.
Now I wait 200 seconds (long enough to TCP/IP timeout) if the +HTTPACTION: 0,200,2 didn't come and after that I send another one request.
Summary:
How to cancel HTTP request
or How to check wheter the SIM808 is still waiting for the response.
Many thanks :-)
I want to set the Real Time Clock on my STM32F4 board that I use with a SIM800 modem. I try to send HTTP GET or HEAD request (for example to "google.com") and use the timestamp in the response header to set my RTC.
I can send the request and get the response but I can't read the response's header.
The code is use and the response:
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","www.google.com"
OK
AT+HTTPACTION=0
OK
+HTTPACTION: 0,302,256
AT+HTTPHEAD
ERROR
Why I got the ERROR at the end? I tried to send request to another URL, in this case I get HTTP OK(200) and can read data but still can't the header.
AT+HTTPHEAD doesn't work in sim800C. It works in: SIM800H,SIM800L,SIM800,SIM800G. Read "AT Command Manual" -
Only Part of Projects Support Following AT Commands.
+HTTPACTION: 0,302,256,
302 error is Found.
Check Mobile Balance or Internet Package in your sim.
It happens when you are out of Balance.
AT+CSTT="live.vodafone.com"$0D$0A OK
AT+CIPSHUT$0D$0A SHUT OK
AT+CIPMUX=0$0D$0A OK
AT+CLPORT="TCP",80$0D$0A OK
AT+CIICR$0D$0A OK
AT+CIPSTART="TCP","http://ph.mydomain.in",80$0D$0A OK CONNECT OK
AT+CIPSEND$0D$0A
GET /phreading.aspx?value=092016040804550815 HTTP/1.1$0D$0A
Host: http://www.ph.mydomain.in$0D$0A$0D$0A
$1A
than i get following error.
Please help me to solve this problem. and tell me the right sequence to send data on server correctly.
Try to use AT+HTTPPARA command to send your get request. Its much easier than using the CIPSEND method.
Connect to GPRS
AT+CGATT?
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","live.vodafone.com"
AT+SAPBR=3,1,"USER","APN_USERNAME" // adapt it to yours
AT+SAPBR=3,1,"PWD","APN_PASSWORD" // adapt it to yours
AT+SAPBR=1,1
SEND DATA USING HTTP GET
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","www.ph.mydomain.in//phreading.aspx?value=092016040804550815"
AT+HTTPACTION=0 // sends HTTP GET
AT+HTTPTERM // terminate HTTP request
AT+SAPBR=0,1 // disconnect gprs if required
Hope this helps..
I'm stumped with sending data to a remote server , I'm able to send a post request but not sure how to add data which is then received by the server.
I've went through the datasheet http://www.jarzebski.pl/datasheets/SIM900_https-121018-1.00.pdf
tried
# usual at+sapbr=1,1 set up
+HTTPINIT
+HTTPPARA = “CID”,1
+HTTPPARA="URL","IP-ADDRESS:PORT"
+httpdata=100,10000
# Where do I add the post data ?
+httpaction=1
which sends the http post request. But how do I add data - I've tried adding it to the url ?key=val but no joy - any help here will be appreciated
httpdata=100,10000 means that SIM800 should expect 100 bytes within 10 seconds.
This is how I accomplished this using the HTTP client:
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://url.com/endPoint"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPDATA=40,10000
At this point, the SIM800 should respond with "DOWNLOAD". Which means it's expecting your data. Send in your data; in my case:
{"location_id": 238, "fill_percent": 90}
Wait 10 seconds to send the rest of the commands. Then:
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM
That did it for me. Hope it helps.
This is where I got the information from: http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands
In the backend, using Python Flask, this is the code I used
#app.route('/reportTrashLevel', methods=['POST'])
def report_trash_level():
data = request.get_json()
database.insert_trash_level(data)
return Response(status=200)
I managed to get it to do what I need, this code-snippet will likely help others
AT+CGATT=1 # enter GPRS configuration mode
AT+CIPMUX=0 # Disable multi IP connection mode. Single IP cnxn only
AT+CSTT="APN","USER","PASS"
AT+CIICR # bring up wireless connection with GPRS and CSD
AT+CIFSR # ip up - gprs working
AT+CIPSHUT # Exit GPRS configuration mode
# Now do a post request to remote server api in json format.
# Change IP_ADDR|DOMAIN for the IP or domain name of your server.
# Change 2000 to its port
AT+CIPSTART="TCP","IP_ADDR|DOMAIN","2000"
AT+CIPSEND=119 # Num of char in tcp/ip data, \r & \n count as 1 char
POST /post HTTP/1.1
Host: **.**.***.***
Content-Type: application/json
Content-Length:23
{"postkey":"postvalue"}
Hope this helps the next person stuck on it.
I m trying to access a website using sim900 GSM module.
This is the list of commands
AT+CSQ
+CSQ: 16,0
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","www.google.com"
OK
AT+HTTPACTION=0
OK
+HTTPACTION:0,601,0
AT+HTTPACTION=0
OK
+HTTPACTION:0,601,0
Unable to access google. 601 code shows Network error.
How to get rid of this error?
You need to setup the connection to the bearer. Here are the minimum setup commands that have worked for me (based on trial/error and searching around on the internet).
AT+SAPBR=3,1,"APN","wap.cingular"
AT+SAPBR=1,1
The correct value for the APN may be different for you, depending on your network and service provider. I'm using AT&T prepaid SIM cards. Once that's working, then you can do the HTTP setup commands as you already have...
AT+HTTPINIT
AT+HTTPPARA="URL","http://www.google.com"
AT+HTTPACTION=0
Status codes above 600 (and some in the 500 range) are unassigned in the HTTP standard. In the AT command manual for the SIM908, status meanings are given in the notes on the HTTPACTION command:
600 Not HTTP PDU
601 Network Error
602 No memory
603 DNS Error
604 Stack Busy
You can query the bearer connection status of CID 1 with AT+SAPBR=2,1 and the related parameters with AT+SAPBR=4,1. You can also check that you're attached to the GPRS network with AT+CGATT?. If everything indicates that you are connected and you are still getting a 601 status code, then check that your service plan has data and that it hasn't run out. I have found that even when my account has a few hundred k of data showing on the balance that I start to get a 601 status until I add more data to my prepaid phone plan. If the SIM module has been on the whole time and you add more data, you'll need to close and re-open your connection (AT+SAPBR=0,1 followed by AT+SAPBR=1,1) and then your HTTP* commands will start working again without having to set the HTTPPARA settings again and without having to restart with HTTPINIT.
I have found that when an http call is made to an https only website it will throw a 601 error on the sim. Beware some sim devices have ssl and some don't. Use AT+HTTPSSL=? to interrogate. device with ssl will respond like, 'HTTPSSL 1'. If you get an error your device doesn't have ssl. This took some work with the factory for me to determine this.
You must also use to hit ssl site. I am using the wifi101 ssl client.
fona.setHTTPSRedirect(true);
dy3
I have encoutered this error as well. The cause of the problem may be that there is not enough money in the phone number account. You may check it.
601 is some custom implemented Error code.
Here is the list of standard HTTP Status codes
+HTTPACTION:0,601,0
The above AT response code (601) for HTTP session start indicates that
there is a network error. Then make sure that the PDP context is setup
properly.
source
https://m2msupport.net/m2msupport/at-command-for-http-functions-for-remote-server-data-access/
I have spent many hours with this module right now.
My experience is that when you dont get a 200 reply from remote server, you should check IP address to verify you are still on the network sendng a ping to a working server (AT+CIPPING="XX.XX.XX.XX").
If it succeeds: Try AT+SAPBR=2,1 and AT+CIFSR. You should get same address for both commands.
If you dont get same address, login again to the netword/service with AT+CIPCSGP=1, "yourapn.com", "user", "password".
If nothing works, power down the module. Wait a couple of minutes, and restart again.
Just in case someone is affected by this problem and stumbles on this post 4 years later: in my case the module had a small "sticker" type antenna and it got somehow damaged.
I could connect to the network but when I tried to use HTTP over the GPRS networks I only got return code 601 (network error) or 603 (failed to resolve DNS).
Once I replaced the antenna with a new one, everything worked perfectly.
Again, in case somebody has the same problem. In my case it was a typo in url:
AT+HTTPPARA="URL"," http://www.google.com"
Did you notice the space before http? For several hours, I didn't notice it too.
Usually after this command AT+SAPBR=3,1,"CONTYPE","GPRS" you enter your "APN", "USR" & "PWD" details also using SAPBR=3,1 etc. These details must match the SIM card / mobile phone provider.
Then it is recommended to check that your device has now received an IP address. Sometimes this is not straight away. Use AT+SAPBR=2,1 to query and this will return your IP address which you should check for confirmation.
Once you have IP address you can enter AT+HTTPINIT, AT+HTTPPARA="CID",1 etc.
Now to use GET you have to include a "?" after the URL to provide your php script with a key=value pairing.
Thus in your case it is something like, AT+HTTPPARA="URL","http://<Public_Ip_Address>:8080/folder/savedata.php?A=1001" where A is the key and 1001 is the value.
Now send the AT+HTTPACTION=0 and you should get a +HTTPACTION: 0,200,1000 response where 200 is the OK and 1000 is the payload size. AT+HTTPREAD will allow you to read the response if it is required.
Change URL. 601 is a URL has been moved. Is a redirect.