GSM GPRS Shield V1.0
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/front1.gif
Contents
Overview
Hook your Arduino up to GSM/GPRS cell phone network with GPRS shield! You can use your Arduino or other main boards to dial a phone number or send a text to your friend via easy to use AT commands now. This board features a quad-band low power consumption GSM/GPRS module SIM900 as well as a compact GSM antenna. Meanwhile, improvements on interfaces and basic circuit have been taken to make it more concise and reliable. And there’re two choices for you to communicate GPRS shield with the main board -- UART or SoftwareSerial
Specifications
Compatible | Arduino UNO/Seeeduino directly ; Other main board via jumpers |
Selectable interface | UART, Software serial |
Quad band support | 850/900/1800/1900MHz |
Communication support | Standard - GSM 07.07 & 07.05 and Enhanced - SIMCOM AT Commands |
Operation temperature | -40°C to +85 °C |
Protocol support | 0710 MUX protocol, embedded TCP/UDP protocol, FTP/HTTP, FOTA, MMS, embedded AT |
Certification of SIM900 | CE, IC, FCC, ROHS, PTCRB, GCF, ICASA, REACH, AT&T |
Dimensions | 68.58 * 53.34mm |
Consumption Power supply | 6.5~12v via Vin pin |
Cautions
- Make sure your SIM card is activated.
- GPRS Shield doesn't come with ESD precautions. Take special care when handling it in dry weather.
- The factory default setting for the GPRS Shield UART is 19200 bps 8-N-1. (Can be changed using AT commands).
Introduction
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/GSM_PCB_PINOUT.jpg
- Serial port select
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/SerialSelection.jpg There’re two choices for you to communicate GPRS shield with the main board while plugging the two jumpers on to the SWserial or HWserial positions. If using SWserial, D2 and D3 will be used by SIM900 of GPRS Shield; if using HW serial, D0 (RX) and D1 (TX) will be used.
- Power on/off by D6
Unsolder pad JP default. Solder it if you wanna use software to power on/off the GPRS shield. Set the D6 to a high level, it means the button is pressing.
- Breakout of SIM900
Some pins of SIM900 are break out beside the ISP port, there're Line_R, Line_L, ADC, PWM1, PWM2, GND, FW_update , RI, LDCD, LDSR, LCTS, VDD_EXT, LDTR, LRTS, SCL, SDA. And those pins are pointed from SIM900 without any setting.
- RTC battery holder
The super capacitor power supply for the RTC. The RTC can work more than 1 day by the power supply of super capacitor. So the SIM900 can keep the time and day when power off.
- LED Status Description
LED | Status | Function |
---|---|---|
Power indicator (Green) | Off | Power of GPRS Shield is off |
On | Power of GPRS Shield is on | |
Status indicator (Red) | Off | Power off |
On | Power on | |
Net indicator (Green) | Off | SIM900 is not working |
64ms On/800ms Off | SIM900 does not find the network | |
64ms On/3000ms Off | SIM900 finds the network | |
64ms On/300ms Off | GPRS communication |
Examples/Applications
Getting Familiar With AT Commands
As you receive the GPRS Shield, what would be the first thing you want to do with it? Send out a text (SMS)? Or call up someone (headset required)? You can do all of this by talking to the GPRS Shield using AT Commands - a special language that it understands. AT Commands are simple textual commands sent to the GPRS modem over its serial interface (UART), so you can use any serial terminal software to communicate with it.
- Preparatory Work
Follow the steps below to set up the hardware system.
1. Insert an activated SIM card to SIM Card Holder A 6 Pin Holder for SIM Cards. Both 1.8 volts and 3.0 volts SIM Cards are supported by SIM900, the SIM card voltage type is automatically detected.
2. Check the antenna Make sure the antenna have installed properly in the antenna interface.
3. Communication port configuration The GPRS shield can be controlled via hardware serial port or software serial port of Arduino. Here we use the software serial port as default. Choose it by inserting jumper caps as below.
4. Plug to Arduino Stack the GPRS Shield onto Arduino.
5. Power up Arduino Power up Arduino by USB cable or DC Jack. The Power-on indicator LED should light up once connectted.
- Usage
Let's have a try to control the GPRS shield with AT commands. The GPRS Shield comes with all accessories that you need to get started with sending data over the GSM network except an Arduino board and a GSM SIM Card. If you want to make voice calls, you would also require a headset with microphone.
Step 1: Test Setup
1.Create a new Arduino sketch and paste the codes below to it.
//Serial Relay - Arduino will patch a //serial link between the computer and the GPRS Shield //at 19200 bps 8-N-1 //Computer is connected to Hardware UART //GPRS Shield is connected to the Software UART #include <NewSoftSerial.h> NewSoftSerial mySerial(2, 3); void setup() { mySerial.begin(19200); // the GPRS baud rate Serial.begin(19200); // the GPRS baud rate } void loop() { if(Serial.available()) { mySerial.print((unsigned char)Serial.read()); } else if(mySerial.available()) { Serial.print((unsigned char)mySerial.read()); } }
- If you are using Arduino 1.0 or later, use this sketch instead:
//Serial Relay - Arduino will patch a //serial link between the computer and the GPRS Shield //at 19200 bps 8-N-1 //Computer is connected to Hardware UART //GPRS Shield is connected to the Software UART #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); void setup() { mySerial.begin(19200); // the GPRS baud rate Serial.begin(19200); // the GPRS baud rate } void loop() { if (mySerial.available()) Serial.write(mySerial.read()); if (Serial.available()) mySerial.write(Serial.read()); }
Note : With Arduino 1.0 you should be able to use the SoftwareSerial library included with the distribution (instead of NewSoftSerial). However, you must be aware that the buffer reserved for incoming messages are hardcoded to 64 bytes in the library header, "SoftwareSerial.h": define _SS_MAX_RX_BUFF 64 // RX buffer size This means that if the GPRS module responds with more data than that, you are likely to loose it with a buffer overflow! For instance, reading out an SMS from the module with "AT+CMGR=xx" (xx is the message index), you might not even see the message part because the preceding header information (like telephone number and time) takes up a lot of space. The fix seems to be to manually change _SS_MAX_RX_BUFF to a higher value (but reasonable so you don't use all you precious memory!).
2. Upload the code to Arduino. If you do not know how to upload the code, please click here
3. Download and fire up serial tool if you don't have one. Choose the correct COM port for Arduino, and set it to operate at 19200 8-N-1 and then click "Open Com". You can also use AT Command Tester to send AT commands. Please click here if you are interested.
4. Power up the SIM900 by pressing the power button in about 2 seconds. The red LED will be on. The green one beside it will blink. If the shield join the network sucessfully, the green LED will blink every 3 seconds.
5. You should find the message on the serial monitor as below which is sent by the SIM900 to inform you it has joined the network:
RDY +CFUN: 1 +CPIN: READY Call Ready
If you can not see the messages in the serial monitor, you should click the "send new" option that will add carriage return at the end of AT command and then send AT command "AT+IPR=19200" to set the baud rate of the SIM900.
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/GPRS_set_baud_rate.jpg
Notice: How AT commands control the GPRS Shield
The ATmega328P microcontroller on Duemilanove board has only one UART which is used for communicating with the PC. What we need is an Arduino Sketch running inside the ATmega328P that would emulate a second serial port (UART) using software on the digital pins D2 and D3 and patch through all the communication between this second software serial port and the actual hardware serial port. By doing this, all the data coming from the computer (connected to the actual hardware UART) would be routed to the GPRS Shield (connected to software UART) then, we would be able to issue AT commands to control the GPRS Shield. The block diagram outlining this scheme is shown below.
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/500px-GPRS_aurduino_uart.jpg
Step 2: Send A Text Message (SMS)
Based on step 1, now we try to send a text message by using AT commands.
1. The GPRS Shield can send SMSes in two modes: Text mode and PDU (or binary) mode. To send out a human readable message, select the text mode by sending AT command "AT+CMGF=1". If succeeds, The GPRS Shield will respond with an OK.
2. To enter the number of your target phone, tick "SendNew" option and send AT+CMGS="136*****556". This will instruct the GPRS Shield to send a new message to the phone number specified (replace the number with the phone number of your target phone). The GPRS Shield will send a> to remind you of typing the message. Please note that phone number specified as parameter in any AT command must be in E.123 format.
3. After entering your message, tick "send hex" option and then send a hex: 1A. The modem will accept the message and respond with an OK. A few moments later, the message should be received on the handset whose number you had specified. I sent "How are you ?". You can check the histroy by clicking "EXT". The commands histroy is listed below "Set Multi Char".
http://shortcircuitdesigns.com/wp-content/uploads/2016/01/Send_a_text_message.jpg
NOTE: If, in spite of following the steps as specified above, you're unable to receive the message on the target handset, you might need to set the SMS Message Center number. Send the following command between the AT+CMGF and AT+CMGS commands:AT+CSCA="+919032055002". Replace the phone number specified with the SMS Center number of your GSM Service Provider. The message center number is specific to each service provider. You can get the message center number by calling up the customer care center of the GSM Service Provider and asking them for it.
Step 3: Make a telephone call with the AT commands 1. Restart the SIM900 if switching from sending texts to making phone calls.
2. Replace the phone number with your target number in the command “ATD186*****308;”(without the quotes) and press Enter key to send it out. If it succeds, a message "ATH OK" will show up as the picture below. Otherwise, "No CRRLIER" will show up instead. The reason might be unexistent phone number or incorrect command format.
Step 4: Exploring Further Now that you have gotten a taste of how the AT Commands work, you can try out some more of them by moving on to developing sketches for Arduino to use the GPRS Shield. This involves creating a sketch to send out a sequence of AT Commands to the GPRS Shield to perform tasks as sending an SMS, making a call or sending data over a GPRS connection. You can go through the AT Commands reference manual to figure out the sequence of commands required to do a particular task. If while developing an Arduino sketch, you find that the GPRS Shield doesn't execute what you have expected, check the AT Commands you sent to find out whether the spelling or sequence gets wrong. To do this, reload the serial relay sketch attached above in step 1 and type out the AT Commands manually and check the output. The responses sent by the GPRS Shield will help you debug the AT Command sequence.
Example 1: How To Send a Text Message or Dial a Phone Number Using AT Commands
In this example we will create an Arduino sketch to allow you to either send a text message or dial a phone number for a voice call when you either type 't' or 'd' respectively in the Arduino's serial comm window.
AT Commands For Sending a Text Message
Looking at the SIM900 Commands Set we can see that to send a text message we first have to set the SMS format, this is one using the AT+CMGF command.
The AT+CMGF command can be one of two values: 0, or 1 for "PDU mode" and "text mode" respectively. In "text mode", SMS messages are represented as readable text. In "PDU mode", SMS messages are represented as binary strings encoded in hexadecimal characters. We will use "text mode" in this example, so the command we need to the send to the GPRS shield is:
AT+CMGF=1\r
Now that we have set the SMS format we can proceed to send the text message. To send the text message we use the AT+CMGS command. According to the SIM900 AT Command Set, the CMGS command follows this format:
AT+CMGS=<da>[,<toda>]<CR>
where <da> is the destination address (phone number), <toda> is the optional type of destination address, and <CR> is the carriage return '\r' character. Once we have send this command the GPRS shield will reply with the '>' character signaling us to enter the actual message.
Note: The phone number must include the country code, e.g. for a U.S. phone number (555)123-4567 the <da> value must be +15551234567
Command(s) For a Voice Call As per the SIM900 AT Command Set sheet, the command used to dial a number for a voice call is "ATD+xxxxxxxxxx;" where "xxxxxxxxxxx" is the phone number with country code included. A semicolon must be send to set up a voice call, omitting it will set up a data or fax call. The Arduino code to send a simple text message or dial a voice call is shown below. Don't forget to change the phone number "xxxxxxxxxx" and message "How are you today?" to your own values.
Arduino Code:
/* GSM Shield example created 2011 by Boris Landoni This example code is in the public domain. http://www.open-electronics.org http://www.futurashop.it */ #include <GSM_Shield.h> //************************************************************************** char number[]="+39123456789"; //Destination number char text[]="hello world"; //SMS to send byte type_sms=SMS_UNREAD; //Type of SMS byte del_sms=0; //0: No deleting sms - 1: Deleting SMS //************************************************************************** GSM gsm; char sms_rx[122]; //Received text SMS //int inByte=0; //Number of byte received on serial port char number_incoming[20]; int call; int error; void setup() { Serial.begin(9600); Serial.println("system startup"); gsm.TurnOn(9600); //module power on gsm.InitParam(PARAM_SET_1);//configure the module gsm.Echo(0); //enable AT echo } void loop() { char inSerial[5]; int i=0; delay(2000); Check_Call(); //Check if there is an incoming call Check_SMS(); //Check if there is SMS //Check data serial com if (Serial.available() > 0) { while (Serial.available() > 0) { inSerial[i]=(Serial.read()); //read data i++; } inSerial[i]='\0'; Check_Protocol(inSerial); } } void Check_Protocol(String inStr) { Serial.print("Command: "); Serial.println(inStr); Serial.println("Check_Protocol"); switch (inStr[0]) { case 'a' : //Answer if (gsm.CallStatus()==CALL_INCOM_VOICE){ gsm.PickUp(); Serial.println("Answer"); } else { Serial.println("No incoming call"); } break; case 'c': // C //Call if (inStr.length()<2) //To call variable 'number' comand c { Serial.print("Calling "); Serial.println(number); gsm.Call(number); } if (inStr.length()==2) //To call number in phone book position comand cx where x is the SIM position { error=gsm.GetPhoneNumber(inStr[1],number); if (error!=0) { Serial.print("Calling "); Serial.println(number); gsm.Call(number); } else { Serial.print("No number in pos "); Serial.println(inStr[1]); } } break; case 'h': //H //HangUp if there is an incoming call if (gsm.CallStatus()!=CALL_NONE) { Serial.println("Hang"); gsm.HangUp(); } else { Serial.println("No incoming call"); } break; case 's': //S //Send SMS Serial.print("Send SMS to "); Serial.println(number); error=gsm.SendSMS(number,text); if (error==0) //Check status { Serial.println("SMS ERROR \n"); } else { Serial.println("SMS OK \n"); } break; case 'p': //Read-Write Phone Book if (inStr.length()==3) { switch (inStr[1]) { case 'd': //Delete number in specified position pd2 error=gsm.DelPhoneNumber(inStr[2]); if (error!=0) { Serial.print("Phone number position "); Serial.print(inStr[2]); Serial.println(" deleted"); } break; case 'g': //Read from Phone Book position pg2 error=gsm.GetPhoneNumber(inStr[2],number); if (error!=0) //Find number in specified position { Serial.print("Phone Book position "); Serial.print(inStr[2]); Serial.print(": "); Serial.println(number); } else //Not find number in specified position { Serial.print("No Phone number in position "); Serial.println(inStr[2]); } break; case 'w': //Write from Phone Book Position pw2 error=gsm.WritePhoneNumber(inStr[2],number); if (error!=0) { Serial.print("Number "); Serial.print(number); Serial.print(" writed in Phone Book position "); Serial.println(inStr[2]); } else Serial.println("Writing error"); break; } } break; } delay(1500); return; } void Check_Call() //Check status call if this is available { call=gsm.CallStatus(); switch (call) { case CALL_NONE: Serial.println("no call"); break; case CALL_INCOM_VOICE: gsm.CallStatusWithAuth(number_incoming,0,0); Serial.print("incoming voice call from "); Serial.println(number_incoming); break; case CALL_ACTIVE_VOICE: Serial.println("active voice call"); break; case CALL_NO_RESPONSE: Serial.println("no response"); break; } return; } void Check_SMS() //Check if there is an sms 'type_sms' { char pos_sms_rx; //Received SMS position pos_sms_rx=gsm.IsSMSPresent(type_sms); if (pos_sms_rx!=0) { //Read text/number/position of sms gsm.GetSMS(pos_sms_rx,number_incoming,sms_rx,120); Serial.print("Received SMS from "); Serial.print(number_incoming); Serial.print("(sim position: "); Serial.print(word(pos_sms_rx)); Serial.println(")"); Serial.println(sms_rx); if (del_sms==1) //If 'del_sms' is 1, i delete sms { error=gsm.DeleteSMS(pos_sms_rx); if (error==1)Serial.println("SMS deleted"); else Serial.println("SMS not deleted"); } } return; }
Resources
SIM900_AT Command Manual_V1.03
Licensing
This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.