Connect to a TCP server by using only a GSP/GPRS module.

Hi friends! Embedded is just like to play with hardware, means fun. I am writing this post to share a very common method to connect to TCP server.

Now start with hardware requirement.

  1. We need a GSM/GPRS module with USB/RS232 interface
  2. Power adapter, 12v 1 amp.
  3. One USB/RS232 cable as per your module.
  4. It is understood that you have a Laptop/PC with one free USB port.
  5. working SIM card


  1. You may need USB to Serial converter which is easily available on Internet.
  2. A software to communicate with serial port i.e. hyperterminal(recommanded).

Now time to connect to TCP server by following step by step procedure which is given below-
first of all insert SIM card in module.
1. connect GSM/GPRS module to adapter.
2. Connect GSM/GPRS module to PC with USB cable.
3. Now you will find a new COM port in your PC.
4. Now run hyper terminal and connect with that new COM port with default setting.
5. You can set default setting yourself i.e. boud rate-9600, data bit-8, parity bit-None, stop bit-None.
6. Now time to use AT command which always give a response as I wrote below.

7. AT    response       OK       
 // OK means module is working correctly
8. AT+CPIN?   response       OK  READY
//If you have no pin lock on sim other wise you will get another message and  have to enter next command first for further processing
9. AT=CPIN=XXXX response     OK   REDAY
//xxxx is your pin number. default is 1234.
10. AT+COPS?    response     OK    VODAFONE IN
// this gives  information about your operator.
11. AT+CREG?    response   +CREG: 0,1   OK    
//   your device is registered in home network.
12. AT+CGACT?    response  +CGACT: 3,0    OK
//Checking if device is already connected...
13. AT+CGATT=1    response      OK
//attach to network
14. AT+CIPMUX=0 response        OK
// to setup single connection. For multiple connections(client) use 1
15. AT+CSTT="www"      response         OK
//Setting up APN for TCP connection. www is APN so enter according to your operator.
16. AT+CIICR      resopnse          OK
//Bring up GPRS Connection.
17. AT+CIFSR       response
//your IP address
18. AT+CIPSTART="TCP","","1234"  
   response     OK    CONNECT OK
//TCP connection success. Now you connected your server
19. AT+CIPSEND     response    >
//now you ready to send message. So type as you wish
20. cool dear you are genius   ctrl+z   
  respose       SEND OK          (server response)
//after getting SEND OK you will get server response but it will take some second so wait
//if you get CLOSED after getting server response it means server has closed TCP connection.
21. AT+CIPCLOSE    response       CLOSE OK
//TCP socket is closed.
22. AT+CIPSHUT      response            OK
// now GPRS connection is closed.
//you can repeat step 14-22 if you want to send TCP data again and again

If you are not receiving exact response, it means there is something wrong. Then you need google.