Using Google Maps with a Mobile GPS Tracker
Two weeks ago I posted about how to interface an AVR microcontroller to a Telit GM862. You can read it here: Interfacing an AVR controller to a GPS Mobile Phone.
That post got listed on Hack-A-Day, Engadet and Makezine among many others! w00t! Thanks for posting and reading it, I really appreciate it.
This post will show you, how to use this equipement to send an SMS with your current position and how to display it in Google Maps.

How does it work?
The controllers serial port is attached to the serial port of the GM862 module. This way the controller is able to send AT commands to the module and receive responses. The GM862 has two serial ports, one for controlling the modem, the other for receiving GPS data in NMEA 0183 format. Fortunately we can access the GPS through the modem port, what saves us from using a second serial port.
To be able to debug and control the controller, I use a second serial port, that connects the controller to my PC. That way I am able to send commands to the controller and steer the program flow as long as it is not fully tested and completed. The following steps are needed to get it up and running.
- Power on the circuit.
- Power on the GM862 module (done by the ATmega8)
- Initialize the modem.
- Initialize the GPS module (may be omitted).
- Request a GPS position (repeat until the position is fix).
- Send an SMS with GPS position to an SMS-to-Email service.
- Open your email and click the Google Maps link.
More details
As the ATmega8 has only one hardware UART, I use this to communicate with the modem at 19200 baud. For debugging purpose, the second serial port is implemented with a software UART with communicates with the PC with 9600 baud.
Starting the controller gives the following menu on the terminal:
------
Beacon v0.02 2007/07/28
s - Change sms phone number
o - Switch modem on/off
i - Init modem
m - Send SMS
c - Cold start GPS
p - Request GPS
------
key >
Switching the modem on and off is done by pulling the pin 17 of the GM862 to low for at least a second. The status LED of the modem should start to blink in response.
Initializing the modem is done with the following sequence of AT commands:
AT, say helloAT+IPR=19200, set the baud rate to 19200AT+CPIN=<pin>, set your PIN for the SIM cardAT+CMEE=2, choose extended error messages
The modem should respond with the status LED blinking slower, if the PIN matches and the network is reachable.
Initializing the GPS is optional, as the modul starts the GPS on power on. You can force a cold or a warm start.
AT$GPSR=1, issue a cold startAT$GPSR=2, issue a warm start
If you ommit the cold or warm start, you should be able to see a fixed position within 30 seconds after you powered up the module. This time may vary with your position and the reachability of the satellites.
The current position is requested by sending
AT$GPSACP, read the acquired position
The response contains information about current time and date, the position and the number of available satellites.
To send send an SMS, send the following commands:
AT+CMGF=1, select text sms formatAT+CMGS="<phone number>", send the message to the given phone number. This command responds with an prompt>. Now the text of the SMS can be transmitted. The message has to end with0x1A.
Parsing the GPS position
The position string received from the GPS looks like this:
GPSACP: 131924.999,5343.9291N,00954.7841E,2.6,34.0,3,29.78,0.32,0.17, 130707,07
All tokens are separated with comma. The tokens are:
- time, hhmmss.SSS
- position, latitude, degrees and minutes
- position, longitude, degrees and minutes
- hdop, horizontal diluition of precision
- position, altitute, meters
- fix, 0=invalid, 2=2D, 3=3D
- cog, course over ground
- spkm, speed in km
- spkn, speed in knots
- date, ddmmyy
- nsat, number of satellites
The position data received is not directly usable for Google Maps, because the GPS returns degrees and minutes, but GM wants degress as a floating point number. That means the minutes have to be converted to decimal fraction of degrees.
Sending a Google Maps link
Now that we have received and converted the GPS position, we are ready to send an SMS with a link to GM. The link has the following format:
http://maps.google.com/maps?q=<lat>,<lon>%28<message>
%29&t=k&z=<zoom>
You can embed a message, which appears in the popup box. It is surrounded by encoded brackets. Further you can control the zoom factor and the type of map (k=satellite, m=map).
Now this link has to be send as an SMS to an SMS-to-email service that forwards the SMS as email to the given address.

Conclusion
If everything went well, you should be able to click the link and see your browser opening Google Maps with your position.

Next todos are pollishing the code to be able to show it and having it more self-sufficient. Send me an email or comment, if you would like to see it online.
Links
- Part I:Interfacing an AVR controller to a GPS Mobile Phone
- Part III: Firmware for the GPS tracking device
- Google Maps request parameters

July 29th, 2007 at 15:01
Is this the full source code for the part one of the project? im planning to construct the project here in the Phil. but I dont know yet about progrmming the ATmega8 microcontroller. Can teach me? Thanks!
July 29th, 2007 at 15:18
Hi Bernie,
no, I am still working on the source. But I plan to release it soon.
If you are new to programming of microcontrollers, I would suggest to try a tutorial on that first. Instructables has some very good, for example this one:
http://www.instructables.com/id/E5H5UDWB5UEUKIKV8V/
Cheers,
Alex
August 2nd, 2007 at 18:33
hi Alex, can u plz temme that how to start with the project and which Gsm hanset can be used and hot to interface them to the avr port.
Rizwan
August 2nd, 2007 at 23:16
Hi Rizwan,
I am not really familliar with GSM handsets.
But if you want to try the GM862, the easiest way would be to get a breadboard and assemble the components as shown in the schematics http://tinkerlog.com/wp-content/uploads/2007/07/beacon.zip
You will need the Eagle CAD software to display it. http://www.cadsoftusa.com/
Cheers,
Alex
August 3rd, 2007 at 10:54
hi Alex, can u plz put up the codes that has to be programed in the microcontroller.
Also, when the Sms is sent as on email, how to convert (the content of the SMS) this in to a file which can be taken sucessfully by the google map.
thanks for your quick reply.
rizwan
August 5th, 2007 at 19:53
I would like to know also
August 13th, 2007 at 14:11
I am interested in your tracking device. Please can you contact me if you would be interested in business deal number is +44786xxxxxx
August 16th, 2007 at 17:00
hi alex, how r u doing?, thanks for the codes.
Alex, do u know any other gsm module other than telit which has a SIM slot for sening the sms., coz this module is not available here in India.
thanks for your response
bye
rizwan.
August 17th, 2007 at 07:51
Hi rizwan,
if you are looking for modules with GPS functionality I think the Telit is the only one. Have you asked roundsolutions.de, if they ship to India?
Others without GPS are produced by Siemens or Sony Ericsson for example.
Cheers,
Alex
August 27th, 2007 at 01:02
Hi Alex,
This is a very interesting project. I have tried to put it together and came up on few obstacles.
1. SUART is using PB0 and PB1. Which one is used as TXD and which one is used as RXD. (Just found it in suart.c PB0 is RXD)
2. I am using 4.0MHz oscillator. What value do I have to set in uart.c for F_CPU?
3. In your assembly picture there is a push button which is not present in schematics. What is the pushbutton used for?
Thanks a lot.
September 1st, 2007 at 06:05
hi, can i use gm863 instead of gm 862.
if yes, what r the necessary changes need to b made?
September 5th, 2007 at 09:39
@DOL, I will check which pins are used. I’m currently not able to look into it. If you are using 4.0MHz, then F_CPU should be set to 4000000. The pushbutton is just for the reset.
@sha, I am not sure if the gm863 works. I think it should have the same functionality but not sure about the pinout.
Cheers,
Alex
September 8th, 2007 at 16:25
Alex,
Thanks for your help. I was able to connect to Br@y++. Below is the portion of the input received in Br@y++ terminal. (I was not able to get anything in HyperTerminal). I have tried different baud rate settings 9600 and 19200 with the same results. I am thinking that there is something wrong with usart.c. Just FYI currently the circuit is on breadboard.
Please advise. xx€xø€øø€øø€xø€xø€øø€xøxxÀø€€€€€€ø€€€€øÀ€ø€ø€€€€€€ø€€€ø€€€€€>€|€€ø
September 22nd, 2007 at 09:59
Hi there, is there a site where I can get a full run down of this project? I’d love to build it but want all the facts before I start!
Thanks
September 22nd, 2007 at 11:29
Hi Dave,
sorry, all infos are a bit scattered in my blog. Be sure to check the first part of this series, see the links section above.
I am currently using the builtin Python, so the list of needed materials will shrink soon, I hope.
Cheers,
Alex
October 19th, 2007 at 07:56
Hi Alex…
Is there anyway i could also get those codes for the unit ?
Thanks very much
Simon
October 19th, 2007 at 17:01
Hi Simon,
please have a look at: http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/ for the firmware.
The easier and smaller version in Python is here: http://tinkerlog.com/2007/09/23/using-twitter-and-twibble-for-mobile-tracking/
Cheers,
Alex
November 9th, 2007 at 10:24
[…] is operational, the microcontroller is programmed to send an SMS with its location. Showing this location on Google Maps involves sending an SMS via an SMS-to-email service, so that you get an email with a Google Maps […]
November 17th, 2007 at 13:43
I am working on a similar poject where the device sends the co-ords to a mobile phone via SMS and then the co-ords are typed into Mappoint. Is it possible to get the device to send an SMS to the mobile with a link to mappoint and then select that link on the mobile and call up the map?
November 17th, 2007 at 13:51
how do you convert the gps position into a format for google
November 17th, 2007 at 14:33
Hi Peter,
if you can open a location in Mappoint with a single link, then it should be possible, to send a text SMS with the formatted link.
For the conversion of coordinated, it depends on what your GPS puts out. Mine formats the location DD MM.mmmm where DD are the degrees, MM are the minutes and mmmm are the fractions of a minute. Google wants DD.ddddddd, degrees and fractions of degrees.
Take a look at the source in C:
http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/
Or in Python:
http://tinkerlog.com/wp-content/uploads/2007/09/tracker-python-001.zip
Cheers,
Alex
November 19th, 2007 at 15:00
There are a number of mapping sites that will open up the location with a single link in this format via a PC web browser.
Does anyone now of a way of doing this on a mobile?
I want someone to be able to get this SMS and automatically open up a map showing the location on a mobile.
January 8th, 2008 at 11:47
hi alex, can i use GE863-gps module instead of gm862, as the gm862 module is not available in india.
please help me out.
bye
January 8th, 2008 at 20:14
Hi sha,
I haven’t tested the GE863 module, but I would expect, that the code could be easily ported. But the hardware may need more investigation, as the GE863 is smaller and does not come with an onboard sim card holder.
Cheers,
Alex
January 29th, 2008 at 03:31
Alex, fine work here! Would it not be possible to also accomplish the same task by sending a request for position (via SMS) to one of the newer GPS-enabled handsets (like Nokia) and simply have it respond with the lat/lon via SMS, and then convert this to a GoogleEarth query format at the receiving end, or a Google Maps app on a Blackberry or Treo? I am looking to do what you have done but wish to leverage as much off the shelf technology as I can find. Thanks.
January 29th, 2008 at 08:28
Hi Drew,
yes that should be possible. It exists even a Python for Series 60.
Cheers,
Alex
May 18th, 2008 at 13:27
Hi Alex , Great project and well done .
I am working NOW on project exactly like this.
Could you plaese send the code to me ?
it will be very helpful to me
Thanks AHMAD .
May 18th, 2008 at 14:35
Hi Ahmad,
just scroll 20cm up and you will find links to the code
Cheers,
Alex
May 20th, 2008 at 06:41
Thanks for your fast replaying ,
but unfortunately, I am using the Telit GM862-GPS with Arduino. So, I thought I shoud use the Arduino code for that ,unless you have any comments for me .
I mean , Must I use the (C) code or Python one ?
your advice plz :$
May 20th, 2008 at 07:42
Hi Ahmad,
the Arduino should be well suited for this.
As the Arduino programming language is C with some additional features, it shouldn’t be a problem to port my C version of the firmware to an Arduino. The most interesting part is the communication by AT commands. At least that should be ported to the Arduino.
And don’t forget to drop me a line, if you get it working
Cheers,
Alex
June 6th, 2008 at 17:27
hi alex
i want start with AVR and i want build an tool that show gps
can u help me?
nice to meet ur site
ur sincerly
Hamid Hamidi