SIM 800C GPRS communication with server

Hello,
Below is the sequence of commands that i have implemented in software for GSM 800C module acting as client.
I am trying communicate between server and GSM.(the data im receiving is plain text)
AT+CFUN=1
OK
AT+CSTT=“airtelgprs”
OK
AT+CIICR
OK
AT+CIFSR
Local IP
AT+CIPSTART=“TCP”,“IP”,PORTNUMBER
OK
CONNECT OK
AT+CIPSEND

after that i am checking uart interrupt for incoming data from server.

I am using hercules as a means to send data to GSM. I am receiving message sent through hercules in the terminal.

the issue is i am able to send or recieve data only for short period of time. after that it is going to hang state and does not respond to any commands or received messages.

is there anything wrong in command sequence or did i miss any commands?

how to have stable communcication between server and GSM for longer periods.

Thanks in advance

I am using hercules to listen to the port and send data.

Hello and welcome!

What is this hercules you speak of? Is it a software, hardware…?

Usually the connection is ended by the server, as the usual use case tends to dispatch every client as soon as possible in order to attend other clients. Server configuration is a hole topic onto itself, so I recommend you to check in some other more specialized forum.

But consider the following: usually it is preferable to keep the connections as short as possible, because you are using a lot more power when you have an open connection, and you need to implement a “re-connection” logic to your firmware anyways, as connections aren’t guaranteed to be 100% stable. Furthermore, it will help you with the scalability of the server side, as there are more and cheaper options that handle a limited amount of simultaneous connections.

As a final recomendation, if your messages can be easily sent as some HTTP GET or POST requests, the SIM800 has a whole different interface for that which is much simpler and stable to use. Check the commands on the AT Commnad Manual starting at page 256, section “11 AT Commands for HTTP Application”

1 Like

Hello Viedana,

Thanks you for the response and your time.

I am using HTTP commands as you suggested. Below is the sequence in which i am sending commands.

at
OK
at+sapbr=3,1,“Contype”,“GPRS”

OK
at+sapbr=3,1,“APN”,“airtelgprs.com

OK
at+sapbr=1,1

OK
at+sapbr=2,1

+SAPBR: 1,1,“100.89.145.234”

OK
at+httpinit

OK
at+httppara=“PROIP”,“202.56.231.117”

OK
at+httppara=“PROPORT”,“8080”

OK
at+httppara=“CID”,1

OK
at+httppara=“URL”,“http://www.m2msupport.net/m2msupport/test.php

OK
at+httpaction=0

OK

+HTTPACTION: 0,601,0

I was getting a dns error so with some searching, i found out in an arduino forum to add the proxy IP and port to get rid of DNS resolution error. It worked.

But I am getting 601(Network error) which im not able to fix.
Kindly let me know what could be done.

Thanks

Have just checked here with a SIM800l module, following what you typed here (but without the proxy settings) I get a 200 response from the server and receive the “test” string without problems. Things to check:

  • Have you save or change some configuration on your SIM800? I’m just using default factory configuration.
  • Is your LED light from the module blinking rapidly after you receive the OK from the AT+SAPBR=1,1 command?
  • Do you have a 2A power supply feeding the module? How are you powering it?

Hi viedana

  • I have not changed any configurations to sim800c.
  • The module does not have any LED’s to check blinking after sapbr=1,1.
  • The module is connected to a controller board and is drawing power from the board

i am able to get message responses correctly using at commands so i doubt it to be a power issue. The signal strength is between 10 to 15.
i have attached an image of the module.

I am currently using Airtel sim.

Should I establish any specifc PDP context before using HTTP commands?

Not that I’m aware of. But if you can try with different providers, It wouldn’t hurt. Also, what kind of plan do your sim has? What usually works best is to use the ones only configured for data transmission and no voice/sms functionality (if that works for your project). Otherwise, you might need to configure things depending on your provider. If you put that sim on a cellphone, do you need to do something extra besides turning on your data in order to use the internet?

In regards to the power issue, that board has a worrisome lack of beefy capacitors around the SIM800, maybe it has some on the backside? If you check most SIM800 “modules” or prefabbed PCBs, they have at least one big tantalum (yellow/orange or sometimes black) capacitor right next to the chip. And the controller board and its corresponding power supply are unknown, so there is no way of knowing how well do they deal with the power needs of the chip. It’s probably ok, but it would be nice to discard any problems and be sure.

It does have 2 big capacitors on the back of the PCB. the controller is a freescale kinetis processor. and the whole thing is powered by a 7.4V battery.

For now I will check with other network providers and see if there is any luck. will update then.

thanks for the reply.

Ok! power seems quite good. It might be something to do with the sim card then, as everything on the software side also seems very clearly ok.

In order to help you discard problems with the sim card, you can try calling the number and see if you get a Unsolicited Response on your serial terminal informing you of this; or even trying to read a SMS message (which is a little more involved).

hi @viedana, i got it to work. thank you for the support.
strangely, I had to add the content type field using HTTPPARA for it to work which i have not seen anywhere in the command sequence.
below is the sequence for anyone facing the same issue.

at+sapbr=3,1,“Contype”,“GPRS”
OK

at+sapbr=3,1,“APN”,“airtelgprs”
OK

at+sapbr=1,1
OK

at+sapbr=2,1
+SAPBR: 1,1,“100.124.79.222” OK

at+httpinit
OK

at+httppara=“CONTENT”,“text/plain; charset=UTF-8”
OK

at+httppara=“CID”,1
OK

at+httppara=“URL”,“http://ptsv2.com/t/6msqn-1576062108/post
OK

at+httpaction=0
OK
+HTTPACTION: 0,200,20

at+httpread
+HTTPREAD: 20
have a wonderful day
OK

I have one more question: Even with HTTP, few minutes after which the module does not respond to at commands. Is this an issue with SIM800C? because my requirement is to print data received from the server continuosly.

Thanks.

Congrats! Hmmm, that you had to specify the Content-type is probably a requirement of the server, for what is worth.

When you say that the module does not respond to AT commands, what behavior are you seeing? I have a hundred modules working autonomously for months receiving and sending data with the HTTP interface without problems, so it’s definitively not an issue with the SIM800 in general.

Things to check:

  • Is your network connection still working? A sudden connection might brake the logic of your software if not handled properly.
  • Have you maybe received too long of a response from the server? This might overflow the receive buffer of the SIM800, which is shared with the send buffer; so overflows make the SIM800 send wrong responses, but usually it still reads AT commands ok.
  • Are you waiting proper times after each command? The AT manual has estimations, but you’ll usually need to adjust the times a bit in some cases to improve stability.