How to interface GSM/GPRS Shield (SIM900A/SIM900/SIM800) To an Arduino
Introducing rhydoLABZ GSM/GPRS Shield, an all-in-one cellular shield that lets you add voice, text/SMS, data and bluetooth* connectivity to your arduino project in an easy to use pluggable shield. This cellular shield from rhydoLABZ is available as three different variants, built with different cellular engines (SIM900, SIM900A and SIM800). All of these are identical in features except that the SIM900 and the SIM800 are quadband versions (operates in 850/900/1800/1900 MHz), while SIM900A is the dualband version (operates in 900/1800 MHz) . And additionally SIM800 has an added features, bluetooth connectivity. All the three variants are pretty much identical in its formfactor and design. These fits on top of any classic Arduino or compatible, and packs a surprising amount of technology into it’s little frame.
The GSM/GPRS Modem is having internal TCP/IP stack to enable you to connect with internet via GPRS. The shield is manufactured with Automatic Pick and place machine to meet the high quality standards. On its own, this shield can’t do anything. It requires a microcontroller like an Arduino to drive it! Additionally a SIM Card with cellular connectivity! The shield can be powered either via Arduino or directly over RMC connector. It comes presoldered with 3.5mm jack for audio out as well as mic in. You can grab some stacking headers from our store, if you would like to stack a shield on top.
Features
- AT command interface
- Quad-band and Dual-band variants*
- Make and receive voice calls
- Send and receive SMS messages
- Send and receive GPRS data (TCP/IP, HTTP, etc.)
- Bluetooth: compliant with 3.0+EDR*
- USB Connector for Firmware Updation*
- Configurable Baud rate (9600-115200, factory default value: 9600)
- Standard Audio Jack Connectors for external speaker and mic
- Selectable interface between hardware serial port and software serial port
- Inbuilt Powerful TCP/IP protocol stack for Internet data transfer over GPRS.
- Level shifting circuitry to make it Arduino-safe
- SMA Connector with external antenna
- Indicator LEDs for Power and connectivity
- Standard Flap type SMA Socket
- ESD Protection over TVS Zener array
- Separate Reset switches for both Arduino and the shield
- Slide switch to swap the shield between Arduino and PC
- Provision to select between hardware and software serial ports
NOTE: Shield has inbuilt voltage regulation circuitry and reverse polarity protection, allows you to connect wide range unregulated power supply (7V – 12V)
SIM900A, SIM900 & SIM800
SIM800 modules are upgraded version of its previous successful GSM/GPRS/GPRS module series SIM900. There are multiple sub versions of each series, each of which cater to a different set of users and applications. SIM900 comes in the form of full version Quad band SIM900 & dual band version SIM900A. SIM800 itself is the full version Quad band SIM800. There are other SIM800 & SIM900 versions but very less information available about them, so they have not been discussed.
What extra does SIM800 modules give me compared to SIM900 series modules? SIM800 GSM modules have a inbuilt Bluetooth stack, accessible using AT commands.
SIM900 and SIM900A modules operate from 3.2V to 4.8V supply range while SIM800 modem operates from 3.4V to 4.4V supply range (Reduced operating range!). Same AT commands used for simple call/sms functionality in SIM900, SIM900A can be used with the SIM800, but SIM800 series have added AT command set for supporting extra features like bluetooth.
SIM800 module is needed only if you need those additional features that are not present in SIM900 series modules, like the Bluetooth functionality which was missing in SIM900 series. SIM800 and SIM900 can be operated worldwide because they can operate in all four GSM bands used across the world.
Layout
LED Indications
The Network LED indicates the various status of GSM module eg. Power on, Network registration & GPRS connectivity. When the modem is powered up, this NETWORK LED will blink every second. After the Modem registers in the network (takes between 10-60 seconds), this LED will blink in step of 3 seconds. At this stage you can start using Modem for your application,showing that modem is registered with the network.
Connection Interfaces
Jumper Connections
Selecting Hardware Serial / Software Serial for communication
The shield is designed such that the GSM module communicates with Arduino either via Hardware serial / Software pins as selected by J3, J4. By default, the shield comes with Hardware serial communication i.e, the GSM module communicates with Arduino via Hardware serial pins [D0 – RX, D1 – TX]. On the other hand, if J3, J4 are shifted to Software serial side, then the GSM module communicates with Arduino via software serial pins [with D8 configured as software RX and D7 as software TX , Refer the code snippet given below]
PKEY using Arduino
PWRKEY pin of GSM modem is to turn modem On/Off externally using open collector transistor or switch. You can turn on/off the modem alternately by driving the PWRKEY to a low level voltage for a short time (2-3 sec) and then release. This pin is pulled up to 2.9V in the GSM Modem.
In the shield, it is connected to digital pin 9 of Arduino via jumper J10. Shorting the jumper and removing R16 from board enables you to power on /off the modem by Arduino.
RST using Arduino
RST pin of GSM modem is active low. In the shield, it is connected to digital pin 10 of Arduino via jumper J11. Short J11 and make the pin 10 HIGH to reset the modem.
Audio Jacks
The Shield contains two audio stereo jacks on board. The first is the audio input jack (labeled “MIC”). This allows you to input audio from any device such as an MP3 player, or cellular phone using a basic audio cable. The second audio jack is the audio output, labeled “SPEAKER”. This jack allows you to route the audio out to a speaker.
Getting Started
Lets check out on getting started with this shield on Arduino.
- Insert an activated SIM Card to the SIM Socket (K5), provided on the bottom side of the shield.
- Make sure if the antenna is installed properly
- Confirm the Jumper connection for the communication port (Software or Hardware -J3,J4)
- Adjust the slide switch as desired (USB – to communicate with the PC directly without an ATmega328 on your Uno, Arduino – to communicate with the ATmega328 on your Uno)
- Stack the shield and power up the Arduino
Test your shield
Having familiarized with the shield, now its time to use it for practical applications. What would be the first thing you want to do with it? Send out a text (SMS)? All of these can be done using the AT Commands – mother tongue for cellular modules. These are simple textual commands sent to the modem over its serial interface, which makes it easy to communicate with the modem over any serial terminal software.
- Copy the given code and paste it in a new sketch on your Arduino IDE. To run the code, the slide switch should be on the USB side and J3, J4 should be shifted to S-RX & S-TX respectively. Compile and burn it to your Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//Arduino will patch a serial link between the computer and Shield at 9600 bps 8-N-1 //Computer is connected to Hardware UART and the Shield is connected to the Software UART #include <SoftwareSerial.h> SoftwareSerial SimShield(8, 7); // Shield is connected to Arduino via softwareserial port unsigned char buffer[64]; // Buffer array for data recieve over serial port int count = 0; // Counter for buffer array void setup() { SimShield.begin(9600); // The SimShield baud rate Serial.begin(9600); // The Serial port of Arduino baud rate. } void loop() { if (SimShield.available()) // If data is coming from softwareserial port ==> data is comming from gprs shield { while(SimShield.available()) { buffer[count++] = SimShield.read(); // Writing data into array if(count == 64)break; } Serial.write(buffer,count); // If no data transmission ends, write buffer to hardware serial port clearBufferArray(); // Call clearBufferArray function to clear the stored data from the array count = 0; // Set counter of while loop to zero } if (Serial.available()) // If data is available on hardwareserial port ==> data is comming from PC or notebook SimShield.write(Serial.read()); // Write it to the SimShield shield } void clearBufferArray() // Function to clear buffer array { for (int i=0; i<count; i++) buffer[i] = NULL; // Clear all index of array with command NULL } |
- Now open up the Arduino serial monitor with the com port connected to Arduino and baud rate set as 9600. Start sending AT commands over the serial monitor to communicate with the shield, and you will get back the response from the shield. Make sure to add up carriage return while sending commands.
If you are using the shield over the hardware uart pins, then you could use the below given code on your Uno to send out a test message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
void setup() { Serial.begin(9600); delay(500); } void loop() { Serial.print("AT\r"); delay(500); Serial.print("AT+CMGF=1\r"); // Set the shield to SMS mode delay(500); // send sms message, the phone number needs to include the country code e.g. For an Indian contact such as 9876543210 then the string must be: // +919876543210 Serial.println("AT+CMGS = \"+xxxxxxxxxx\""); delay(500); Serial.println("Test Message"); //the content of the message delay(500); Serial.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet) delay(500); while(1); } |
Resources
- AT Commands (SIM900A/SIM900)
- AT Commands (SIM800)
- Datasheet (SIM900)
- Datasheet (SIM800)
Shop with us
- Cellular Shield – SIM900A
- Cellular Shield – SIM900
- Cellular Shield – SIM800
- Arduino Uno
- Arduino Starter Kit
*NOTE: Kindly note that the quad band variants of the shield comes with SIM900 and SIM800, whereas SIM900A is the dualband version. The Bluetooth functionality and USB debug features are available on the SIM800 variant only. Certain features such as display interface, PWM output etc requires customization of the firmware.
1 2 |
Serial.print("AT\r"); delay(100); |
Leave a Reply
You must be logged in to post a comment.