How to control GM862 from Arduino

Arduino to GM862 pin connection

Arduino to GM862 pin connection

It took some effort to figure out how to connect the GM862 GSM module to a UART (in my case the Arduino USB evaluation board, so I decided to document the steps here.

I also have the GM862 USB Evaluation board, if you plan to use this board and control the GM862 from Arduino, e.g., to programmatically send an SMS message, then you need to be careful how you power the GM862 USB board. If you power it via a battery or external power source (but not USB), then you’re fine. Otherwise, you must remove the jumper that disconnects the TX and RX pins from the GM862 USB FT232. To remove this jumper, you must remove the solder that is on the pins marked TX-I and RX-O. This board is not designed to accept a two pin header and a plastic jumper to allow you to easily switch between USB control and external control. So to get going, don’t use the GM862 USB to power the GM862, whilst it is being externally controlled through your Arduino board.

For a minimum implementation, only the TXD and RXD lines needs to be connected, the other signals of the GM862 modem serial port (DCD/pin 36, DTR/pin 43, DSR/pin 33, RTS/pin 45, CTS/pin 29, and RI/pin 30) can be left open provided a software flow control is implemented (which is what we are trying to do).

You’ll need to disconnect the RX pin 0 on the Arduino board each time you upload your program. If you don’t, upload will fail with the “avrdude: stk500_recv(): programmer is not responding” error message. After you’ve uploaded the program you can reconnect pin 0. Pin 1 can remain connected at all times, so there is no need to disconnect pin 1.

It helps to have a LED attached to the status indicator LED (pin 39 of GM862), but this is optional and not required for you to control the GM862 from Arduino. Pin 39 is an Open Collector output where we can directly connect a LED to show network and call status information (fast blink means net search, not registered or turning off, slow blink means registered full service, always on means a call is active). I connected a LED with a pull-up resistor.

After connecting the Arduino RX pin (pin 0) to GM862 RX-O pin (pin 37), Arduino TX pin (pin 1) to GM862 TX-I pin (pin 20), and Arduino Ground to GM862 Ground, you are ready to take control of GM862 right from Arduino (click on the thumbnail for detailed schematics). To test this set up, send a SMS message. Here is the code to do just that:

#include <SoftwareSerial.h>

int rxPin = 0;
int txPin = 1;

// set up a new serial port
SoftwareSerial serial=SoftwareSerial(rxPin,txPin);

void setup()  {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);

  // set the data rate for the SoftwareSerial port

  // Set SMS to text mode. Note it is critical 
  // to use \r\n to end each line
  // The delays are also critical, without them, 
  // you may lose some of the
  // characters of your message

  // Replace with a valid phone number
  serial.print("Hello from Arduino.");

  // End the SMS with a control-z

void loop() {

Here is a function that takes a char array and use that as the content of the SMS. Not sure if a delay after each print statement is really needed or not.

#define PHONE_NUMBER  "+14081234567\r\n" 
#define PRINTDELAY 500

void sendSms(char msg[]) {
  // End the SMS with a control-z


42 Responses to “How to control GM862 from Arduino”

  1. matt.e Says:

    Did you use any level converting (5V to 3.3V) for the serial connection between the arduino and GM862?

  2. sj Says:

    Hi, Thank you for your comment. No I had not attempted to drop the voltage from 5 to 3.3V. I didn’t know I had to do that. I checked the GM862 reference manual and found that the serial data voltage for GM862 is 2.8V. This means that to be safe you’ll need to drop the Arduino serial data voltage from 5V to 2.8V. After your comment, I did try to convert the voltage by adding a 51 ohms pull-down resistor (one end to the 5V Arduino serial data pins 0 and 1 and the other of the resistor to ground. This reduced the voltage from 5V to 2.9V.

  3. matt.e Says:

    Thanks for the article. It helped me get started. I took the level shifter one step further and created a voltage divider instead of just a pull-down resistor to lower the current load on the arduino’s TX pin. I used a 1.1K R from the Arduino TX pin to the GM862 pin and a 2K R from the GM862 pin to GND. That way the GM862’s pin only sees a maximum of 2.75V. Also for a little protection I put a 1.1K R in series with the Arduino’s RX pin. I’m curious if you’ve taken your program any further such as parsing incoming SMS for control commands or even the GPS data.

  4. sj Says:

    Hi Matt, a voltage divider is the right way to reduce the voltage on the TXD line. Thank you for suggesting it. I’ve not been able to read from GM862 yet. When I send an AT command the response on the GM862 RX line is only about 300 mv. I wonder if the RX pin is dead. Can you monitor the voltage on the RX pin and see what it is when you send an AT command that produces an output (almost all AT commands do that). But the bottom line is that I’ve had enough of all of this voltage translation problems. I have ordered a 3.3 V Arduino Pro. I’m looking forward to just connecting the micro-controller without having to worry about voltage translation.

  5. matt.e Says:

    I am receiving replies (and parsing them somewhat). My O-scope shows 2.5V on the Arduino’s RX(0) pin when idle and 0-2.5V levels during active communication.

    Originally I started with AFSoftSerial on other io lines but I noticed incoming data was being dropped so now I’m using the hardware UART. Is there a certain reason you are using SoftSerial on the Arduino’s hardware serial lines?

    I’m trying to figure out an efficient way to parse incoming commands. Also a basic error handling method. For example, after a certain number of errors, wait for better signal or reset module depending on whether the error was related to poor signal or something else.

  6. sj Says:

    Hi Matt, The only reason I used GIO’s other than Arduino’s pin 0 (RX) and 1 (TX) was so that I could use the Serial.print on the hardware UART for debugging purposes.

    The Arduino RX pin on idle is at 5V if it is not connected to the GM862. When I connect it to the GM862 pin it drops to 300mV. Is this what you see?

    How do you connect the Arduino RX pin to the GM862 RXD pin?

  7. matt.e Says:

    My Arduino RX pin sits at 2.8V when connected to the GM862 RXD pin. I have it connected through a 1.1K R. It sounds like your GM862 is pulling the RX line low.

    Regarding which IOs to use for the serial connection with the GM862, I’m again using GIOs(with NewSoftSerial) rather than the hardware UART. I’m actually using a Modern Device BBB. Here my hardware UART pins are pin 0(RX) and pin 1(TX). Are they different on a name brand Arduino?

    I’ve done some extension programming this last week and I have come to the conclusion that the Atmega168 does not have enough memory to fully utilize the GM862. I was having weird problems that I believe were SRAM overflow related. I plan to move to a Sanguino (Atmega644).

    I’m surprised at how often the GM862 stops responding to serial commands and my program has to issue a OFF/ON sequence on the GM862s ON_OFF pin.

    I also have not yet figured out how to pass char[] variables to my Send() function. So far I have just been setting a global char[] before I call my Send() function.

    If you feel our correspondence should be moved to something like email, let me know. Thanks again.

  8. sj Says:

    Hi Matt,

    The hardware UART pins are pin 0 (RX) and 1 (TX) on the name brand Arduinoo too. I now use digital pins 7 and 8 for software RX and TX. This allows me to use Serial.print for debugging using the hardware UART, and software serial for communication with the modem.

    I will try connecting the RX pin with a 1.1K resistor. Do you connect the one end the PWRMON to pull-up the voltage to 2.8V?

    I’ve had the same problems with a program that appeared to used more memory that I had. I reduced the size of the arrays that I was using and it fixed the problem.

    I just got the Arduino Mini Pro which is a 3.3V system, and again the voltage on RX is about 300mv, so the pull-up resistor looks essential.

    How do you read the response to the AT commands? If you use the non-verbose mode, ATV0, then the response to mist AT commands will be in the form “<test><CR><LF><numeric code><CR>” Do you actually get all of this response?

    I’ve also seen the GM862 every-once in a while stops responding to AT commands. Up to now I just power-cycle the system, but using the ON/OFF is clearly the better way.

    I use AT command to shutdown the module and the pulse on the ON/OFF pin to turn it back on. However, the ON part does not always work.

    I also noticed the reducing the speed of the serial communication to 4800 worked with the Arduino Mini Pro (3.3v). I was using 9600 with Arduino Decimilia (5v).

    I’ve not tried the NewSoftSerial. Unfortunately, looks like it does not support 8MHz clock speed (Arduini Mini Pro 3.3V). (BTW. I updated the entry and added a function that takes a char array and passes that as the content of the SMS.).

    Thank you for your input.

  9. matt.e Says:

    Hi SJ,
    For the RX connection, I just have the 1.1K R in series for a little protection in case I hooked something up wrong, no pullup.
    GM862 RXD——–/\/\/\———Arduino RX
    The TX line is connected through a voltage divider.

    At first I had the PWRMON pin connected to a digital input but it seemed like it wasn’t going high enough to trigger a HIGH reading so I moved it to an analog input and use the values 410 and 102 to detect an ON and OFF respectively. The ON_OFF and RESET pins I have both connected through their own diode so that the Arduino can only pull it low (as low as the diode’s forward voltage drop allows) because the GM862 has it’s own pullup R and the Arduino’s 5V might cause problems. The manual states that an open collector circuit is required, I figure this is almost the same but easier to setup.
    GM862 ON_OFF——>|——–Arduino IO (repeat for RESET)
    I’m developing this for a remote temperature monitoring unit so I need it to be automated. Until now I just issued a RESET if there was no response from the GM862 but I want to look into issuing an ‘AT’ first to clear the GM862’s RX buffer, in case the issue is just a poorly transmitted command. Though now that I’m using NewSerialSoft, there are fewer resets.

    So far I have left verbose responses on but I issue the ATE0 command to turn off command echo. Then after sending a command, I have a function that waits for a reply. The reply function includes a timeout counter that resets after every received character. After the last character comes in it waits 1 sec before it assumes the GM862 is done. Then it uses a nested for…loop to compare the reply with my expected reply. At initialization, my expected reply is just ‘OK’ but later on I query the GM862 with the $GPSACP, +CSQ, #MONI and #TEMPMON=1 commands. Before sending each command I set my expected reply for comparison with the GM862’s reply. The manual actually states how long a wait there should be for most of the AT commands. To be thorough, I should add a wait var to be set along with the expected reply so that my program waits the proper length of time. My debugging output is formatted so that I can see what the Arduino is actually receiving back. Except for the first ATZ and ATE0 commands, the reset appear to received completely.

    I am trying to setup these functions to be universal with any command I might send. Except for sending an SMS (expected pause between command and msg), I think they work. With the low mem issue, does a single global char[25] use less SRAM than two localized char[25] would when passing one to the another in a function? I might be better off sticking with my global char[] vars.

    With the help of Dave(dcb) on this forum,
    I have learned how to manually check a sketch’s SRAM usage.

    • telmo Says:

      Hi Matt

      Can you help me.

      I try to read the response of my AT command, but I can’t read anything.

      can you help me with some code that sends a At command an reads response.


      • Matt E Says:

        telmo, that’s a difficult question to answer with a simple answer. Your problems may be related to hardware troubles (the serial connections) or software. I suggest studying the GSM playground schematics and sketches at Oldrich has been kind enough to share the code for his Arduino GSM library along with the Eagle brd and sch files for his Arduino shield. Make sure that your physical connections between the modem and microcontroller are correct. Telit offers some useful pdfs on their website in regards to the hardware hookups and AT commands.

  10. Diogenes Says:

    Good examples, in the web haven’t examples for Teilt modules, but your C examples are poor implementing because several AT commands cant delay more than fixed delay.

  11. sj Says:

    Good point. Thank you for the reminder.

  12. MMIX Says:


    Nice work. This is very helpful.

    I was wondering if anyone had found a way to listen for and receive SMS on the Arduino.

    I know about the AT+CMGL=”ALL” command, but I am not sure how to actually read the module response into a string that I can later parse.

    Any ideas?

    • sj Says:


      Thank you for your post. Yes I do read SMS responses. One thing to bear in mind is the command AT+CREG=2. If you set this command to 2 (which is a right thing to do in most cases), then the Telit modem will output the reports as the network registration status changes (and the status does change even if the modem is in a stationary location). So you need to be prepared to read this input. I’ve set a timer in the Arduino loop and every second I attempt to read the input and if there is a network status change, I update a global variable that denotes the network status. When I need to send an SMS, I check this variable, and if the modem is registered, then I send the SMS and I also check for any incoming SMS messages. Unfortunately, you’ve to do basic C style string processing. Not sure if there is a library that makes this a little less painful or not.

  13. Open_Sailing Says:

    […] References – GM862 Cellular Quad Band Module – Memory […]

  14. Oldrich Says:

    Hi Matt,
    nice example! I have solved something similar with GE863-QUAD…finaly I have made a switch for serial communication so that you can also communicate with the module directly from PC (it is good for trying and learning with the module). Maybe you can find something interesting here:

  15. Rahul Tripathi Says:

    Hi SJ,

    I am so sorry that I posted my query on your “About” page. I didn’t see an option here.

    I am developing a simple application on GM862 GPS modem using python script. I want to toggle a GPIO (General Purpose IO)pin on the
    board from a SMS. Like if a SMS text says “ON”, the pin should set to “1” and if it says “OFF”, pin should set to “0”.

    I think I can do the toggling part but where I am facing difficulty is:

    1. How to detect an incoming SMS. On the Rsterm it does show the response as “+CMTI: SM, 2” but how to listen using a python script.

    2. How to extract the SMS text using python and use that text for invoking desired tasks.

    I would really appreciate if could guide me on this.


    • Shahram Javey Says:

      H Rahul,

      You need to use the AT command to read the SMS inbox. Check out the Telit documentation and read about CMGL, CMGR, …
      I’ve not used the Telit Python. I control it using C. Good luck.

      • Rahul Tripathi Says:

        Thank you Sir. But even in C how you do extract SMS text and use that text to perform a task?

  16. Jim Hood Says:

    I am conducting my PhD project at the moment. I have purchased a Zigbee development board and have assembled it (hopefully correctly!). There are two connectors for the processor, one with two rows of 8 pins and one with nine two rows. I wish to connect sensors and a Telit GSM/GPS module and three sensors to this board, with an XBee Zigbee 2.4 GHz. I am also having problems writing the code I have to the PIC 16F819 I have. My background is not in electronics. Can you advise how to fit the GSM module and sensors properly and the easiest way to load the code to the processor please? I would be very grateful for any help given.

    Many thanks,
    Jim Hood.

  17. Shahram Javey Says:

    It may be easier to use Arduino than try to get started with PIC/ZigBee/Telit. I’m not familiar with PIC development environment.

  18. fcarlo Says:

    Hi all,

    Is it feasable to use hardware flow control (RTS/CTS) during a GPRS connection (when AT+CGATT=1 and AT#GPRS=1)?

    Could serial control signals be active during a GPRS session?

    I’m trying to connect to a server FTP via GPRS, retreive some data (AT#FTPGET=”myfile.txt”) and halt Telit GM862 module from sending data (set CTS=1) every 50 bytes received.

    NOTE: The connection works only when control flow is OFF (AT&K0)… of course in this case there is no way to halt the module when it starts getting the file…

    NOTE2: I’m using the following module: PS:5.02.203/AL:6.04.204-GM862 QUAD

    Thanks in advance

    • ull Says:

      I am trying to use FTP client on this module with no success. Can You please post the command sequence You are using.


  19. TCB13 Says:

    Hi, everyone, first of all great post about arduino and tellit, but I’ve a problem!

    How can I use my telit and arduino in order to have a port allways opened to the internet waiting for connections?

    I’ve tried to do this, using the socket listen AT command, but seems like I can’t use it the right way…

    The first try out was:

    Send the following to the mode:
    AT#FRWL=1,[my-ip], -> Add my ip to accepted list
    AT#SL=2,1,1001 -> Open the socket for listen connections…

    It works fine that way, but when I change my ip, the ip is not authorised and the connection is rejected…

    So… I read a little bit of the AT commands reference guide, and I tried this:

    Send the following to the mode:
    AT#SCFG=2,0,0,5000 -> Basic Socket Config (OK)
    AT#SCFGEXT=2,0,0,0,1,0 -> Extended config, supposedly auto-accept connections mode… (ERROR)
    AT#SL=2,1,1001 -> Open the socket for listen connections…

    I don’t know why an error happens, when I try to configure the socket to auto-accept all connections… What should I do? What am I missing?

    Help please!

    • Adi Says:


      Can you please tell me how do you exactly make it listen? Since i’m trying but no luck…

      What is the ip that you should put in the firewall? is it LAN?

      Also, when you try to connect to the device, from where did you get the ip for it?

      I hope you explane what is the IPs you’ve used…

      • TCB13 Says:

        Hi Adi,

        Considering my first tryout (the one witch works…):

        AT#FRWL=1,[my-ip], -> Add my ip to accepted list
        AT#SL=2,1,1001 -> Open the socket for listen connections…

        On the AT#FRWL command you should place the ip of the computer that you will use to connect to the modem…

        Then, open comandline/terminal and “telnet ip 1001”
        ip of the modem on the internet
        1001 is the port.

      • TCB13 Says:

        Hi, sorry by the delay but I saw this now..

        Well Telit told me that I could set an open chain in the modem firewall so I can connect to it from every IP I want… so:

        AT#FRWL=1,0,0,0,0, –> Add and open chain the the firewall…

        AT#SL=2,1,1001 –> Socket listening @ port 1001 😉

        I didn’t test this out yet, because this project is a little bit in second place… but.., I will…

        Adi, next time leave your email…

      • TCB13 Says:

        I forgot…

        When you issue AT#GPRS=1 to connet to the internet, the modem answer it’s IP if successfully connected 😉

  20. Viktar Tatsiankou Says:

    Hi all,

    I have purchased the GM862 USB evaluation board from Sparkfun. I have successfully got it to work with the PC’s hyperterminal, i.e. I can send and receive SMS. However, the eventual goal for me is to connect the board to Arduino MEGA and communicating with GM862. I read in the manual that in order to allow external communication the USB FTDI chip need to isolated from the evaluation board, via desoldering jumpers RX, TX, RTS, CTS. I was just wondering if anyone has done this, if so maybe someone can post a picture as to exactly where these jumpers are located. Also any comments interfacing the USB evaluation board for GM862 and Arduino MEGA would be greatly appreciated.

  21. Matt E Says:

    I recommend careful reading of the GM862_hardware_user_guide from Telit. The de-soldering is actually just removing the solder that bridges the two pads per connection. Looking at the pic on sparkfun’s site it appears you will need to remove the solder on the RX-O, TX-I, DTR, RTS & CTS pads right below the FTDI chip. Also, take note of the RX-O and TX-I labels. I believe it’s TX from the microcontroller’s perspective and (I)nput from the GM862’s perspective and vice versa for the RX-O line.

  22. Vimal ganth Says:

    Hi i want use a ps/2 keypad to send sms .my understanding is i have to use ctrl z to send a text. Is it possible to select another charecter to carry out the cntrl z command eg: I type 123456 followed by # to send 123456 as message. Could you tell me how to do this? I have managed to interface keyboard and it is working ie i can see what i am typing on the pc

  23. Diogenes Says:

    Hi Vimal, it’s no possible, only CTRL-Z

  24. Tim Zaman Says:

    This article is actually dangerous. If you would use this only a few times changes are big you will fry your $150 module. omg!

  25. NaThAN Says:

    Hi there!
    I ‘ve started a project for my university on the Telit GM862 and arduino communication.

    I managed to send an SMS to my phone, the GSM connects easily (5-6 seconds) but i cannot receive a response to the arduino.

    I am connecting the TXD (+5V) of arduino to the TXD of the module using a voltage divider (+2.8V)
    I also connect the RXD directly to my Arduino RXD.
    I can send from my arduino anything but i cannot receive a thing.

    I have uploaded your sketch, and every time i receive “no response” not even the RXD led on the arduino flashes.
    I am using an arduino Duemilanove and i am connecting the RXD of the module to the RXD (pin 0) and the TXD to the pin 1 (TXD) of arduino, using a voltage divider.
    The module should respond with “OK” if I write on the arduino serial monitor “AT” and press send, right?

    Do I have to write a program with; in order to see the responses on the serial monitor, of the arduino software?
    Can someone send me an example sketch so I can read the AT command responses from my module to my arduino?

    Please help me, I am stuck on this for about 2 days.

  26. NaThAN Says:

    I managed to make the module communicate. But the only way to test it, is by putting the RX module pin to another serial port, and the transmit from the arduino to my module TXD. Both GRN are connected to my circuit.
    Now I can send a lot of commands to my module and receive the correct answer to my PC.

    But because I need to make a program that handles some data that’s been received by arduino, I need it to work fully with the arduino IDE (Serial Monitor).
    I am using some kind of code but sometimes I receive strange characters that are not making sense. Everytime I receive the correct answer etc.”OK” but its followed by characters.

    NewSoftSerial mySerial(2, 3);
    void setup()
    Serial.println("GM862 testing...");
    // set the data rate for the NewSoftSerial port
    void loop() // run over and over again
    if (mySerial.available()) {
    if (Serial.available()) {

    I press the reset button each time.
    What I receive to my arduino serial monitor:
    [quote]GM862 testing…
    EÕÔHèjªHøGM862 testing…

    GM862 testing…

    GM862 testing…

    GM862 testing…

    GM862 testing…
    Q55RzµÕHøGM862 testing…


    I need to compare the “text” i receive from myserial to my arduino with another string.
    For example, I need to know how to compare what I receive, with the word “OK’ or the word “GM862-GPS” so i make a routine for the program to do some functions if its TRUE.
    So I need two things… A code that receives the data and saves it to an array, when it receives the carriage return to make the data as a string, and serila print it to myserial monitor.
    The second thing is to compare it with another string. I think that’s easy by using the strncmp() function.

    I am trying something like this…

    if (mySerial.available() == “OK”) {
    Serial.println(” Modem –> OK”);

    Can someone help me by giving me an example code of what I want to do? Or just fix this one?

    Thanks in advance!

    • TCB13 Says:

      If that’s happening is probably because your baud-rate is to high or the modem is not configured to it. Check my comments here: they might contain something useful to you.

      Another important thing, like I said on that comments is that Arduino library’s are NOT the way to go with this kind of stuff… If you really wan’t it to work properly you need to use stdout and printf to the modem and set interrupts to get the data back.

      Have a nice day.

      • Abhishekn Says:

        Hi TCB13
        Thank you for these valuable comments.
        I am doing the same thing and facing the same problem ,now i have connected 22k resistor in Tx line but still i am not getting the response on serial monitor. I am using the same board from microelectronica but instead of arduino mega i am using arduino Uno .Please help me ..

  27. JuanK Says:

    Hello!! I need Help. I Work with telit gm862-gps and msp430 micro controller. I create a library like a gm862.h but adapted for msp430 and work well. I try create a socket like an example that is in telit’s GPRS easy document, but the problem is that all receive data are backwards. I need know how to telit receive data packets. Is necessary that the telit work with a baud rate of 9600? Actually I set a baud rate of 115200, and configuration socket parameters are:


    After that, the module response a CONNECT, and I perform a HTTP request.

    Thanks in advance!

  28. joshua Says:

    I am using the GM8862 sms module. With an AT89c5131 microcontroller using it for my project and i dnt know how to start

  29. haifa Says:

    hi there!
    i am asking for how to send data after opening of socket server by using GM862-Quad because i tried to use this command ” AT#SSEND” or “AT#SSENDEXT”, but it’s not working:
    AT+CGDCONT= 1,”IP”,”orange”





    This last command returns “CONNECT”. But informations written on the serial port after that aren’t received on the socket. I tested the destination socket with another application and datas are correctly sended.

    Thanks in advance !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: