Arduino Cellular Shield Tutorial
by randofo in Circuits > Arduino
97457 Views, 503 Favorites, 0 Comments
Arduino Cellular Shield Tutorial
![2A.jpg](/proxy/?url=https://content.instructables.com/F6E/GBQ4/HFD1DEO3/F6EGBQ4HFD1DEO3.jpg&filename=2A.jpg)
The Arduino Cellular Shield allows you to make cellular telephone calls, and send text messages. The brains of this shield is the SM5100B which is a robust cellular module capable of performing many of the tasks of most standard cell phones. This shield requires use of a SIM card to connect to a cellular network. The tutorial that follows is a bare bones tutorial for initializing the shield, and both sending and receiving text messages, and telephone calls. To learn more about the module's functionality, be sure to check out the datasheets on Sparkfun's product page.
Go Get Stuff
![1A.jpg](/proxy/?url=https://content.instructables.com/FUN/7ACI/HFBK6WW2/FUN7ACIHFBK6WW2.jpg&filename=1A.jpg)
You will need:
(x1) Cellular shield
(x1) Stackable Arduino headers
(x1) Quad band antenna
(x1) Arduino Uno
(Note that some of the links on this page are affiliate links. This does not change the cost of the item for you. I reinvest whatever proceeds I receive into making new projects. If you would like any suggestions for alternative suppliers, please let me know.)
Solder Headers
![2A.jpg](/proxy/?url=https://content.instructables.com/FKP/389B/HFBK9VYM/FKP389BHFBK9VYM.jpg&filename=2A.jpg)
![2B.jpg](/proxy/?url=https://content.instructables.com/FBB/IQ78/HFBJWDZ5/FBBIQ78HFBJWDZ5.jpg&filename=2B.jpg)
![2C.jpg](/proxy/?url=https://content.instructables.com/FC5/NMWS/HFBK6WW8/FC5NMWSHFBK6WW8.jpg&filename=2C.jpg)
Insert the headers into the shield and solder them into place.
Insert
![3A.jpg](/proxy/?url=https://content.instructables.com/FRB/553S/HFBK6XKK/FRB553SHFBK6XKK.jpg&filename=3A.jpg)
![3B.jpg](/proxy/?url=https://content.instructables.com/FR1/2QGG/HFBKEJO1/FR12QGGHFBKEJO1.jpg&filename=3B.jpg)
Resolder
![4A.jpg](/proxy/?url=https://content.instructables.com/FAR/GW8C/HFBKEJYK/FARGW8CHFBKEJYK.jpg&filename=4A.jpg)
Attach the Antenna
![5A.jpg](/proxy/?url=https://content.instructables.com/FPP/M3NM/HFBK2BS6/FPPM3NMHFBK2BS6.jpg&filename=5A.jpg)
![5B.jpg](/proxy/?url=https://content.instructables.com/FB7/V3MX/HFBKAFXZ/FB7V3MXHFBKAFXZ.jpg&filename=5B.jpg)
Insert SIM Card
![6B.jpg](/proxy/?url=https://content.instructables.com/FZ8/PVWC/HFBJS0ZS/FZ8PVWCHFBJS0ZS.jpg&filename=6B.jpg)
![6C.jpg](/proxy/?url=https://content.instructables.com/F3F/1FA5/HFBK9098/F3F1FA5HFBK9098.jpg&filename=6C.jpg)
![6D.jpg](/proxy/?url=https://content.instructables.com/FVJ/YYK1/HFBJS13W/FVJYYK1HFBJS13W.jpg&filename=6D.jpg)
![6A.jpg](/proxy/?url=https://content.instructables.com/F3B/NLUV/HFBK9XPS/F3BNLUVHFBK9XPS.jpg&filename=6A.jpg)
Initialize
![7A.jpg](/proxy/?url=https://content.instructables.com/FND/WJ0Q/HFBK6Y50/FNDWJ0QHFBK6Y50.jpg&filename=7A.jpg)
Open the serial port in the terminal. On a Mac this is accomplished by typing:
screen /dev/tty.usbmodemfa131 9600
(replace tty.usbmodemfa131 with your Arduino's serial address)
Wait to see the following sequence returned:
Starting SM5100B Communication...
+SIND: 3
+SIND: 4
+SIND: 11
(If this sequence is not returned check the error codes listed at the bottom of the code above, and debug appropriately. You may need to set the module for North American usage -- see below -- before it registers to network (i.e. +SIND 11))
Send the following commands to the serial port:
Send this for North American usage:
AT+SBAND=7
Set the current time - yy/mm/dd:
AT+CCLK="13/05/15,11:02:00"
Send test call:
ATD4155551212
Text Messages
![8A.jpg](/proxy/?url=https://content.instructables.com/F3B/PREA/HFBKAGY5/F3BPREAHFBKAGY5.jpg&filename=8A.jpg)
Download and install SerialGSM into your Arduino library.
To send a text message visit the Tronixstuff cellular module tutorial and use example code 26.3:
http://tronixstuff.wordpress.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/
If you would like to run the example code to receive a text, connect an LED to pin 8 and put it in series with a 220 ohm resistor to ground.
To send a text message visit the Tronixstuff cellular module tutorial and use example code 26.5:
http://tronixstuff.wordpress.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/
Text one of the following commands to your cellular module:
//turns the LED on
#a1
//turns the LED off
#a0
Voice
![9A.jpg](/proxy/?url=https://content.instructables.com/F21/HXMM/HFBJVZHF/F21HXMMHFBJVZHF.jpg&filename=9A.jpg)
![9B.jpg](/proxy/?url=https://content.instructables.com/F24/1QQ4/HFBJS18R/F241QQ4HFBJS18R.jpg&filename=9B.jpg)
![9C.jpg](/proxy/?url=https://content.instructables.com/FVR/PL5Y/HFBK9XTA/FVRPL5YHFBK9XTA.jpg&filename=9C.jpg)
Connect a microphone and speaker to the shield using grounded audio cable. The center signal wire should go to the audio plus terminals and the shielding should go to the respective negative terminals on the shield. These cables should be connected similarly on the microphone and speaker side.
To initialize a voice call upload the following code:<pre>//********************************************************************************** // MAKE A CALL // // BUFFERING CODE BASED UPON: // <a href="http://jayeshprojects.blogspot.com/2010/04/real-time-mobile-gps-tracker-with.html"> http://jayeshprojects.blogspot.com/2010/04/real-t...> // //********************************************************************************** #include <SoftwareSerial.h> #define BUFFSIZ 90 //Set up buffer array char at_buffer[BUFFSIZ]; char buffidx; //Network state variables int network_registered; int network_AT_ready; //Code state variables int firstTimeInLoop = 1; int firstTimeInOtherLoop = 1; int x; //Will hold the incoming character from the Serial Port. char incoming_char=0; //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin. SoftwareSerial cell(2,3); void setup() { //Initialize Arduino serial port for debugging. Serial.begin(9600); //Initialize virtual serial port to talk to Phone. cell.begin(9600); //Hello World. Serial.println("Starting SM5100B Communication..."); delay(1000); //Set initial network state network_registered = 0; network_AT_ready = 0; } //Read AT strings from the cellular shield void readATString(void) { char c; buffidx= 0; // start at begninning for (x = 0; x < 10000; x ++) { if(cell.available() > 0) { c=cell.read(); if (c == -1) { at_buffer[buffidx] = '\0'; return; } if (c == '\n') { continue; } if ((buffidx == BUFFSIZ - 1) || (c == '\r')){ at_buffer[buffidx] = '\0'; return; } at_buffer[buffidx++]= c; } } } //Process the AT strings void ProcessATString() { if( strstr(at_buffer, "+SIND: 8") != 0 ) { network_registered = 0; Serial.println("network Network Not Available"); } if( strstr(at_buffer, "+SIND: 11") != 0 ) { network_registered=1; Serial.println("network Registered"); } if( strstr(at_buffer, "+SIND: 4") != 0 ) { network_AT_ready=1; Serial.println("network AT Ready"); } } void loop() { /* If called for the first time, loop until network and AT is ready */ if(firstTimeInLoop == 1) { firstTimeInLoop = 0; while (network_registered == 0 || network_AT_ready == 0) { readATString(); ProcessATString(); } } //LET'S MAKE A PHONE CALL! if(firstTimeInOtherLoop == 1){ //Change the 10 digit phone number to whatever you wish cell.println("ATD4155551212"); firstTimeInOtherLoop = 0; } }To receive a voice call upload the following code:
<pre>//********************************************************************************** // ANSWER A CALL // // BUFFERING CODE BASED UPON: // <a href="http://jayeshprojects.blogspot.com/2010/04/real-time-mobile-gps-tracker-with.html"> http://jayeshprojects.blogspot.com/2010/04/real-t...> // //********************************************************************************** #include <SoftwareSerial.h> #define BUFFSIZ 90 //Set up buffer array char at_buffer[BUFFSIZ]; char buffidx; //Network state variables int network_registered; int network_AT_ready; //Code state variables int firstTimeInLoop = 1; int firstTimeInOtherLoop = 1; int x; //Will hold the incoming character from the Serial Port. char incoming_char=0; //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin. SoftwareSerial cell(2,3); void setup() { //Initialize Arduino serial port for debugging. Serial.begin(9600); //Initialize virtual serial port to talk to Phone. cell.begin(9600); //Hello World. Serial.println("Starting SM5100B Communication..."); delay(1000); //Set initial network state network_registered = 0; network_AT_ready = 0; } //Read AT strings from the cellular shield void readATString(void) { char c; buffidx= 0; // start at begninning for (x = 0; x < 10000; x ++) { if(cell.available() > 0) { c=cell.read(); if (c == -1) { at_buffer[buffidx] = '\0'; return; } if (c == '\n') { continue; } if ((buffidx == BUFFSIZ - 1) || (c == '\r')){ at_buffer[buffidx] = '\0'; return; } at_buffer[buffidx++]= c; } } } //Process the AT strings void ProcessATString() { if( strstr(at_buffer, "+SIND: 8") != 0 ) { network_registered = 0; Serial.println("network Network Not Available"); } if( strstr(at_buffer, "+SIND: 11") != 0 ) { network_registered=1; Serial.println("network Registered"); } if( strstr(at_buffer, "+SIND: 4") != 0 ) { network_AT_ready=1; Serial.println("network AT Ready"); } } void loop() { /* If called for the first time, loop until network and AT is ready */ if(firstTimeInLoop == 1) { firstTimeInLoop = 0; while (network_registered == 0 || network_AT_ready == 0) { readATString(); ProcessATString(); } } if(firstTimeInOtherLoop == 1){ //Look for incoming call if( strstr(at_buffer, "+CPAS: 3") != 0 ) { //Answer the phone cell.println("ATA"); firstTimeInOtherLoop = 0; } } }
![](/proxy/?url=https://content.instructables.com/FP8/ABPR/K9R2LUOD/FP8ABPRK9R2LUOD.jpg?auto=webp&crop=1:1&frame=1&width=320)
Did you find this useful, fun, or entertaining?
Follow @madeineuphoria to see my latest projects.