Tutorial – Arduino Uno and SM5100B GSM Cellular

Shield is now obsolete. Contact your hardware supplier for support.

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:1
    +SIND:10, “SM”,1,”FD”,1,…..(all with 1)
    +SIND:0
    +SIND:3
    +SIND:4
    +SIND:7

  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

    Sincerely,
    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.

        Sincerely,
        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:

    Hello!
    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.
    Thanks!

  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:

    Hi,
    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
    Gil

    • 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?
    Thanks.

    • 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!
    AR

    • 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
        #include

        #define PINNUMBER “”

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

        void setup()
        {
        // initialize serial communications and wait for port to open:
        Serial.begin(9600);
        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
        while(notConnected)
        {
        if(gsmAccess.begin(PINNUMBER)==GSM_READY)
        notConnected = false;
        else
        {
        Serial.println(“Not connected”);
        delay(1000);
        }
        }

        Serial.println(“GSM initialized”);
        }

        void loop()
        {

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

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

        // send the message
        sms.beginSMS(remoteNum);
        sms.print(txtMsg);
        sms.endSMS();
        Serial.println(“\nCOMPLETE!\n”);
        }

        /*
        Read input serial
        */
        int readSerial(char result[])
        {
        int i = 0;
        while(1)
        {
        while (Serial.available() > 0)
        {
        char inChar = Serial.read();
        if (inChar == ‘\n’)
        {
        result[i] = ”;
        Serial.flush();
        return 0;
        }
        if(inChar!=’\r’)
        {
        result[i] = inChar;
        i++;
        }
        }
        }
        }

  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:

    Hello,
    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?
    Regards,
    Gili

    • 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!!!
      Gili

      • 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:

    John,
    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?

    Sam
    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.
    Regards,
    Gili

  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.

    Gil.

    • John Boxall says:

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

    • Ben says:

      Gill,

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

      http://www.instructables.com/id/SM5100B-GPRS-and-General-Notes/

      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
      Ben

      • 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…
        +STCPD:1
        Wait, that’s not what we were expecting. We wanted “OK”
        the msg is:+STCPD:1
        Looping forever displaying cell module output…

        OK.

        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

        OK

        +SDATA:1,0,

        OK

        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.

        Gil

  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:)

      Ben

    • 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
    place.

Trackbacks/Pingbacks


July 2016 – tronixstuff.com is on hiatus

There may not be any more updates, comment moderation or email replies for some time.

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: