Tutorial – Arduino Uno and SM5100B GSM Cellular

Connect your Arduino Uno or compatible to the cellular network with the SM5100 GSM module shield.

This is chapter twenty-six of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

If you are looking for tutorials using the SIMCOM SIM900 GSM module, click here, and here if you have an Arduino Mega.

Updated 15/01/2014


The purpose of this tutorial is to have your Arduino to communicate over a GSM mobile telephone network using the SM5100B GSM Cellular Shield:


My goal is to illustrate various methods of interaction between an Arduino and the GSM cellular network using the SM5100B GSM shield from Sparkfun, with which you can then use your existing knowledge to build upon those methods. Doing so isn’t easy – but it isn’t that difficult.

Stop! Please read first:

  • It is assumed that you have a solid understanding of how to program your Arduino. If not, start from chapter zero
  • Sending SMS messages and making phone calls cost real money, so it would be very wise to use a prepaid cellular account or one  that allows a fair amount of calls/SMS
  • The GSM shield only works with “2G” GSM mobile networks operating on the 850, 900 and PCS1800 MHz frequencies. If in doubt, ask your carrier first
  • Australians – you can use any carrier’s SIM card
  • Canadians – this doesn’t work with Sasktel
  • North Americans – check with your cellular carrier first if you can use third-party hardware (i.e. the shield)
  • I cannot offer design advice for your project nor technical support for this article.
  • If you are working on a college/university project and need specific help – talk to your tutors or academic staff. They get paid to help you.
  • Please don’t make an auto-dialler…


Getting started

As mentioned previously, we’re using the Sparkfun GSM shield with the SM5100B module. When you order the shield, don’t forget to order the stacking header pin set as they’re not included with the shield, and you’ll need to solder them on yourself. Power -the GSM shield can often require up to 2A of current in short bursts – especially when turned on, reset, or initiating a call.

However your Arduino board can only supply just under 1A. It is highly recommended that you use an external regulated 5V power supply capable of delivering 2A of current – from an AC adaptor, large battery with power regulator, etc. Otherwise there is a very strong probability of damaging your shield and Arduino.

Ignore this at your own risk

When connecting this supply DO NOT use the DC socket on the Arduino. Instead, connect the 5V (positive) from the supply to the 5V pin on the GSM shield, and the negative to the GND pin.

If you’re looking for a more permanent or easy-to-wire solution, get yourself a DFRobot power shield:


This shield sits on top of your GSM shield (which sits on top of your Arduino). Before use you need to set it up:

  1. The only jumpers that should be on the power shield are as shown in the image above;
  2. Connect a power supply of between 9 and 35V DC to the blue terminal block at the bottom-left of the shield;
  3. Connect a voltmeter/multimeter to the other blue terminal block at the top-left and adjust the potentiometer (blue thing between the terminal blocks) until the voltage measured is 5 volts; ignore the LEDs on the shield as they’re not that accurate;
  4. Run a wire from the positive power output to the 5V pin on the shield, and run another one from the negative power output to a GND pin on the shield;
  5. If you have the USB cable connected to your project while operating the GSM shield, remove the USB cable before turning off external power to the project.

Here’s what it looks like once assembled with the antenna:


Next – use an antenna! The wire hanging from the shield is not an antenna. YOU NEED THE ANTENNA! There are two choices. Either use the smaller one for areas where handheld mobile reception is acceptable, such as this one:

Or if you are in an area of weaker reception, use an external antenna such as that used on a motor vehicle. If you are using the larger vehicle-style aerial, you might find that the plug will not fit to the shield’s connector. For example, consider the following:


On the left is the end of the lead from the carphone aerial, the right is the lead from the GSM shield. Problem! The solution is in the centre: an FME male to SMA male adaptor. This one came from element-14, part number 1826209 (it is a Multicomp R23-014-00-002611000).

Furthermore, care needs to be taken with your GSM shield with regards to the aerial lead-module connection, it is very fragile:


And finally, download this document (.pdf). It contains all the AT and ERROR codes that will turn up when you least expect it. Please review it if you are presented with a code you are unsure about.

Wow – all those rules and warnings?

The sections above may sound a little authoritarian, however I want your project to be a success. With the previous iterations of the tutorial people just didn’t follow the instructions – so I hope you do 🙂

Are you using an Arduino Mega or Leonardo board?

Things are a little different for you. Those boards don’t support SoftwareSerial on digital pins 2 and 3 thus rendering the GSM shield a little trickier to use. Instead, bend back the D2 and D3 pins on the GSM shield as such (click image to enlarge):

Then run jumpers from D2 on the attached shield to D10 and another from D3 to D11. If you’re using the aforementioned power shield it would be on top of the GSM shield however the jumper wires would be the same. Finally in all the sketches, change the line SoftwareSerial cell(2,3);  to SoftwareSerial cell(10,11); . If you have a Leonardo, get a Uno.

Initial check – does it work?

This may sound like a silly question, but considering the cost of the shield and the variables involved, it is a good idea to check if your setup is functioning correctly before moving on. From a hardware perspective for this article, you will need your Arduino board, the GSM shield with activated SIM card and an aerial, and a range of previously used components.

Make sure your SIM card is set to not require a PIN when the phone is turned on. You can check and turn this requirement off with your cellphone. For our initial test, upload the following sketch:

Then connect the GSM shield, aerial, insert the SIM card and apply power. Open the serial monitor box in the Arduino IDE and you should be presented with the following:


It will take around fifteen to thirty seconds for the text above to appear in full. What you are being presented with is a log of the GSM module’s actions. But what do they all mean?

  • +SIND: 1 means the SIM card has been inserted;
  • the +SIND: 10 line shows the status of the in-module phone book. Nothing to worry about there for us at the moment;
  • +SIND: 11 means the module has registered with the cellular network
  • +SIND: 3 means the module is partially ready to communicate
  • and +SIND: 4 means the module is registered on the network, and ready to communicate

From this point on, we will need to use a different terminal program, as the Arduino IDE’s serial monitor box isn’t made for full two-way communications. You will need a terminal program that can offer full two-way com port/serial communication. For those running MS Windows, an excellent option is available here.

It’s free, however consider donating for the use of it. For other operating systems, people say this works well. So now let’s try it out with the terminal software. Close your Arduino IDE serial monitor box if still open, then run your terminal, set it to look at the same serial port as the Arduino IDE was. Ensure the settings are 9600, 8, N, 1. Then reset your Arduino and the following should appear:


The next step is to tell the GSM module which network frequency(ies) to use. Please download this document (.pdf), and view page 127. There is a range of frequency choices that our module can use. If you don’t know which one to use, contact the telephone company that your SIM card came from. Australia – use option 4. Choose your option, then enter

(where X is the value matching your required frequency) into the terminal software and click SEND. Then press reset on the Arduino and watch the terminal display. You should hopefully be presented with the same text as above, ending with +SIND: 4. If your module returns +SIND: 4, we’re ready to move forward.

If your terminal returned a +SIND: 8 instead of 4, double-check your hardware, power supply, antenna, and the frequency band chosen. If all that checks out call your network provider to see if they’re rejecting the GSM module on their network.

Our next test is to call our shield. So, pick up a phone and call it. Your shield will return data to the terminal window, for example:


As you can see, the module returns what is happening. I let the originating phone “ring” twice, and the module received the caller ID data (sorry, blacked it out). Some telephone subscribers’ accounts don’t send caller ID data, so if you don’t see your number, no problem. “NO CARRIER” occurred when I ended the call. +SIND: 6,1 means the call ended and the SIM is ready.

Have your Arduino “call you”

The document (.pdf) we downloaded earlier contains a list of AT commands – consider this a guide to the language with which we instruct the GSM module to do things. Let’s try out some more commands before completing our initial test. The first one is:

which dials a telephone number xxxxxx. For example, to call (212)-8675309 use

The next one is

which “hangs up” or ends the call. So, let’s reach out and touch someone. In the terminal software, enter your ATDxxxxxxxx command, then hit send. Let your phone ring. Then enter ATH to end the call. If you are experimenting and want to hang up in a hurry, you can also hit reset on the Arduino and it will end the call as well as resetting the system.

So by now you should realise the GSM module is controlled by these AT commands. To use an AT command in a sketch, we use the function

for example, to dial a phone number, we would use

To demonstrate this in a sketch, consider the following simple sketch which dials a telephone number, waits, then hangs up. Replace xxxxxxxx with the number you wish to call.

The sketch in example 26.2 assumes that all is well with regards to the GSM module, that is the SIM card is ok, there is reception, etc. The delay function in void setup() is used to allow time for the module to wake up and get connected to the network. Later on we will read the messages from the GSM module to allow our sketches to deal with errors and so on.

However, you can see how we can simply dial a telephone. You could now have a home alarm system that can call you upon an event happening, etc.

Send an SMS from your Arduino

Another popular function is the SMS or short message service, or text messaging. Before moving forward, download and install Meir Michanie’s SerialGSM Arduino library from here. Sending a text message is incredibly simple – consider the following sketch:

It’s super-simple – just change the phone number to send the text message, and of course the message you want to send. The phone numbers must be in international format, e.g. Australia 0418 123456 is +61418123456 or USA (609) 8675309 is +16098675309.

Reach out and control something

Now let’s discuss how to make something happen by a simple telephone call. And the best thing is that we don’t need the the GSM module to answer the telephone call (thereby saving money) – just let the module ring a few times. How is this possible? Very easily. Recall Example 26.1 above – we monitored the activity of the GSM module by using our terminal software.

In this case what we need to do is have our Arduino examine the text coming in from the serial output of the GSM module, and look for a particular string of characters.

When we telephone the GSM module from another number, the module returns the text as shown in the image below:

We want to look for the text “RING”, as (obviously) this means that the GSM shield has recognised the ring signal from the exchange. Therefore need our Arduino to count the number of rings for the particular telephone call being made to the module. (Memories – Many years ago we would use public telephones to send messages to each other.

For example, after arriving at a foreign destination we would call home and let the phone ring five times then hang up – which meant we had arrived safely). Finally, once the GSM shield has received a set number of rings, we want the Arduino to do something.

From a software perspective, we need to examine each character as it is returned from the GSM shield. Once an “R” is received, we examine the next character. If it is an “I”, we examine the next character. If it is an “N”, we examine the next character. If it is a “G”, we know an inbound call is being attempted, and one ring has occurred.

We can set the number of rings to wait until out desired function is called. In the following example, when the shield is called, it will call the function doSomething() after three rings.

The function doSomething() controls two LEDs, one red, one green. Every time the GSM module is called for 3 rings, the Arduino alternately turns on or off the LEDs. Using this sketch as an example, you now have the ability to turn basically anything on or off, or call your own particular function.

And now for a quick video demonstration. The first call is made, and the LEDs go from red (off) to green (on). A second call is made, and the LEDs go from green (on) to red (off). Although this may seem like an over-simplified example, with your existing Arduino knowledge you now have the ability to run any function by calling your GSM shield:

Control Digital I/O via SMS

Now although turning one thing on or off is convenient, how can we send more control information to our GSM module? For example, control four or more digital outputs at once? These sorts of commands can be achieved by the reception and analysis of text messages.

Doing so is similar to the method we used in example 27.1. Once again, we will analyse the characters being sent from the GSM module via its serial out. However, there are two AT commands we need to send to the GSM module before we can receive SMSs, and one afterwards. The first one you already know:

Which sets the SMS mode to text. The second command is:

This command tells the GSM module to immediately send any new SMS data to the serial out. An example of this is shown in the terminal capture below:

Two text messages have been received since the module was turned on. You can see how the data is laid out. The blacked out number is the sender of the SMS. The number +61418706700 is the number for my carrier’s SMSC (short message service centre). Then we have the date and time. The next line is the contents of the text message – what we need to examine in our sketch.

The second text message in the example above is how we will structure our control SMS. Our sketch will wait for a # to come from the serial line, then consider the values after a, b, c and d – 0 for off, 1 for on. Finally, we need to send one more command to the GSM module after we have interpreted our SMS:

This deletes all the text messages from the SIM card. As there is a finite amount of storage space on the SIM, it is prudent to delete the incoming message after we have followed the instructions within. But now for our example. We will control four digital outputs, D9~12. For the sake of the exercise we are controlling an LED on each digital output, however you could do anything you like.

Although the sketch may seem long and complex, it is not – just follow it through and you will see what is happening:

And now for a video demonstration:


So there you have it – controlling your Arduino digital outputs via a normal telephone or SMS. Now it is up to you and your imagination to find something to control, sensor data to return, or get up to other shenanigans. If you enjoyed this article, you may find this of interest – controlling AC power outlets via SMS.

And if you enjoyed the tutorial, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop” from No Starch Press.

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The following two tabs change content below.

John Boxall

Founder, owner and managing editor of tronixstuff.com.

87 Responses to “Tutorial – Arduino Uno and SM5100B GSM Cellular”

  1. Bruce says:

    Thanks for this tutorial, John, I found it very helpful. I have a few questions I’m hoping you (or someone) might be able to answer: 1. When I first ran example 26.1 I got all the right SIND messages, but after a few weeks of running variations of the code the module now only returns 11 (and occasionally 7), even on the original code. Do you know why the other messages are no longer appearing? 2. The AT Command manual notes that the SIND messages are stored in flash memory. Does this mean that they are accessible by means other than cell.read()? 3. When I sent AT+ADCM it return the value 3979. Is this 3.979 V and does it correspond to the range 3.3 to 4.2 referred to in the SM5100B manual (Table 1)? Thanks for your help.

    • John Boxall says:

      Hi Bruce
      1) If you’re getting 11 there’s something on the network side that’s stopping full registration (e.g. account issues). 7 means you can’t register on your SIM’s network, but the module is finding another network. Check your account, SIM, antenna, reception etc. Or the module is playing up – it happens. (2) You can read SIND status by sending “AT+SIND?” so yeah, either cell.read or your own code to monitor what’s coming back from the module via serial. (3) AT+ADCM is reading the ADC on the module – page 32 of AT command guide says it varies between 0~5000.

  2. Phil says:

    Man..when i tried example 26.3 i got SerialGSM does not a name type error..please help

  3. Carlos says:

    Hello, John.

    First I want to thank for this Tutorial which is very explained, but, I just I have any doubt, if the GSM cell can perform a conventional calling vois to vois since my personal cell phone to the GSM Cell and If I can conect a speaker to this shield.?

  4. David says:

    Hi John,
    Man I’m loving your tutorials, they are everything that I need in one place…thankyou!!!
    With example 26.3 I’m assuming that it is a typo on line two where there is nothing appended to your #include statement.
    I added the header file SoftwareSerial and everything seemed to work fine. Is that what is supposed to be there?

  5. Bogdan Nilă says:

    why do i get this message and it does not connecting to network?? what is +stin :9 ??

  6. threelegs says:

    If you have a mega do you still need the extra 5v power supply or will it be able to provide enough to power the shield ?

  7. Emilio says:

    con respecto al conector que mencionas para el cable de la antena, ¿ Así lo tengo que pedir pedir..?
    en el lugar donde lo quiero comprar (un macho FME a SMA adaptador macho), o tendrá algún otro nombre.
    y que otro cable le puedo conectar en ves del que mensionas arriba (cable de la antena del teléfono del coche), por que en el lugar donde la requiero poner, no tiene mucha señal.

    Lo mas cercano que encontré de un conector para la antena fue una que se llama conector macho tipo “F” PermaSeal-II, no se si sea similar.

    gracias. Me sacarias de un apuro que tengo.

  8. Diego Ch says:

    Why loading the configuration code to arduino and run the terminal returns me these values:

    +SIND:10, “SM”,1,”FD”,1,…..(all with 1)

  9. Diego Ch says:

    Okay, I’ll try that. One more question, it is normal that I return terminal + SIND: 0 or who is this?

  10. Sun Hwi Bang says:

    Hello john

    I got my SM5100B today and I have a trouble with connecting a simcard and module. I have a simcard that works for my phone and if I hook it up to module and check the serial monitor, then I get following message:

    Starting SM5100B Communication…
    +SIND: 8

    +SIND: 8 means that “the network is lost”. Do you know a way to fix this? Perhaps it is because this simcard requires the pin code and I have no idea how I can input the pin code.

    Thank you and my team will not forget your generous help

    Sun Hwi Bang

    • John Boxall says:

      You can remove the requirement for a PIN by putting the SIM in a normal handset and turning it off through the security (e.g.) menu.
      Make sure you have selected the appropriate band as well.

  11. Sun Hwi Bang says:

    Hello John. Thank you so much for your help, but I am having another trouble:

    Starting SM5100B Communication…
    +SIND: 1

    +SIND: 10,”SM”,1,”FD”,1,”LD”,1,”MC”,1,”RC”,1,”ME”,1

    +SIND: 3

    +SIND: 8

    +SIND: 4

    I am using AT&T sim card and it seems that it does not find the network. Could you tell me how I can fix this problem?

    • John Boxall says:

      If your last SIND is 4 then it should be working.

      • Sun Hwi Bang says:

        Hello John

        I fixed my antenna and now I am getting
        Starting SM5100B Communication…
        +SIND: 1

        +SIND: 10,”SM”,1,”FD”,1,”LD”,1,”MC”,1,”RC”,1,”ME”,1

        +SIND: 3

        +SIND: 4

        +SIND: 8

        and if I run SMSsend code then I am getting CME = 313 error. i am so desperate with this module, but sorry for bothering you again

      • John Boxall says:

        CME = 313 means “SIM failure”. However your SIND results are still the same. Did you call AT&T about the IMEI or account?

      • Sun Hwi Bang says:

        Hello John Thank you so much for your help. It finally works and I am super happy. I would not make this happen without your help. I think the problem was power supply. Also, quick question about sending SMS. Could you tell me a correct syntax to send SMS to multiple recipient?

      • John Boxall says:

        Good news. I can’t help you with multiple SMS.

      • Sun Hwi Bang says:

        Thank you so much for this posting. I was so happy that I finally made this module working.

  12. Steve says:

    Hi John, thanks so much for the info on this page. Very useful indeed. I’m following your directions and I’m up to the point where I need to do the two-way communicating between the terminal software and the cellular shield. As I have a Mac however I’ve not been able to follow the instruction on the OS X download you provided the web link for above, “http://syncterm.bbsdev.net/”. Any chance you could offer some guidance for Mac users? Otherwise, perhaps there are other ways to troubleshoot the +SIND: 8 error? My connections to the module look good.

    • John Boxall says:

      The Syncterm link is still active but I don’t have a Macintosh so not sure about that one. You can use any other terminal software that can communicate with the serial/USB port.
      However a +SIND: 8 means network is lost. Check your hardware, the frequency band against your GSM carrier and if it still returns 8 call your provider as they may need the IMEI of your GSM module or not allow 3rd party devices on your network.

      • sunhwi says:

        Hello John. I sincerely respect your patience and time for answering my inquires. I am in Costa Rica and I am trying to use the GSM module via Costa Rican mobile network. I am using the same sim card that I tested in US but different GSM module (I have two SM5100B and I left “working” GSM module in US and brought the new one here)

        However, this is what I am getting on my Arduino Serial:

        Starting SM5100B Communication…
             r›áŸ”1)’@«–0 ˜A8)ä ̨Å;)”a„!Pëž!”þ ƒÐÍD0 ………

        I kept getting bunch of ramdon characters, which opens to two possibilities.
        1) GSM module doesn’t not work in Costa Rican network (However, the same SIM card works in smartphone here)
        2) GSM module is already broken somehow (I didn’t put any external power, so I hardly believe that I would have burnt the module)

        Thank you for considering my questions again. Have a great Saturday eveing.

        Sun Hwi Bang

      • John Boxall says:

        1) The module may be faulty however with the random characters it may be one of the few ones that were set to 115200 bps that Sparkfun let slip through a year or so ago – so try altering the data rate in your sketch.
        1a) Your smartphone may support a frequency that’s used in Costa Rica which the SM5100 does not.
        2) Use power as described in the tutorial.

      • Andre Celere says:

        John, even if the network operates with a frequency not supported by the SM, would it not recognize that a SIM has been inserted? I only get +SIND: 0 and I tried with 2 different SIMs, from 2 diff operators… :(((

      • John Boxall says:

        Yes, It will recognise a SIM ins’t inserted.

  13. John says:

    I really appreciate your work.
    I’m from Romania and i work for my license.I buy this shield.Example 26.1 works fine.
    But i tryed example 26.3 and doesn’t work.Serial Monitor box is blank.
    cell.Rcpt(“+xxxxxxxxx”); // replace xxxxxxxxx with the recipient’s cellular number
    +40 represents code of my country.
    What can i do? I saw in examples of arduino–>libraries the code is different as against this. I tried different variants but….still not working. I need help.

  14. Abishai says:

    Hi, very nice tutorial. I am using sim 300 module along with arduino and I want to control my arduino through GPRS by turning arduino into web server. Can you give some suggestions to me for doing it.

  15. benson domingo says:

    Good Day author, i just want to ask how to connect the gsm shield to my arduino on breadboard.what pins do the shield connected in atmega328? by the way, your tutorial is a big help for me. i’ve learned a lot since i start reading. Thank you for your consideration for a newbie^^.

  16. gili says:

    Thanks for the tutorials. They are really helpful.I Followed your tutorial and i can talk to the SM5100B and get response from him but i don’t get +SIND 11 or rarely get it. It is plugged to an external 5V power supply with 3A rating.
    It usaslly looks like this:
    +SIND: 1

    +SIND: 10,”SM”,1,”FD”,1,”LD”,1,”MC”,1,”RC”,1,”ME”,1

    +SIND: 7

    +SIND: 3

    +SIND: 4

    Then occasionaly I do get SIND 11

    +SIND: 1

    +SIND: 10,”SM”,1,”FD”,1,”LD”,1,”MC”,1,”RC”,1,”ME”,1

    +SIND: 7

    +SIND: 3

    +SIND: 4

    +SIND: 11

    And then the all process start all over. I guess it because of the loop. So my question is if i get only SIND 4 is it ok?
    and the second problem is that if i run the sms sketch, the module doesn;t send an sms.
    Is it related to the SIND 11?
    What can i do to make the SIND 11 consistent?
    Thanks in advence

    • John Boxall says:

      The last SIND should be 4, if it skips 11 that’s ok. It could be a reception issue – check your antenna connection. Or it could be the network doesn’t allow 3rd party devices – call them to check.

      • gili says:

        Thank you for the reply. Actually the problem was that I connected the external power to the 5V pin instead of the VIN pin. I’ve noticed something weird. Your example of the SMS sending is working properly, but the SERIALGSM example of the SMS sending isn’t. Can you tell why? Is it because of the delay or the fact that you made it a standalone function? also what is the do->while loop function? Why do you say it’s risky to take it out?

        Thanks again for your time and answers. It is most appreciated.

      • John Boxall says:

        The do-loop is there just to ensure the sketch only sends one SMS. It’s a demonstration sketch, to show how it works which people can modify to do what they like with.

  17. gili says:

    Hi John,

    Sorry for the late reply, i set it a side for a while. First of all thanks for the answer. it made sense after i deleted the loop and got lots of sms’s…
    I have another question though, I’m using pin 2 for interrupt in the UNO, so i tried to set the software serial to other pins (like 4,5) but it didn’t work. Does the shield hard wired to pins 2,3 ? I have to use jumpers from other pins to make it work?
    how do I use the hardware serial pins (tx-1,rx-0)? if I can’t use other pins for the software serial?

    • John Boxall says:

      Shield is hard-wired to 2 and 3, you’ll need to use some jumpers or solder some replacement wiring.

  18. gili says:

    Hi john,

    I would like your advice please. I worked with the module and all was well. And then for some reason it started to sometimes work and sometimes don’t. So I went back to the terminal to look at the basic sketch, and after the “start communication…” nothing happens.
    It has external power supply of 5V 3A,So it is not power related, and connected to the arduino pin 2,3 for comms.
    What can I do to see if the module is defeceted or not?

    • John Boxall says:

      Hard to say without being there – so I’d pull everything apart and re-assemble it, checking the connections and the voltage from the power supply with a multimeter.

  19. Alex says:

    Hi John, thanks for the info, Im getting the following problem when i run “verify”,

    ‘SerialGSM’ does not name a type

    sketch_sep19a:3: error: ‘SerialGSM’ does not name a type
    sketch_sep19a.ino: In function ‘void setup()’:
    sketch_sep19a:8: error: ‘cell’ was not declared in this scope
    sketch_sep19a.ino: In function ‘void sendSMS()’:
    sketch_sep19a:13: error: ‘cell’ was not declared in this scope

    Thanks in advance!

    • John Boxall says:

      Did you install the SerialGSM library?

      • Alex says:

        John, thanks for the response… I found another way… and its working!!! 🙂 Thanks…
        Here is the code,

        // Include the GSM library

        #define PINNUMBER “”

        // initialize the library instance
        GSM gsmAccess;
        GSM_SMS sms;

        void setup()
        // initialize serial communications and wait for port to open:
        while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only

        Serial.println(“SMS Messages Sender”);

        // connection state
        boolean notConnected = true;

        // Start GSM shield
        // If your SIM has PIN, pass it as a parameter of begin() in quotes
        notConnected = false;
        Serial.println(“Not connected”);

        Serial.println(“GSM initialized”);

        void loop()

        Serial.print(“Enter a mobile number: “);
        char remoteNum[20]; // telephone number to send sms

        // sms text
        Serial.print(“Now, enter SMS content: “);
        char txtMsg[200];

        // send the message

        Read input serial
        int readSerial(char result[])
        int i = 0;
        while (Serial.available() > 0)
        char inChar = Serial.read();
        if (inChar == ‘\n’)
        result[i] = ”;
        return 0;
        result[i] = inChar;

  20. Robert Benson says:

    My name is Robert and Im doing a senior project on the arduino cellular shield and Im getting this error message. can you help?

    ” Starting SM5100B Communication…

    +SIND: 1

    +SIND: 10,”SM”,1,”FD”,1,”LD”,1,”MC”,1,”RC”,1,”ME”,1

    +SIND: 3

    +SIND: 8

    +SIND: 4

    +CME ERROR: 4 “

  21. Eric says:

    I think I’m having some problems getting the Arduino to communicate with the module. The +SIND codes are coming in all right (sequence: 1, 10, 3, 4, 8), but when I sent it AT+SBAND? it didn’t return anything, so I’m not sure if I’m even on the right frequency. I have an H2O SIM card.

    • John Boxall says:

      You don’t want SIND 8 – that means the network is lost. If you get 4 then 8, the network most likely doesn’t want your SIM and IMEI combination. I see that H20 resells AT&T, who have GSM 850MHz and 1900 MHz. However H20 might not offer access to that network as part of their reseller agreement with AT&T. So call H20 and ask them 1) do they resell 2G GSM and 2) do they let any IMEI number on the network or just their own supplied devices.

  22. Iosif says:

    Thank you for your tutorial. A basic question. Which Arduino boards are compatible with this GSM module?

    • John Boxall says:

      For simplicity, a Uno or compatible. However you can use others as long as you have the serial and power wiring correct.

  23. gili says:

    Hi John,

    I have replaced the since it didn’t communicate back. Meaning it didn’t send back any responses over serial. Do you have any idea why it could be?
    Also, with the new module i get the sind:4 but when i try to make a call it says “NO CARRIER”. Do you have any idea why? On the other handwhen i call it, it rings and i can answer the call…
    My sim is pre-paid, is it possible the recharge of the sim didn’t went through although the service provider said it was succesfully?

    • gili says:

      I forgot to ask how do send ctrl-z through the terminal? I can’t figure it out. I know ctrl-z is 26 in DEC or 0x1A in hex but icant figure out how to incorporate it to the sms sequence via terminal? Could you please write down the sequence after the “at+cmgs=”xxxxx” command?
      Thanks a lot!!!

      • John Boxall says:

        Depends on your terminal emulator. With the one in the tutorial just ensure the “+CR” box is selected.

    • John Boxall says:

      Possibly, put the SIM in a phone and try to call someone etc.

  24. hameedullah says:

    I need such type of code but want to control relay via sms using gsm and arduino pls write such type of code i extremly need this thanks

  25. Örjan says:

    Thanks for your tutorials. I have a problem. If I receive an SMS I do not get the text content but I get the following: + CMTI: “SM”, 4
    I can’t then use the information in my programming to perform actions. Am I doing something wrong?

    • John Boxall says:

      Please see chapter 27 where we deal with receiving SMSs. Are you using AT+CMGF=1 and AT+CNMI=3,3,0,0?

  26. Ushan says:

    hi i need a make a wrist watch size device to send sms using gsm module and aurdinos is there any availbale devices to complete my project?

  27. Sergio Monsalve says:

    Hi, very nice tutorial. I am using SM5100B module in GPRS mode and I want to control my system through GPRS by turning arduino into web server. Can you give some suggestions to me for doing it.

  28. Sergio Monsalve says:

    Thanks for your soon answer.

  29. Ed says:

    Hi. I have used your tutorial and used the GSM module sucessfully.
    I now want to use the GSM module from another serial device. Can you tell me how to access and use the external pins.
    Many thnaks, Ed

    • John Boxall says:

      It’s just serial data on pins 2 and 3 of the shield. So communicate with your device at 9600 bps, 8N1 with the AT commands as used in the examples here.

  30. Minko says:

    Hi, John!

    I followed your tutorial and it was working great. Nevertheless, today I run example 26.1 again and there was something wrong. After SIND 1,10,11 and 3 (when SIND: 4 is supposed to come in) it just prints random symbols. I suppose it is some change in the baud rate but I don`t really know. Could you give me some advice?

    • John Boxall says:

      It won’t change the baud rate during operation, just check all your wiring, the antenna and external power supply, etc. Otherwise you might have a faulty shield.

  31. sam says:

    hi John,

    based on the great tutorial above, I had successfully implemented the GSM shied and DF Robot power shield a few months ago.

    yesterday whilst connecting my Arduino controller (complete with shields) into my project, I inadvertantly switched on/off the external power supply whilst the laptop USB was still connected to the Arduino. (yes, you warn against this in the tutorial)

    now the Arduino will not excecute the sketch. pin13 LED remains on all the time. Other test sketches won’t work either, I tried (Blink) and a pin HIGH sketch where I measured only a trickle voltage at the HIGH pin. The IDE appears to upload to Arduino ok as the Tx & Rx led’s do their flashing.

    I suspect I have damaged the board, is there any way to repair?

    Dingley VIC, AUST

    • John Boxall says:

      You could try a new microcontroller with Arduino bootloader if you have one spare, otherwise it’s new board time :\

  32. gili says:

    Hi John,

    First my appreciation for the guides (even though i said it before) I keep coming back to it as a reference.
    I Want to move on beyond SMS’s and do the GPRS part of the module. Do you if there’s any library/guide/ a really good and clear explanation about how to do it? what are the steps needed in order to get it work?
    I couldn’t find any reference, and the ones i did find are offline…
    Thank you very much.

  33. gili says:

    Hi John,

    I have seen those. And still no Luck…I think I will try with the terminal first…
    I would appreciate it very much if you could do a tutorial about GPRS also.


    • John Boxall says:

      Maybe, but don’t wait for me to do it.

    • Ben says:


      Ive made a quick instructable showing how I got http get via gprs


      I would like to build on it, also Also would like to make a library for the GSM module but it might take me a while.

      Like you gill I have had allot of trouble finding any good info

      • gili says:

        Hi ben,

        Thanks for the info. I did tried it out and there is inconsistency with the work of the module. Some times it connects sometimes not, but mostly it gets weird behavior. Such is this:
        +SOCKSTATUS: 1,1,0102,0,0,0
        Socket connected
        Sending HTTP packet…
        Wait, that’s not what we were expecting. We wanted “OK”
        the msg is:+STCPD:1
        Looping forever displaying cell module output…


        While through the terminal i don’t get it. I don’t even get the +STCPD:1 response from the server. Even though the socket status returns an ACK bytes. And if i’m tring to read the data that’s the answer:

        +SOCKSTATUS: 1,1,0102,9,9,0




        I did altered your code as i figure out a better way to get the module to connect. (if it doesn’t connect after 4 tries i close the connection and re-open and it immediately connects. If you have any suggestions about it, I would love to hear from you.


  34. Ben says:

    Gill – seems like your not getting an OK after you finish writing the http and send the completion character (GSMSerial.write(26);)
    I usually see an OK coming back after this, but your not, it seems the next message your getting is the “+STCPD:1” – dont know if maybe your using software serial and its missing the OK or what the reason for that might be but I dont suppose its a big deal, why not just remove the waitFor(“OK”); that appears immediately after (GSMSerial.write(26);), then it will stop waiting for ok and the next step was just to wait until a “+STCPD:1” anyway.

    GSMSerial.print(“User-Agent: “+useragent+”\r\n\r\n”); // SIZE: 16
    GSMSerial.write(26); // ctrl+z character: send the packet
    //waitFor(“OK”); – //Try removing this wait for ok!
    waitTil(“+STCPD:1”); // this means data is received

    • Ben says:

      Oops, its Gili not Gill, sorry.

      Message me via the Insructables post if you want to have a chat about it as I have had some more success recently and have gotten a fair bit of the library going for this GSM module.

      Excuse me John, not trying to hijack your page here, just hoping Gili and I can help each other nut out this module properly:)


    • gili says:

      Thanks Ben,

      I will.

  35. gili says:

    Hi Ben,

    I’ve sent you a message on instructable. My problem is that I don’t get the STCPD:1 from the server. Could it be that a dns server may be configure wrong? I also dont see the request on the server (john, I’m posting the question here for other users sake…)

  36. rocker switch says:

    I have an excited synthetic attention pertaining to detail and may foresee problems before they will take


Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: