This page tells you how to connect your GSM module to a AVR or Arduino Microcontroller. For a overview of what you need to get in terms of sim cards and data plans read up on that here:
For code examples see here:
To connect most GSM modules to microcontrollers a serial connection is utilized, the problem with this can be if you are using a microcontroller thats running at a hiiger voltage than the GSM module the serial logic levels will be off.
Every module has specifications for its serial port and they have to be followed in order to have a working communications system (the below specifications are from a GE863 Telit model):
Each input and output is described with a Min and Max level, what this means is between the two specifications is where the input state will trigger or the output voltage will range between. Soas you can see the GSM will read a logic low between 0-.5V and will output a logic high between 2.2-3V. So our microcontroller needs to have these same voltage levels to talk with the GSM.
Logic levels are very important and can determine the quality of serial communication you have to take into account the HIGH logic level AS WELL AS THE LOW logic level to get a good connection.The GSM modules usually have aLogic Level of 2.8v CMOS compatible, because they are designed to run off a single cell Lith ion battery. So if you are running your microcontroller at another voltage than ~3V you will need to change the logic levels. Below are a few ways you can hook up your boards to a GSM.
The below examples show you how to connect microcontrollers running at different voltages to a GSM module (or any serial device)
If the microcontrolller you are using is running at 2.8-~3.3V, you can probably get away without using a level conversion circuit, just check to see that the range of your microcontroller matches with the GSMs,
As you can see if you run the ATMEGA644P at 3.0V:
On the Microcontroller: *The input Low level (VIL) is rated -> -.5 to .3(Vcc) and the *The input High level (VIH) is rated -> .6(VCC) to (.5 + VCC) so if VCC = 3V *we get -.5 - .9V for the range of the Low voltage Input. and *we get 1.8V - 3.5V for the Input High range. On the Telit: *The Output Low level (VOL) is 0 - 3.5V and *The Output High level (VOH) is 2.2 - 3.0V We then compare the Microcontrollers input to the Telits output levels, Microcontroller TELIT -.5 - .9 (VIL) -> (VOH) is 0 - 3.5V 1.8V - 3.5V (VIH) -> (VOL) is 2.2 - 3.0V Then do the same thing for the output of the microcontroller to the input of the Telit. And find that they will trigger just fine.
So to hook the device up in this case you would just connect the RX and TX together and make sure they share a common ground.
These devices need a Logic conversion circuit in order to operate. The voltages on the microcontroller need to be shifted up or down accordingly to match the telits range and visa versa. This can be done in a couple ways:
There are many ways you can do logic conversion most involve using a comparator of some sort but you can also use transistor arrays or a zener diode to accomplish the feat. I will show you first a real hack way that you can get going with parts from radio shack and then I will show you the more proper way that we use on our boards here at Groundlab as well as from places like the ever amazing spark fun.
The first is a mess of a circuit I put together to get a arduino mega talking with a Telit module using a Spark fun development board. The circuit is a bit wild but it shows two ways of doing logic conversions, the comparator and the Zener diode.
As you can see there is a Arduino mega(blue running @ 5V) and a GSM(red running @ 3.6V) the third board is the logic conversion board(yellow). The circuit is made up of a LM311N comparator chip and a zener diode with a couple resistors thrown in the mix.
The comparator works by comparing two voltages on two inputs and biasing the output high or low according to which input is higher. So the way it is used in this circuit is to raise up the voltage of the GSM output (Telit RXD normal TX) to the input level of the Arduino mega. The way we accomplish this is to use a voltage divider on one of the inputs which floats the voltage near the max voltage the LOW logic level will output from the GSM. This level is compared to the output of the GSM serial line (Telit RXD normal TX), if the voltage on that line is LOWER than the voltage on the voltage divider the output will be pulled Low(to GND) and the microcontroller will read a LOW logic level. If the voltage out (Telit RXD normal TX) is larger than the dividers level the output is released and the 10K pull up resistor brings the output high, registering a HIGH on the microcontroller.
To figure out what voltage level the voltage divider needs to be at and what resistors to use, we employ the ever-ready ohms law (Voltage = current*resistance or V=I*R):
So once again we check the Telits documentation to find the LOW LEVEL threshold:
and see it is .35V this is a good place to set your threshold, but since I only had a certain set of resistors with me that day I set it at about half that and it works just fine. This is to show that as long as you know what you are shooting for in a pinch there is some wiggle room (and that everyone runs out of parts).
So to figure out how to get a .35 voltage out of the divider and into pin 3 on the comparator we need to figure out the voltage drop:
So we take 5v and need a drop of 4.65 volts to hit the .35V mark.
To find this we use ohms law and take the total resistance value 480K ohms and divide the original voltage by 480k ohms to get the current (I) 5/480K = .0000104166 amps (I) Then we can find the voltage drop by saying (I)*(top resistance = 470k) (.0000104166 amps)(470k) = 4.8958020000 V and so 5V - 4.8958020000V = .1041980000 V
which is < half of the specked .35 but in a pinch it works ok, The one thing you don't want to do is just tie the line to ground, in my experience outputs never reliably hit a clean GND and your communications will probably not work.
The http://en.wikipedia.org/wiki/Zener_diode zener diode is the other half of this circuit and cuts down the 5V output from the microcontroller to the 2.8 volt level the GSM needs. You can see the circuit is trivial all you need is a resistor and a zener diode to make it work. The drawbacks of the circuit are at higher baud rates it cad start having inductance problems that mimick RC circuits which will throw off your communications.
You can see the circuit in the bottom part of the drawing, what a zener diode does is allow current to flow to ground once a certain threshold is reached and therefore “clamping” the voltage at that set level. You need to put a resistor in series with the zener from preventing a large in-rush of current from destroying the zener.
There are also chips and kits out there that do logic conversion for you chips include the maxim:
And of course great products from spark fun!;
These guys are pretty self explanatory if you google logic conversion IC's you will see a bunch more.
There are also boards that have the microcontroller and the GSM built into one package for you so you just have to turn it on or solder up a couple connections.
GroundLab offers two boards one with a Atmel Atmeg1280 chip that can be flashed with the Arduino bootloader or can be used alone with a ISP programmer.
The circuit we used on this board utilizes the TC7W125 duel bus buffer with a pull up resistor as shown here:
The full eagle cad files for this board can be found here:
So using this board you would just plug it in and you can start using the GSM library found here:
The second board from Groundlab is a small board with a built in logic level circuit on board. With this device you can just make four connections to a microcontroller running 1.8-12v and you are ready to go.
Connections: The connections you need to make are, microcontroller GSM(Telit board) RX -> RXD TX -> TXD VCC -> microVcc GND -> GND
A example of the board hooked up to a atmel 644P for testing:
More info on GroundLabs boards and how to get them can be found here:
ON THE TELIT THE CONNECTION IS MASTER BIASED, WHICH MEANS THE RX FROM YOUR MICROCONTROLLER GOES TO THE RXD OF THE TELIT AND THE TX OF THE MICROCONTROLLER GOES TO THE TXD OF THE TELIT.
ONCE AGAIN RX->RXD TX->TXD
The Telit is very sensitive to its power source when transmitting it can spike up to two amps, this requires a power source and power regulator that can handle those spikes. So if using a battery it is not recommended to use anything below a 500ma battery and only use lith ion packs with the device if you implement any charging.
More info on putting together a tracking tool chain to track and visualize the data you can go here: