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.
Hardware:
- We need a GSM/GPRS module with USB/RS232 interface
- Power adapter, 12v 1 amp.
- One USB/RS232 cable as per your module.
- It is understood that you have a Laptop/PC with one free USB port.
- working SIM card
Software:
- You may need USB to Serial converter which is easily available on Internet.
- 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 xx.xxx.xx.xxx //your IP address 18. AT+CIPSTART="TCP","xyz.com","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.
Thanks. This tutorial is clear. I will try this today. Meanwhile I have a query : I am going to use a network which is in roaming here. Do i need to supply any command to “enable mobile data in Roaming” as we do in smart phones?
Thanks.
Commands are always same if you are in national roaming but APN changes according to country. “Enable mobile data in roaming” is a functionality provided by smart phone, not by module.