Please note: I am based in the UK and the following works with Orange and O2 pre-pay sim cards. The situation where you are may be different!
The Seeedstudio SIM900 based GSM/GPRS shield for Arduino is a popular and easy to use accessory. However, it can be daunting to first time users so here is my simple guide to getting things working. We first check that we can communicate with the shield, and then we will turn a LED, connected to D10, on and off using text messages / SMS. Perhaps at this stage I should mention that this is just a demonstration of how to achieve this, and is not representative of best programming practice. In the real world, don't use delay()!
Despite what is written in the specifications the SIM900 can momentarily draw about 2 amps when operating. The USB power supply to the Arduino will not suffice! For development work I have a 5 volt 2 amp power supply plugged into the shield, and a separate 9 volt 1 amp power supply into the Arduino. Set the power select switch to the appropriate position, either Xduino or Ext.
Once the shield has been powered up and completed its self check it will start to search for a network signal. During this process the NetLight indicator will blink rapidly, once a second. When a signal is acquired it will then blink once every three seconds.
So we need a robust power supply, an unlocked SIM card, our shield, an LED with an appropriate resistor and our Arduino of choice.
Our first decision is do we want to enable software power control? Initially this might not sound like a difficult decision but think about it for a moment. The same procedure will turn the shield on if it is off and off if it is on. So, if, when you are testing, you reset your Arduino without turning off the shield then it will send the power on/off command and turn the the shield off. So I would suggest that until you are comfortable with the shield leave the pad near pins D8 & D9 (illustrated below) unsoldered and use the PWRKEY switch to turn it on or off.
When your project is up and running you may want to incorporate software control. If so, solder the two pads together and add the following section to your code:
And then put a call to the procedure in setup().
Arduino Uno (etc)
Using the shield with the Uno is comparatively straight forward. We can use the USB connection to communicate with the board, and use SoftwareSerial on pins D7 & D8 to communicate with the shield. Ensure that the jumpers, adjacent to the aerial connector, are to the right as per the main illustration.
Check that it works
The first job is to ensure that we can communicate with the shield. To do that we will use a fairly common piece of software called Serial Relay (sadly I don't know who wrote it to give credit). This piece of software relays any commands sent from the Serial Monitor to the Arduino on to the SIM900, and sends anything from the SIM900 to the Arduino on to the Serial Monitor. Don't worry about the 8-N-1, that is the default setting, and if you have been playing with that you probably don't need to be reading this introduction!
I have removed quite a lot of the original comments. If you don't understand how it works there are several versions on the internet.
So upload this sketch to the Arduino, connect the shield and start up the Serial Monitor (at 19200 baud)
Wait until the green network led is blinking every three seconds, and then type the letters AT into the command bar,
and click the 'Send' button. The sketch will send the command on to the SIM900, which will (hopefully) in turn respond...
We are in business!
At this stage you may wish to
1) Download a manual of SIM900 AT commands and have a play around with the device.
2) Issue the AT&F command to reset the device to the factory settings.
Now we shall get on with the process of receiving and acting upon a SMS / text message.
I traced some of this code back to http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/
Using the shield with the hardware port isn't as straightforward as the Uno, but it is by no means difficult.
Instead of using SoftwareSerial we will use Serial1, and use two jumpers to connect the output of the SIM900 to the Mega. Connect shield D7 to Mega 19 (Rx1) and shield D8 to Mega 18 (Tx1)
Set the jumper pins (shown below) on the shield to the 'SWserial' position.
First the code for Serial Relay
And now the code for receiving and acting upon the instruction:
In either case upload the sketch to the Arduino before assembling the shield and led.
Now if you text the message '#a0' to the shield it should turn the led off, and '#a1' will turn it on. If it doesn't then check that the led is the right way round and connected to the correct pin. If all seems in order dismantle the project, remove the SIM card and place in a mobile phone so you can inspect the messages received. Hence why we don't delete the messages once we have processed them! Once you have everything working you can reinstate the line that deletes the messages. The typical SIM card can hold around 50 standard text messages.
Now you can go away and learn how to use the other AT commands to control the shield. Search online for 'SIM900 AT Commands'.
Send a text / sms
In response to questions, a simple way to send a message. It is meant to show how to, rather than a stand alone sketch. If you do want to try it, change the destinationNumber to your own, and upload to the sketch to the Arduino. Attach shield and apply power. Every time you reset the Arduino it will send the message!
This is for the Uno. I'm sure you can now make the necessary changes if you have a Mega.