GSM/GPRS modems are getting very common these days, as prices are getting cheaper and cheaper. Apart from providing SMS and call functions to my projects I also wanted to communicate via TCP.
Although there are many documents and blog posts to help but I have always found that they either are answers to specific problem faced by someone or not providing complete details. In this post I would first explain the AT commands used in brief. You may connect your SIM900 to your computer via a serial/usb and test these commands. In the later part of this post I would include arduino example code.
AT commands for TCP/UDP Connection with example response and a brief description are given in the table below. Refer to the AT commands manual of your modem for details
AT command | Response | Description |
AT | OK | test command. reply is OK |
AT+CGATT? | +CGATT:n | checks if GPRS is attached? n=1 if attached |
AT+CIPMUX=n | OK | use n as 0 for single connection or use 1 for multiple connections |
AT+CSTT=”apn”,”username”,”pass” | OK | Sets APN, user name and password |
AT+CIICR | OK | Brings up wireless connection |
AT+CIFSR | ip address | Get local IP address if connected |
AT+CIPSTART=“TYPE” , “domain”, “port” | Connected | Establishes a connection with a server. Type can be UDP or TCP |
AT+CIPSEND | > | Sends data when the a connection is established. |
AT+CIPCLOSE | OK | Closes the connection |
AT+CIPSHUT | SHUT OK | resets IP session if any |
how to make a connection:
- Send ATr and wait for a response from the modem. You should recieve OK
if everything is set. - Make sure that the Modem has registered to network and that PIN code is disabled on the SIM. Send AT+CGATT?r to check if GPRS is attached or not. +CGATT: 1 indicates that GPRS is attached.
- Send AT+CIPSHUTr . Although its optional this will be helpful as it resets IP session if any. you will get a response SHUT OK .
- Send AT+CIPMUX=0 to set a single connection mode, response would be OK
- Now set APN settings by AT+CSTT= “apn ”, “username”, “password”r . replace apn, username and password to match APN (Access Point Name) ,username and password for your service provider.
- Now send AT+CIICRr , this will bring up the wireless connection. OK is received on successful connection
- Send AT+CIFSRr , this will reply with the IP address the modem has been assigned.
- Send AT+CIPSTART=”TCP”,”server domain name or ip”,”port”r, replace the domain name/ip and port with appropriate values, on connection modem will reply with CONNECT OK
- Now you can send your data using AT+CIPSENDr AT command. modem will respond with > indicating it is ready to receive data to be sent. Type in your data.
- Now the modem is waiting for the ASCII 26 that is control+z on keyboard. Depending on the terminal software used you can either press control and Z together on keyboard or send hex value 0x1A. The modem will then send the response from server.
- Now send AT+CIPSHUT to shut down the connection. Modem will reply with SHUT OK
- cheers 🙂
ARDUINO CODE :
Below is example code for single and multiple connection using arduino and sim900
int8_t answer; int onModulePin= 2; char aux_str[50]; char ip_data[40]="Test string from GPRS shieldrn"; void setup(){ pinMode(onModulePin, OUTPUT); Serial.begin(115200); Serial.println("Starting..."); power_on(); delay(3000); // sets the PIN code sendATcommand2("AT+CPIN=****", "OK", "ERROR", 2000); delay(3000); Serial.println("Connecting to the network..."); while( sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 1000)== 0 ); } void loop(){ // Selects Single-connection mode if (sendATcommand2("AT+CIPMUX=0", "OK", "ERROR", 1000) == 1) { // Waits for status IP INITIAL while(sendATcommand2("AT+CIPSTATUS", "INITIAL", "", 500) == 0 ); delay(5000); // Sets the APN, user name and password if (sendATcommand2("AT+CSTT="APN","user_name","password"", "OK", "ERROR", 30000) == 1) { // Waits for status IP START while(sendATcommand2("AT+CIPSTATUS", "START", "", 500) == 0 ); delay(5000); // Brings Up Wireless Connection if (sendATcommand2("AT+CIICR", "OK", "ERROR", 30000) == 1) { // Waits for status IP GPRSACT while(sendATcommand2("AT+CIPSTATUS", "GPRSACT", "", 500) == 0 ); delay(5000); // Gets Local IP Address if (sendATcommand2("AT+CIFSR", ".", "ERROR", 10000) == 1) { // Waits for status IP STATUS while(sendATcommand2("AT+CIPSTATUS", "IP STATUS", "", 500) == 0 ); delay(5000); Serial.println("Openning TCP"); // Opens a TCP socket if (sendATcommand2("AT+CIPSTART="TCP","IP_address","port"", "CONNECT OK", "CONNECT FAIL", 30000) == 1) { Serial.println("Connected"); // Sends some data to the TCP socket sprintf(aux_str,"AT+CIPSEND=%d", strlen(ip_data)); if (sendATcommand2(aux_str, ">", "ERROR", 10000) == 1) { sendATcommand2(ip_data, "SEND OK", "ERROR", 10000); } // Closes the socket sendATcommand2("AT+CIPCLOSE", "CLOSE OK", "ERROR", 10000); } else { Serial.println("Error openning the connection"); } } else { Serial.println("Error getting the IP address"); } } else { Serial.println("Error bring up wireless connection"); } } else { Serial.println("Error setting the APN"); } } else { Serial.println("Error setting the single connection"); } sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000); delay(10000); } void power_on(){ uint8_t answer=0; // checks if the module is started answer = sendATcommand2("AT", "OK", "OK", 2000); if (answer == 0) { // power on pulse digitalWrite(onModulePin,HIGH); delay(3000); digitalWrite(onModulePin,LOW); // waits for an answer from the module while(answer == 0){ // Send AT every two seconds and wait for the answer answer = sendATcommand2("AT", "OK", "OK", 2000); } } } int8_t sendATcommand2(char* ATcommand, char* expected_answer1, char* expected_answer2, unsigned int timeout){ uint8_t x=0, answer=0; char response[100]; unsigned long previous; memset(response, ' ', 100); // Initialize the string delay(100); while( Serial.available() > 0) Serial.read(); // Clean the input buffer Serial.println(ATcommand); // Send the AT command x = 0; previous = millis(); // this loop waits for the answer do{ // if there are data in the UART input buffer, reads it and checks for the asnwer if(Serial.available() != 0){ response[x] = Serial.read(); x++; // check if the desired answer 1 is in the response of the module if (strstr(response, expected_answer1) != NULL) { answer = 1; } // check if the desired answer 2 is in the response of the module else if (strstr(response, expected_answer2) != NULL) { answer = 2; } } } // Waits for the asnwer with time out while((answer == 0) && ((millis() - previous) < timeout)); return answer; }
int8_t answer; int onModulePin= 2; char aux_str[50]; char ip_data[40]="Test string from GPRS shieldrn"; void setup(){ pinMode(onModulePin, OUTPUT); Serial.begin(115200); Serial.println("Starting..."); power_on(); delay(3000); // sets the PIN code sendATcommand2("AT+CPIN=****", "OK", "ERROR", 2000); delay(3000); Serial.println("Connecting to the network..."); while( sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 1000) == 0 ); } void loop(){ // Selects Multi-connection mode if (sendATcommand2("AT+CIPMUX=1", "OK", "ERROR", 1000) == 1) { // Waits for status IP INITIAL while(sendATcommand2("AT+CIPSTATUS", "INITIAL", "", 500) == 0 ); delay(5000); // Sets the APN, user name and password if (sendATcommand2("AT+CSTT="APN","user_name","password"", "OK", "ERROR", 30000) == 1) { // Waits for status IP START while(sendATcommand2("AT+CIPSTATUS", "START", "", 500) == 0 ); delay(5000); // Brings Up Wireless Connection if (sendATcommand2("AT+CIICR", "OK", "ERROR", 30000) == 1) { // Waits for status IP GPRSACT while(sendATcommand2("AT+CIPSTATUS", "GPRSACT", "", 500) == 0 ); delay(5000); // Gets Local IP Address if (sendATcommand2("AT+CIFSR", ".", "ERROR", 10000) == 1) { // Waits for status IP STATUS while(sendATcommand2("AT+CIPSTATUS", "IP STATUS", "", 500) == 0 ); delay(5000); Serial.println("Openning TCP"); // Opens a TCP socket with connection 1 if (sendATcommand2("AT+CIPSTART=1,"TCP","IP_address","port"", "CONNECT OK", "CONNECT FAIL", 30000) == 1) { Serial.println("Connected"); // Sends some data to the TCP socket sprintf(aux_str,"AT+CIPSEND=1,%d", strlen(ip_data)); if (sendATcommand2(aux_str, ">", "ERROR", 10000) == 1) { delay(500); sendATcommand2(ip_data, "SEND OK", "ERROR", 10000); } // Closes the socket sendATcommand2("AT+CIPCLOSE=1", "CLOSE OK", "ERROR", 10000); } else { Serial.println("Error openning the connection 1"); } } else { Serial.println("Error getting the IP address"); } } else { Serial.println("Error bring up wireless connection"); } } else { Serial.println("Error setting the APN"); } } else { Serial.println("Error setting the multi-connection"); } sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000); delay(10000); } void power_on(){ uint8_t answer=0; // checks if the module is started answer = sendATcommand2("AT", "OK", "OK", 2000); if (answer == 0) { // power on pulse digitalWrite(onModulePin,HIGH); delay(3000); digitalWrite(onModulePin,LOW); // waits for an answer from the module while(answer == 0){ // Send AT every two seconds and wait for the answer answer = sendATcommand2("AT", "OK", "OK", 2000); } } } int8_t sendATcommand2(char* ATcommand, char* expected_answer1, char* expected_answer2, unsigned int timeout){ uint8_t x=0, answer=0; char response[100]; unsigned long previous; memset(response, ' ', 100); // Initialize the string delay(100); while( Serial.available() > 0) Serial.read(); // Clean the input buffer Serial.println(ATcommand); // Send the AT command x = 0; previous = millis(); // this loop waits for the answer do{ // if there are data in the UART input buffer, reads it and checks for the asnwer if(Serial.available() != 0){ response[x] = Serial.read(); x++; // check if the desired answer 1 is in the response of the module if (strstr(response, expected_answer1) != NULL) { answer = 1; } // check if the desired answer 2 is in the response of the module else if (strstr(response, expected_answer2) != NULL) { answer = 2; } } } // Waits for the asnwer with time out while((answer == 0) && ((millis() - previous) < timeout)); return answer; }
is there any way to maintain continuous reception of msgs from server by making sim 800c as client. in my case, module is hanging after 5 msgs received from server
you have to keep the connection open by sending some ping requests.
Hello
the code posted in this topic doesn’t have the declaration of the sim gsm module, so when i upload it i just keep getting “AT” in the serial monitor.
i’ve added:
#include
SoftwareSerial gprs(10,11);//TX,RX
and in the setup:
gprs.begin(9600);
and in the loop:
if(gprs.available()){
Serial.write(gprs.read());
}
if(Serial.available()){
gprs.write(Serial.read());
}
but i still can’t get any answers, i just get “AT”
i hope that you post the entire code, or help making it.
Hi using sim800c need to send 4000 bytes through tcp ip to server but limit exceed 1460 showing server same wismo modem work on them but now outdated how can i go up to 4000 bytes
Try FTP
I am using sim800c and when I am trying to connect to internet using command AT+CGATT? it shows 0. what might be the problem? And once its done will I be able to use this existing GPRS connection for different tasks? or do we need to do the entire setup again?
CGATT will result in 1 only when the module has attached to GPRS. Seems it haven’t!
thanks for sharing, can gsm moodule communication with websocket?, thanks
have a look at this https://github.com/adik/webgsmcontrol
hazrat, tussi great,
will be working with SIM800 soon.
bookmarking your page.
keep up the good work.
Thanks Ali.
i made all steps of sending gprs packet to anther gprs modem very well. and when reaching to command of start connection at+cipstart , the command will be connect fail after 75 seconds.
and if i make a ping from my pc to this ip , cipstart will be responded by connect ok.
and then if i shutdown and reconnect again , all thing will be ok
so what is the reason of it ? Is it form the network?
why did it work when pinging the ip only for the first time ?
Can you send the sequence
Hello sir,
Is it possible to send binary data over tcp/ip using gsm/gprs AT commands?
If yes what command needs to be used?
Thankyou.
I THINK THIS WILL NOT WORK
dear Dost Muhammad Shah,
i am using gsm\gprs A7 with arduino.
now I manage to send out string form data packet (etc:”Hello server!”) to the server,
but I still failed to send out raw data packet (non-string data).
is there any restriction to the type of data that can be sent using tcp over gsm/gprs?
Thank you.
HTTP will work with strings only. You can encode your data in json and hence at the receiving side you can extract it with the correct type
hai sir,iam working on gsm sim900 and i want to set time delay for every 15minutes to check the hardware connection is alive or not.for every 15 minutes it should check the connection can you please help me out
what do you mean by “hardware connection is alive or not” do you mean internet connection?
i get error when i send AT+CGATT=1 for TCP connection over GPRS using SIM900A
ps: GSM WORK FINE FOR ME
What is the response of AT+CGATT?
always 0
Did you try with another simcard from different network privider?
i tested with 3 different sim card ,and give the same result , and i flashed with another firmware(sim900) and nothing
i have doubt about is that any sim 900 gsm/gprs module to setup the GPRS connection time gap need between one AT Commands other in Ardunio , is that really required are not, clarify to me for this issue
I DIDNT GET WHAT U WANT TO SAY
Dear,
You have to add a sequence in order to send the data
using
AT+CIPSEND
command after entering it,wait for> and send GET /XXXXXXXX after this,
send
this makes the data to be sent to website successfully
by prompting the response with the number of times
the data being sent to that website
Hi Sir,
I was sending message using GSM module, it was working fine,
after connecting to the internet and sending some data to internet (this also worked fine )
the same message command which I was using earlier is not working. the message is getting send to the SIM as sim message with no content.
the function I am using to send a message is
it was working very well before connecting to the internet
After the AT+CMGS command either increases the delay or wait for the > character in the modem.
i have done that earlier and i have even waited for “>” and then sent the message.
When you wait for > it should work
it works well with one mobile operator and sends sim message with another operator
it started working the command that was required was
AT+CSMP=17,167,0,0
Hi mr. shah,
I keep getting
“+cme error: 53”
. Could you please help me..??Please check the at command manual
Thanks for replying… AT+CIPSEND it’s giving > symbol after that I m passing my values and I typed ctr+z it’s giving Okay… So my doubt is (my values where it’s going) I know
hi dost shah, i am using sim900a and i need to use gprs, i should send some data to my website ,can u give me basic code. this my mail id santhoshappy92@gmail.com
I am working with sim808 and arduino . I am sending AT commands to sim808 for getting gnss data then parsing it using arduino and again sending longitude and latitude to websocket server how should I do that?
Please let me know the part where you are facing the problem.
I am not able to connect websocket server the entire thing works fine with socket test application
Working Good, Great Article
Thanks,
Siva
Hi! This is a brilliant blog and comments make it even better. I am using SIM808 for a vehicle tracking system. I am faced by 2 constraints.
First, I cannot upload a packet of more than 255 bytes.
Second, the port is automatically Closed after a successful CIPSEND. So I have to do CIPSTART every cycle.
These 2 constraints induce a very tough situation in which I can only send small packets to server, that also not continuously but a gap of 30-40 seconds! What could be the possible solutions?
I want to receive data from server, after send, could you help me?
Hello
I saw the Mqtt code in RMAP -> Arduino. It is working when I connect module to Serail1. But it does not work when I connect it to Software Serial or the normal Serial.
Can you tell me the changes
I have to go through the code… There is an option to select the serial port…
How to implement these commmans in ardunio??help me
Please go through the code snippets provided in the post!
hy, is there a way to send a zero length packet? this would be useful to check the connection health, i dont like to send “keep alive” messages…
I haven’t tried. I usually use one byte Ping messages as keep alive messages!
Hi, i am traying to implement a tcp connection. I need to keep open the connection all the time, and some time my SIM800L give me a CLOSED message. The TCP connection have a timeout by default? how i can keep open 1 tcp connection, without lost this connection? Thanks a lot.
Servers and Clients implement a keep alive mechanism for this by deciding upon a keep alive interval. The server will usually waits 1.5 times the keep alive interval and if it didn’t receive any thing from the client, disconnects. The client will send a one byte message (Ping message) within that keep alive interval.
Hi, I need to ask this. Have you ever used that module as a tcp server? I’m trying to do that but I got a problem, when a client disconnects from the module, It can’t reconnects again for like a half hour, even tho the module says it’s disconnected from the client and his ip state is “server listening”. I have browsed thru the documentación but I haven’t found the answer. I will apreciate if you can point me in any direction
The issue is due to Natting.
Thanks for your answer.
I should had specified that I’m doing my tests using a TCP “raw” connexion between the gsm module and a “TCP/IP Client Server terminal” named “HERCULES”.
I believed that the connexion-desconnexion messages and ack between client and server was solved by the module and the “teminal software” on their aplication layer.
I had used “hercules” before for testing TCP sockets aplications in linux and never had a problem like this.
Now, do you know how can i figure out the NAT protocol if there’s any implemented by this module in order to make my terminal compatible with it?
Many thanks in advance
Dost Muhammad Shah
Hi Friend!
Im was doing some similar like you program, i want to send some information to server TCP/IP (SOCKET)
i ready can send my information. but i want to turn on some led to know if my shield (arduino uno) get the conection with the server. ¿How to read the word “CONECT OK” before the command AT [[AT+CIPSTART]] and turn on the led with this confirmation?? … thanks for you help .
You need to parse the responses. An easier way is to add your logic to switch on the led near the line
Salam
can use MQTT in sim900a Possible or no?
Simcom only offers MQTT AT Commands in 3G modules or may be in LTE as well. For sim900 you need to implement it in your microcontroller or in EAT
Thank you Man
can you post an exemple for MQTT impemented for a
microcontroller please
Search for rmap arduino on github
Thank you, I searched for rmap arduino but nothing found.https://github.com/search?utf8=%E2%9C%93&q=rmap+arduino
I am struggling to use MQTT over SIM900A. If that does not work, my SIM900A module will become useless 🙁
As you said, how can I implement MQTT commands in Arduino ?
This is the link https://github.com/r-map/rmap/tree/master/arduino
Assalamualaikum,
It is great that you release good informative videos which help many over the internet.
Actually I would like to know how I can implement FOTA (Firmware update over the Air) for Pic micro controller with GSM kit.
please advise.
You would require to download the new firmware file using gsm module to its flash memory and then implement a bootloader like the arduino has to start the flashing process.
Thanks for the quick response. Kindly help me out some details.
Hi….Actually I am working on arduino based project.
And I want to send the temperature sensor data at web server from gsm module900A interfaced with arduino uno. I didn’t find any helpful code on internet, all I found was using gsm shield which I don’t want to use. Can you please help me in this as I also want to keep sensor data updated on server.
GSM shield is an easy way to connect sim900/sim900A or any other gsm module with an arduino. You just need to wire rx/tx and few more wires to arduino and you are done as most of your work is with AT commands.
Hi Shah, about data connection status, I think SIM900 has a firmware bug. Several times a TCP connection stops passing data without notice, both on server side and client side. The SIM900 in client mode reports (CIPSTATUS) CONNECTED but doesn’t receive any data sent by the server. The server also reports connected. SIM900 can stay in this state for hours. If I tell SIM900 to close the TCP connection and connect again, it resumes receiving data for some time. It seems there is an inactivity timeout somewhere that breaks the link but doesn’t disconnect the TCP link when there is no data flowing for some time. Have you seen this behavior? Thanks.
Servers and clients implement a keep alive mechanism where the connection is closed if there is no activity for 1.5 times the amount of keep alive interval. The client needs to send a ping or small packet within this time.
Thanks for this detailed doc. But incase if we need to receive data using TCP/IP, then is there any command for that? suppose i need to receive a data over TCP/IP and depending on that i need to send response back. How do i do that? please help. Thanks in advance
You will have to setup your module as a server
Ok, Let me try. I will get back after that. Thanks so much
Hi, I checked and its a whole new headache to change my device to server mode. ie my device has to switch between server and client mode after every 10 sec. So is there a way to receive data from remote server while my SIm900 is in client mode itself? Please help
No
hey i have sim808 and i need to connect it with google SUPL server.What else do i hve to apart from what’s given above ?
What are the requirements to connect to SUPL server?
I need A-Gps for assistantace of ephemeris data which can be fed to already present gps reciever .So require a periodic retrieval of ephimeris data.Supl client has to be ensembled with sim 808 module .Hey i m a beginner with this so apologies if i m wrong smwhere.
It’s required to send and retrieve data using TCP /IP
I have no idea of supl server anf have not worked with them. If you need to get some data using TCP you can achieve that easily.
How are you configuring server client(user agent) on an ardunio which sends and retrieve data frm any server over Tcp connection?
Can we perform two way communication using sim900. That is will it possible to send data to a server via TCP using sim900 and to receive data from the server ung TCP via sim900…
Hey, I too am working where requirement is to receiving data from Server using TCP via Sim900. Is it possible? If so then please help me doing that. Thanks
Hey man,
I need your help to solve the problem of receiving nothing. Could you please check my code if there are something wrong?
There are two possible results:
1.
AT+CIPSEND is error
�
2.
AT+CIPSEND is OK
but receive nothing.
Which library are you using to enable the communication between arduino and sim900 shield?
No special library has been used. Simple Serial.read and print functions are used. Go through the code to understand it
Hello sir,
I am working on Sim900 for last 3 months. Can you please tell me the error handling cases in AT Command Sequence for initializing SM900 as a TCP Client Module.
Errors while trying to initialize or while in communication?
I am trying to send a message to my domain name on port 8080 using AT+CIPSTART=“TYPE” , “domain”, “port”. I don’t know how can I retrieve this message/ see this message on my website. Could you please help me in this?
As I explained in the email its easier to use the HTTP commands and use GET/POST requests done although you can create a get and post request by the method you used. See this post.
Hello, I want to inquire that if i dont send the command “AT+CIPSHUT” and continue trnsmitting data to the same server with just writing “AT+CIPSEND” ,once after the TCP connection is established. Is it possible?
hey, r u listening?
Sorry … was busy in other stuff couldn’t give time to the blog
It is possible but you have to make sure that the connection is alive.
dear mr.shah we are having a problem connecting the arduino to thingspeak which is iot website .
our problem is writing the code but we have no experience in arduino programming ,we already have the code for the sensors (gas sensors) but we need to combine it with the thingspeak code that only supports wifi and ethernet …..any suggestions please …much respect
if you share your code I would be able to better understand your problem
hi, I need to know that code should be written in gettempdata.php plz
test is your database ?
thx for all
I didn’t get what you need?
i need file: gettempdata.php sorry for my english I need to send two variables with sim900 to MySQL
Do you mean you need to make a get request to a file named
gettempdata.php
on the server?Yes, I need to send two variables by AT commands from the SIM900 to wampserver (mysql) and does not work,
I have to add is the gettemdata.php file in the C:wamp/www, I need the code gettempdata.php
You have to do it yourself or ask someone to do it for you… Wamp server will only be accessable if you do port forwarding from your router and have a fix ip or a ddns setup…
Hi Dost, great articles. Do you have a similar type “how to” article for http?
Hi
Is it possible, sending real time data over tcp connection using AT+CIPSEND? for example sending voice data after sampling!
You may give it a try…
Hi, Could you please help on my query.
Hi, i am failing with CIPSTART command.i actually tried my server and client codes directly in multiple systems and there is no issue with server/client code.
below is the command i am giving after getting IP address.
at+cipstart=”tcp”,”server ip”,”port”
the above command giving me result as TCP closed.
Hai i need a small help from you.I need to control the device from web server how to read the data from web server using by using SIM900 AT commands. Please get me back.
You need to create a page which the Modem will read and get to know what it has to do..
Hai DMS
thanks for your reply.I already created a web page.Now my doubt is what are the AT commands we have to read the data from server to SIM900 modem to control the device.
EX: I need to turn ON and OFF the LED from the Web server.I connected this LED to the micro controller and i interfaced GPRS modem to my micro controller.
follow this https://www.youtube.com/watch?v=bDBOlcELNLA
it not the professional way to do it as it will need continuous data communications.
The recommended way is to use an IoT platform like MQTT.
Hi,
I am able to send the UDP packet to the server but I am not receiving the UDP packets for the Server.
I am using SIM 900 module with FreeeScale Controller ?
Does ISP blocks the incoming UDP connections and I need the hole punching server to establish 2 way communication over UDP ?
How do I establish 2 Way communication over UDP ?
Thanks and Regards
Sachin
Hello Dost Muhammad
Could you please let me know what could be the issue ?
you can setup your sim900 as a server or as client, but in one configuration at a time.
For incoming connections you must set it as server!
i have error with AT+HTTPINIT and AT+CIPMUX=0 or AT+CIPMUX=1 !!!
give details please!
There can be a number of issues…
problem is resolved,
if i open Flash Data Buffer with AT+CFSINIT i can not initialize http service, must be Free the Flash Buffer with AT+CFSTERM before use http service.
Great!
Thanks a lot for sharing the cause and solution. It will help many people!!
Hi Mr Shah,
should there be a library for these codes? they don’t compile for me. using arduino ide 1.55 and I get an errors from mismatching brackets ) before APN to unknow source headers. Does anyone have these codes working? Thanks.
I have this error also and I don’t understand why unfortunately.
Has anyone fixed it?
Many thanks.
I will check them and let you know!
Hello again,
I’d like to use your routines to send a text file, or the contents of a text file, to a server.
Will this be possible using your two routines – this one and the next?
And, will it be possible to send the entire file as one action or will I need to read the file a character at a time and send each character to the remote server?
I’ve been pulling my hair out trying to solve this problem and being a relatively new starter to Arduino am finding it difficult to understand all the possibilities. Your routines seem to fit the bill.
Regards.
mr dost shah i have one problem in apn for simcom 900.i am in saudi arabia using stc sim card this modem i am using in vending machine from russia i tried stc apn but its not connect the admin in russia.can u help me how to connect
can you connect to intrnet?
you have to use the apn , username and password for your network provider
Hi, I finally got the POST method working using the TCP connection, my question is you do you keep the connection alive, I need to send data(make post) at 30s interval. but the connection closes inbetween, what is the best way to reconnect it.
thanks!
I am not sure what is the best way… what I do is :
Hi, I tried to POST for many days unsuccesfully, only GET work. Can you help me with a bit of working code to use POST?
Many thanks
Hi, try this example code
When I send data to my server I get SEND OK then it closes the socket with and data is never recived by the server. Any help would be great.
have you tried sending data to the same server from pc with same request?
When I send data to my server I get SEND OK then it closes. The server is not receiving the data and I have tried sending data to the same server from pc with same request and it works. I am sending the data to the thingspeak website using the GET method like
GET /update?api_key=VXVCDQ3MST4FZEN3&field2=30.9254&field3=80.6746&headers=false
Please share your complete code for the request
As you can see the send ok command is displayed after i sent the data, but the data does not appear on the destination ip address.
Hi,
SEND OK
means that the data was sent. It doesn’t imply that the request was correctly made or not. Please follow this post to know how to send a get requestdear Dost Muhammad Shah,
iam using gsm\gprs sim900 module with raspberrypi2
i was successfully establish tcp connection socket was running successfully client connect but iam unable to post the data by using AT+CIPSEND i got ‘>’ in sim900 pdf type some thing ctrl+Z after some time nothing will be posted can u tell me how we have to send the data using that AT command and step by step
Hi, Can you share your code?
Dear Dost Muhammad Shah,
1.What happens when we give the time(time.sleep(0.5)) delay in one AT-command to another AT-Command
2.Is that really required from each other can you explain clearly
3.I was tested without time delay(time.sleep) to start to end but unable communicate errors will accured
4.Can u send GET method AT-commands for Ardunio are raspberrypi
1 & 2 –> please note that you have to send a command and wait for the response and then act accordingly, In your code what you are doing is essentially just sending command after command with a small delay and not considering what was the reply. Although this might work but its not guaranteed to work.
3 –> every command might take some time to process which you are not considering and sending the next command.
4 –> I suggest to use a library for sim800/900 for arduino and raspberry pi , these days well developed libraries are available for both the platforms and are very reliable. As far as the AT-commands for GET method please refer to the content of this post!
If I want to send a text message to another GSM/GPRS module via GPRS, then if I replace “Ip_address” with the IP address of the receiving module, will it be receive there? or do I have do something other?
You need to understand how a client and server works together… The server needs to listen on a port for incoming data.
ya definitely it will receive . but this will happen only at that instance only.
because the IP address you get for the GPRS/gsm module everytime you restart the device is different. it is dynamic . so you better find a better solution . or else make a broker between both , so that you can get the updated IP address every time you need.
I hope this will solve you issue.
Mahender verma
mahender@uniolabs.com
#uniolabs
thanks for the information
Welcome dear!