Interfacing an AVR controller to a GPS Mobile Phone

Update: Part II Using Google Maps with a Mobile GPS Tracker is online.

My goal is to build a kind of a mobile tracker. There are many different use cases you can think of but one of the obvious is a device, that is able to report where it is. This device can be put in your car and it could trigger an alarm, if the car got stolen. Actually it could tell you where it is.

There are already mobile tracking devices out there, but they seemed to be too expensive and too closed for my needs. Another option is one of these new Nokia N95 which have built-in GPS. They are really nice, but about 600€, which is not a bargain. So I decided to do my own.

IMGP1475

Materials

So my first idea was to combine a microcontroller with a GSM and a GPS modul. There are a lot of these modules over at Sparkfun, for example. Looking through their shop I found the Telit GM862, which is a GSM modul with an built in GPS receiver. That is what I wanted. And they sell great break out boards to make it easier for hobbyist to access these modules.

Here are some of the features of this GSM-GPS module:

  • Quad band GSM
  • 17mA average stand-by, 3.5mA in low-power mode
  • 250mA average operating current
  • SiRF III GPS Receiver Built In
  • Data, Voice, SMS, and Fax
  • Data speeds up to 57.6kbps
  • Supply voltage : 3.4-4.2V
  • CMOS Camera Capable
  • Python Interpreter built-in

Voice means you are not limited to mobile tracker applications. You could attach a speaker and a microphone to build a complete mobile phone!

So here is a list of what I purchased to get the first integration done.

  • Telit GM862-GPS modul, roundsolutions: 126€, or Sparkfun: CEL-07917, $183.95
  • GM862 Evaluation Board, Sparkfun: CEL-00277, $29.95
  • Quad band antenna, Sparkfun: CEL-00675, $7.95
  • GPS antenna 3V, Sparkfun: GPS-00464, $14.95
  • 2 interface cables for antenna, Sparkfun: GPS-00285, $8.95
  • optional: PolymerLithium Ion Batteries, Sparkfun: PRT-00341, $7.95
  • optional: LiPoly Charger, Sparkfun: PRT-00726, $16.95
  • ATmega8 microcontroller, ca. 2€
  • Resistors: 100, 10k, 22k, 27k, 2 x 47k, 2 x 100k, ca. 1€
  • Capacitors: 2 x 22p, 100n, 10u, ca. 2€
  • LED, 0.10€
  • Transistor, BC337, 0.10€
  • Prototyping board, 3€
  • optional: bread board

Summing up you get all parts at about 220€ or $286. Ouch! Who said, that tinkering with electronics is a cheap passion? But again, if you go this way, you can implement anything you can think of.

Circuit

Looking at the specs for the GM862, you realize, that it is more complex as you might have thought. A problem for me, still a beginner in electronics, were the different voltages used for the module. The power supply has to be 3.4-4.2V. Thats ok as an AVR can run on that voltage. But the serial port requires lower levels, 2.8V (CMOS). That means, you can not connect the UART of the controller directly to the module. You have to do some level translation. Fortunately this has already been solved over at Trackbox2.

Another point to mention is the power supply itself. It requires at least 2A for peaks. I used a LiPoly rechargable battery, which perfectly fits my needs. If you have to use 5V supply, you will have to use a capable voltage regulator and you have to deal with the CMOS voltage level issue as well.

GM862_circuit

As you can see, there are very few connections really required to the GM862. You have to connect the following on the breakout board:

  • RX, seriell modem communication
  • TX, seriell modem communication
  • RTS to ground, no handshake is used.
  • Status LED
  • On/off to power on the module
  • VCC and GND

Please keep in mind, that this is not an enterprise grade and production like circuit, so read any spec and guide before you assemble your components. You have been warned.

Operation

For now I am able to switch the module on and off, send text SMS through the module and fetch GPS positions from it. Here is an example GPS response:

Request GPS
AT$GPSACP got: AT$GPSACP
GPSACP: 131924.999,5333.9291N,00954.8841E,2.6,34.0,3,29.78,0.32,0.17,130707,07
OK

So now you know where I am living ;)

Conclusion
That’s it so far. It cost me quite some energy and money but was worth it. Next time more on software and how to talk to the GSM module.

IMGP1490

Links

Downloads

107 thoughts on “Interfacing an AVR controller to a GPS Mobile Phone

  1. Hi.

    I am looking for a tracking system that can be fitted to a boat. It needs to be relitivey small, and not triggerd my movement. I will need acsses to the location of it by internet live updating.

    If you can come up with a posible tracker then I would be looking at a bulk order!

    Regards

    Kent Paget

    Director Of Pendennis Maritime Security

    Like

  2. Nice link Tim!

    Does anybody know where I can find further info on the Inmarsat transcievers? Are there specific IC’s for building an Inmarsat transceiver?

    Like

  3. hi Alex, Good job. I have two questions.

    – How to attache the terminal to PC. Is there need to use Max232 or other thing for connecting to PC?
    Is this right to connect TX (PB0), RD (PB1) and GND connections directly to Serial DB9 connector? And is it possible to transfer data via serial port?

    – Is it possible to use 4.0000MHz quartz instead of 4.096MHz?

    I will be very thankful for your reply.

    Like

  4. Hi ideree,

    yes, I used an USB-to-RS232 converter to connect the terminal to the PC. This converter uses a FTDI chip but any other should do as well. So RX, TX and GND should be connected to such a converter.

    Every crystal will work, but you may have to check timings and baud setting again.

    Cheers,
    Alex

    Like

  5. Hello,
    it is necessary to make programm in phyton or connect GM863 with ucontroler. Isn’t possible just send well formated SMS from mobile to GM862 and receive GPS possition? Thanks.

    Like

  6. Hi Alex… it is an intresting project. I am writing a C# application for traking sistems. I am intrested in this “device”. I want to learn more about this. I would be gratefull if you give me an email / yahoo messanger / msn messanger address.

    Like

  7. Can anyone supply better picture of the circuit …this one is just too small.

    tnx.

    Like

  8. The schematic is updated and now in full size, just click on the link.

    Like

  9. Hi Alex,
    Very interesting project! … I build the circuit and I am in the uploading firware process, and I have some doubts. These are the tools/kit I am using: AVR Studio 4.13, STK500 AVR Flash MCU Starter Kit, and the Mfile for AVR-GCC ver 2.7:
    1. Is there any way to see a sample of a filled beacon file (C Type) to compare it with my entries? I found all the “EDIT THIS” areas, but I want to make sure I am using the right parameters and format information.
    2. Once I have customized my own information in the beacon file (C Type), do I need to compile this file with the others files too? (suart & uart (C & H type), and beacon (Microsoft Schedule and Application type).
    3. If I need to upload the previous files, do I need to use the flash section in the AVR Studio software for the beacon (Ctype file), and the EEPROM section for the other files?

    Thanks a lot for your support, and sorry for the bunch of questions.
    Arthur Neva

    Like

  10. Hi Arthur,

    edit this line and replace 1234 with your PIN for your SIM card.
    const char ATCPIN_P[] PROGMEM = “AT+CPIN=1234”;
    Edit this line and replace 7676245 with the phone number, to which you can send SMS. It is the number of a SMS center. This number can be found at the configuration details for your provider.
    const char ATCMGS_P[] PROGMEM = “AT+CMGS=”7676245″”;

    You have to compile all .c files. The .sch is a eagle cad schematic file, you can not compile that. I haven’t used AVR studio, so I am not sure, but you should be able to add all .c and .h files to a project and then to compile them.

    The compile step should result in two files, one for the flash (.hex), another for the eprom section (.eep). Both must be uploaded.

    HTH

    Cheers,
    Alex

    Like

  11. Hi Alex,
    I really appreciate your feedback.
    I’ll implement the changes you recommended, and I’ll keep you posted on the results.

    Greetings.
    Arturo

    Like

  12. Cool projects,

    Anyone here gotten around to doing a math module with basic Trig which would run natively on the Telit using their Python engine.

    I am thinking this could be done using Taylor Series but I have not got around to doing it yet. Maybe someone else has???

    Thanks,
    Serge

    Like

  13. hey all … hiiii , first i wanna know if i can make my tracker with a GPRS instead of gsm… i need the circuit to do that… please if any body here can help me just reply here and on my mail modern_lord@hotmail.

    Like

  14. Hi, i am wondering whether the telit module can do interrupt handling routines like microcontrollers. For example, can it handle an interrupt that is raised due to input from serial port>? Thanks

    Like

  15. Hi Alex,

    Do you have any idea to add a cmos camera (like E700 at Sparkfun) into the GM682?

    Thanks
    Dan

    Like

  16. Hi Dan,
    no, I haven’t done anything like that. But it should be possible, I think I read something about cameras attached to the GM862 in the documentation.
    Cheers,
    Alex

    Like

  17. Dear Alex,

    I live in BRAZIL. Here I only look SIEMENS MC39i GRPS MODEMS for buy.

    I have a MC39i with DB9 conector (RS232C) But It´s not have any GPS module only modem and RS232. How I use you track circuit for insert a
    serial GPS and RS232 MODEM separately ?

    Congratulation for BLOG and PROJECTS !

    Best for You,

    ORENGO

    Like

  18. Hi jorge,

    most of the GPS modules out there are using a serial port for NMEA output. You could use a microcontroller to fetch the GPS data and send it via your MC39i. You may want to take a microcontroller that has two serial port, e.g. ATmega32.

    HTH.

    Cheers,
    Alex

    Like

  19. Pingback: Взаимодействие микроконтроллера AVR с GSM телефоном - Разработка электро

  20. hey alex….really intersting project..and i hope u can email me with all the details and info i need to try it..thnx

    Like

  21. Dear Alex

    May i know how you can progamme the microcontroller of your built device ? What programming language you are using ?

    Thks & Rgds
    May

    Like

  22. Can you give me the schematics of the harware by using EAGLES?The schematics should include the connection of TelitGM 862 Module and Sparkfun GM 862.Thanks

    Like

  23. Hi, Alex

    You sad that, you used USB-to-RS232 converter to connect the terminal to the PC. This converter uses a FTDI chip.

    – So in such case do you have your own driver built-in in your USB-to-RS232 converter?

    And what about terminal operation when terminal is not connected to PC.
    – Can i send a message to another mobile phone number stored in EEPROM of ATmega8-16PU?

    And i am going to use this device in Mongolia, which country located between Russia and china.
    – So, is there any reason that i can’t be using this device in Mongolia?

    Regards, Ideree

    Like

  24. Hi Ideree,
    you don’t need a driver in the converter. It looks like a serial connection to the controller. Just attach RX and TX to the controller. The connection from the converter to the PC is established with a driver that enables a virtual com port. You can download these drivers at FTDI, http://www.ftdichip.com/Drivers/VCP.htm
    Sending an SMS to another mobile phone should be possible, if you tweak the source code.

    I don’t see any reason, why it shouldn’t work in Mongolia. I assume you have GSM coverage most of the time.

    Cheers,
    Alex

    Like

  25. Hi, Alex

    Finally I’ve collected all equipments (Antennas, GM862GPS, Atmega8 and etc).
    First I have to say that I am not good at programming but i really wanna build a device as you built. And I’m hardly trying to make it working.

    I’ve finished to assemble all elements along with your guidence, and changed all the settings in your source code as you signed as EDIT THIS.
    And I have compiled all .c and .h codes and built a hex file. So i’m gonna write this file to Atmega8.

    – So I’d like to know how to use this source code and is it possible to send a message to another phone number instead of connecting device to PC?
    – If it is possible i can use your source code and program ATmega8 and build a device as you have, and turn it on by plugging power supply than device will send a message to another phone number from anywhere and anytime, without need of using PC.

    As I mention that this source code you made is possible to send a message to another phone and If I connect device to PC, the device can be controlled by PC.

    – AM I RIGHT?

    Please help me to finish this project successfully.

    Best regards,
    Ideree

    Like

  26. Hi Ideree,

    I will help as best as I can, but I will not do the programming for you. Sorry. You will have to learn this to adopt this project to your needs.
    You can modify the sms_gateway string to a number of your choice. And then have a look at the google_maps_P string. This is the formatted message that gets send. Further you have to adjust the main method to acquire the gps position and set it out with the SMS.
    If you have any further questions you can drop me an email, alex at this domain.

    Cheers,
    Alex

    Like

  27. Hi, alex
    Interesting project, i have the gm862 and all the components, i trying to make this by hooby, it appears that it’s all right, but i have problems with the terminal, i connect it via USB-RS232 converter, i probed this with a garmin and it works at 4800 bauds but i try to connect with the terminal the AVR at 19200 bauds with the pins 14, 15 and GND to transmit with the terminal but nothing appears, what i’m doing wrong? the only thing that i see is the blinking led when i power the circuit, and i supposed that it’s working because as soon as i reset the avr, the led stop blinking then it blinks again.
    Your help it’s appreciated.

    Regars
    Chris

    Like

  28. Hi Chris,
    pin 14 and 15 are ok. If you haven’t modified the source code, then the baud rate for the serial connection is 9600 baud.
    HTH,
    Cheers,
    Alex

    Like

  29. hellow alex..how are you???
    can help my to solve Latitude/Longitude from GPS data to Distance Conversion(meter unit)…thank you

    Like

  30. Pingback: uOLED progress

  31. I wanna know how can I use interrupt with python.Python has interrupt’s function?Can you help me about this topic???
    thnks

    Like

  32. Hi ALex/anybody who can help

    Im having issues getting my GM862 GPS to process AT commands I send it from the micro. Hyperterminal proves to me that the micro is doing its job correctly, however I can’t understand what Im doing wrong. Ive been reading and reading and reading for days..please guys?..Help.

    Like

  33. Hi alex, Thanks for making this great project available. I didnt know anything about microcontrollers before i started and has been a great way to learn. I had quite some success yesterday and now when I power the tracker on I get sent a text message on my phone every two minutes with the converted co-ordinates and the email-google map details. Im not going to use the sms-email function as costs quite alot of money here in new zealand to acuire it. Im able to load the long. and lat. numbers in manually on google maps and if I put a “-” in front of the first co-ordinate i get my location. Would that have to do with me being in the southern hemisphere? The other question I had was whether the unit has to run automatically when powered on. Am i able to change so i get a response from tracker if i text to it? If not could i change code so i get sent a new position once a day? thanks

    Like

  34. Good day! i would like to ask if i will do this project, when i text the device it will send me an SMS message containing the GEOCODE right? like 0.000 latitude and 0.000 longitude… now what i want to ask, is is there a way for me to reverse it.. instead it sends me real street address… hope you reply

    thanks!!

    Like

  35. Hi everyone.

    A few days ago, I was surfing the web and I found out a project that works over most mobile phones which lets you know where your friends are in real time and update your status in twitter. It´s called Dimdix.

    On their website they say you don´t need a GPS system to detect your location. Does anyone know how this works?

    I´m using a Motorola L7 and amazingly it detected my location.

    I cannot stop thinking of all the things I could do with it.

    If anyone wants to take a look you can go here

    Thanks,

    Regards,

    Juan

    Like

  36. dear alex
    i want to ask you about price of all the products above now
    and pleas tell me if that products enough to make the instrument

    Like

  37. I am doing a similar project but using a pic. I have a question about your level translation. I am confused about the voltage divider you have in your schematic for TXD. Shouldn’t the r6 resistor to ground be on the other side of r5, so that when the controller went high i.e. 5V then the gsm would see (5/49k)*22k=2.24V? Which would still be within the high range for the gsm. Forgive my stupidity if am I miss reading this. Also, when I connect my gsm to the rs232 port using demo board and hyperterminal I have to use 115200 in order to send text. How do I set this using the microcontroller? Thx for any help.

    Like

  38. That module is pretty big to me, a mobile phone done with that would be a fat one. Is there a smaller alternative?

    Like

Comments are closed.