<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tinkerlog &#187; gps</title>
	<atom:link href="http://tinkerlog.com/category/gps/feed/" rel="self" type="application/rss+xml" />
	<link>http://tinkerlog.com</link>
	<description>Alex' blog</description>
	<lastBuildDate>Wed, 14 Jul 2010 21:23:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Interfacing Arduino with a Telit GM862</title>
		<link>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/</link>
		<comments>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/#comments</comments>
		<pubDate>Fri, 15 May 2009 17:59:52 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[gsm]]></category>
		<category><![CDATA[GM862-GPS]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/?p=704</guid>
		<description><![CDATA[
The Arduino can talk over a wide range of networks. Ethernet, Bluetooth, Wifi, XBEE and GPRS to name the most known. I had a Telit GM862-GPS module laying around, unused for some time already. It has GPRS and GPS capabilities, both accessible with AT commands. So I decided to port some of my code to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_dsc_0005.jpg" alt="" title="Telit GM862-GPS" width="480" height="343" class="alignnone size-full wp-image-705" /></p>
<p>The Arduino can talk over a wide range of networks. Ethernet, Bluetooth, Wifi, XBEE and GPRS to name the most known. I had a <a target="_blank" href="http://www.telit.com/en/products/gsm-gprs.php?p_id=12&#038;p_ac=show&#038;p=7">Telit GM862-GPS</a> module laying <a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">around</a>, unused for some time already. It has GPRS and GPS capabilities, both accessible with AT commands. So I decided to port some of my code to the Arduino.</p>
<p><span id="more-704"></span></p>
<h3>Schematic</h3>
<p><a href="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/l_gm862.png"><img src="http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/s_gm862.png" alt="" title="Schematic GM862 with Arduino Mega" width="490" height="240" class="alignnone size-full wp-image-706" /></a></p>
<p>Connecting the Arduino Mega to the GM862 is rather easy. Only four connections are needed.</p>
<ul>
<li>Tx3 &#8211; Tx</li>
<li>Rx3 &#8211; Rx</li>
<li>Pin 22 &#8211; On/Off</li>
<li>GND &#8211; GND</li>
</ul>
<p>The GM862 is accessed with a breadboard fiendly breakout board from <a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=277">Sparkfun</a>.</p>
<p>The logic pins of the GM862 accept only CMOS 2.8 Volt. For that reason, a voltage divider is needed for the Tx line. Both, Rx and Tx are pulled up to the PWR_CTL line of the module because these pins don&#8217;t have an internal pull up resistor.<br />
The on/off line is connected to ground with a transistor.</p>
<p>The bad thing for this setup is the power supply. The module is powered by a LiPo cell (3.7 V with 2000 mAh). The Arduino Mega is powered by the USB port. If I want to make this portable, I have to use two batteries.  Or find a better solution. Maybe powering the Arduino with a step-up converter. </p>
<h3>Software</h3>
<p>First I wanted to use an Arduino Pro mini, that runs on 3.3 V. That would save me from having two different power supplies for the Arduino and the GM862. I tried to connect the Rx/Tx lines to two digital pins and use the <a target="_blank" href="http://arduiniana.org/">NewSoftSerial</a> library. This library enables a second serial port on the Arduino besides the hardware serial port. Unfortunately it wasn&#8217;t reliable enough. Sending to the module seems to work well, receiving sometimes did not. I tried it with different baud rates and different Arduinos, 8 MHz and 16 MHz, but that didn&#8217;t help. Maybe I did something wrong, but I couldn&#8217;t figure it out.<br />
So I switched to my brand new Arduino Mega. I just connected Rx/Tx to one of the hardware serial ports and it worked immediatly.</p>
<p>The following features are implemented:</p>
<ul>
<li>Starting and stopping the module</li>
<li>Initialization</li>
<li>Sending of SMS</li>
<li>Requesting GPS position and parsing the result</li>
<li>Opening a socket, writing and reading (used to talk HTTP) over GPRS</li>
</ul>
<p>The software is an really early stage. I focussed most on functionality and less on performance or compact code.  The following todos are still open:</p>
<ul>
<li>Make debugging output configurable</li>
<li>Use of PROGMEM to reduce RAM usage</li>
<li>More compact structure for AT commands</li>
<li>Parse more responses of AT commands. Some are simply issued, without looking at the response</li>
</ul>
<p>Nevertheless, here is a small snippet, that shows features that are already working. To get it working, you have to replace XXXX with your PIN. For GPRS you have to dig into the module code and adapt the GPRS settings.</p>
<pre name="code" class="c">
/*
 * GM862-GPS testing sketch
 * used with Arduino Mega
 * http://tinkerlog.com
 */

#include "GM862.h"

int onPin = 22;                      // pin to toggle the modem's on/off
char PIN[5] = "XXXX";                // replace this with your PIN
Position position;                   // stores the GPS position
GM862 modem(&#038;Serial3, onPin, PIN);   // modem is connected to Serial3
char cmd;                            // command read from terminal

void setup() {
  delay(10000);
  Serial.begin(19200);
  Serial.println("GM862 monitor");
  modem.switchOn();                   // switch the modem on
  delay(4000);                        // wait for the modem to boot
  modem.init();                       // initialize the GM862
  modem.version();                    // request modem version info
  while (!modem.isRegistered()) {
    delay(1000);
    modem.checkNetwork();             // check the network availability
  }
  Serial.println("---------------------");
  Serial.println("ready");
}

void requestHTTP() {
  char buf[100];
  byte i = 0;
  modem.initGPRS();                   // setup of GPRS context
  modem.enableGPRS();                 // switch GPRS on
  modem.openHTTP("search.twitter.com");    // open a socket
  Serial.println("sending request ...");
  modem.send("GET /search.atom?q=gm862 HTTP/1.1\r\n"); // search twitter for gm862
  modem.send("HOST: search.twitter.com port\r\n");     // write on the socket
  modem.send("\r\n");
  Serial.println("receiving ...");
  while (i++ < 10) {                  // try to read for 10s
    modem.receive(buf);               // read from the socket, timeout 1s
    if (strlen(buf) > 0) {            // we received something
      Serial.print("buf:"); Serial.println(buf);
      i--;                            // reset the timeout
    }
  }
  Serial.println("done");
  modem.disableGPRS();                // switch GPRS off
}

void loop() {
  if (Serial.available()) {
    cmd = Serial.read();
    switch (cmd) {
    case 'o':
      modem.switchOff();              // switch the modem off
      break;
    case 's':                         // send a SMS. Replace with your number
      modem.sendSMS("6245", "your@email.com hello from arduino");
      break;
    case 'w':
      modem.warmStartGPS();           // issue a GPS warmstart
      break;
    case 'p':
      position = modem.requestGPS();  // request a GPS position
      if (position.fix == 0) {        // GPS position is not fixed
        Serial.println("no fix");
      }
      else {                          // print lat, lon, alt
        Serial.print("GPS position: ");
        Serial.print(position.lat_deg);  Serial.print(".");
        Serial.print(position.lat_min);  Serial.print(", ");
        Serial.print(position.lon_deg);  Serial.print(".");
        Serial.print(position.lon_min);  Serial.print(", ");
        Serial.println(position.alt);
      }
      break;
    case 'h':
      requestHTTP();                  // do a sample HTTP request
      break;
    default:
      Serial.println("command not recognized");
    }
  }
}
</pre>
<h3>Log</h3>
<p>Here is a log, that I recorded within the Arduino IDE. You can see, how</p>
<ul>
<li>the modem gets switched on</li>
<li>the modem gets initialized</li>
<li>the version info is requested</li>
<li>it waits until the network is reachable</li>
<li>a GPS position is requested</li>
<li>a SMS gets send</li>
<li>how a HTTP GET is issued over GPRS, it searches for gm862 on twitter</li>
</ul>
<pre>
GM862 monitor
switching on
done
initializing modem ...
AT
->ok
AT+IPR=19200
->ok
AT+CMEE=2
->ok
AT+CPIN=XXXX
->ok
done
version info ...
AT+GMI
->buf: AT+GMI
Telit
OK
AT+GMM
->buf: AT+GMM
GM862-GPS
OK
AT+GMR
->buf: AT+GMR
07.02.403
OK
AT+CSQ
->buf: AT+CSQ
+CSQ: 0,0
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,2
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,2
OK
done

checking network ...
AT+CREG?
->buf: AT+CREG?
+CREG: 0,1
OK
done

---------------------
ready

requesting GPS position ...
AT$GPSACP
->buf: AT$GPSACP
$GPSACP: 110621.999,5333.9477N,00954.8735E,1.4,66.3,3,22.21,0.10,0.05,150509,08
OK
3
GPS position: 53.565794, 9.914568, 66

sending SMS ...
AT+CMGF=1
->ok
AT+CMGS="6245"
->not ok: AT+CMGS="6245"
>
your@email.com hello from arduino
done

initializing GPRS ...
AT+CGDCONT=1,"IP","internet","0.0.0.0",0,0
->buf:
+CMGS:  35
OK
AT+CGDCONT=1,"IP","internet","0.0.0.0",0,0
OK
AT#USERID=""
->buf: AT#USERID=""
OK
AT#PASSW=""
->buf: AT#PASSW=""
OK
done

switching GPRS on ...
AT#GPRS=1
->buf: AT#GPRS=1
+IP: 10.37.146.251
OK
done

opening socket ...
AT#SKTD=0,80,"search.twitter.com",0,0
->buf: AT#SKTD=0,80,"search.twitter.com",0,0
buf:
buf:
CONNECT
sending request ...
receiving ...
buf:HTTP/1.1 200 OK
Date: Fri, 15 May 2009 11:07:19 GMT
Server: hi
Status: 200 OK
Cache-Control: ma
buf:x-age=20, must-revalidate, max-age=1800
Content-Type: application/atom+xml; charset=utf-8
X-Serve
buf:d-By: searchweb005.twitter.com
Expires: Fri, 15 May 2009 11:37:18 GMT
Content-Length: 4757
Vary:
buf: Accept-Encoding
X-Varnish: 218274860
Age: 0
Via: 1.1 varnish
X-Cache-Svr: searchweb005.twitter
buf:.com
X-Cache: MISS
Connection: close

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
[...]
    &lt;/author&gt;
  &lt;/entry&gt;
&lt;/feed&gt;

NO CARRIER
done

switching GPRS off ...
AT#GPRS=0
->buf: AT#GPRS=0
OK
done
</pre>
<h3>Outlook</h3>
<p>Besides some software todos on the list, two things are still bugging me. One is the need of an Arduino Mega because of the hardware serial port. I will try the new version of NewSoftSerial, as soon as it is released. The other thing is the need of two power sources. But that could be solved with the Arduino Mini pro, when the software serial issue is fixed.</p>
<p>Everything else worked well. Now I only need a problem that could be solved with this <img src='http://tinkerlog.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<h3>Links and Downloads</h3>
<ul>
<li>Source code: <a href='http://tinkerlog.com/wordpress/wp-content/uploads/2009/05/arduino-gm862.zip'>arduino-gm862.zip</a></li>
<li><a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">Interfacing an AVR controller to a GPS Mobile Phone</a></li>
<li><a target="_blank" href="http://www.sparkfun.com/commerce/product_info.php?products_id=277">GM862 breakout board</a> from Sparkfun</li>
<li><a target="_blank" href="http://www.telit.co.it/modulef.asp?famId=7&#038;famName=GM862%20Modem%20Family">GM862 specs</a> at Telit.</li>
<li><a target="_blank" href="http://www.roundsolutions.de">roundsolutions</a>, distributor for GM862 modules.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>Using twitter and twibble for mobile tracking</title>
		<link>http://tinkerlog.com/2007/09/23/using-twitter-and-twibble-for-mobile-tracking/</link>
		<comments>http://tinkerlog.com/2007/09/23/using-twitter-and-twibble-for-mobile-tracking/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 06:27:58 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[gps]]></category>
		<category><![CDATA[gsm]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/09/23/using-twitter-and-twibble-for-mobile-tracking/</guid>
		<description><![CDATA[Some weeks ago I met Thilo and he showed me twibble, his GPS enabled twitter client for the N95. Nice little and smart application. It sends messages with geo positions to twitter. The postion can then be tracked and viewed within Google Maps.
I was impressed and decided immediately to try to post the same messages [...]]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago I met <a href="http://www.das-zentralorgan.de/">Thilo</a> and he showed me <a href="http://www.das-zentralorgan.de/twibble">twibble</a>, his GPS enabled twitter client for the N95. Nice little and smart application. It sends messages with geo positions to twitter. The postion can then be tracked and viewed within Google Maps.</p>
<p>I was impressed and decided immediately to try to post the same messages with my mobile tracker and use the same, twitter, twibble and GM, to track my positions.</p>
<p><a title="Track in Google Maps" href="http://tinkerlog.com/wp-content/uploads/2007/09/maps.jpg"><img alt="Track in Google Maps" src="http://tinkerlog.com/wp-content/uploads/2007/09/maps.jpg" /></a></p>
<p><span id="more-31"></span></p>
<p>&nbsp;</p>
<p><strong>Using Builtin Python instead of the AVR controller</strong></p>
<p>Actually I switched to use the builtin Python interpreter as some on the comments already suggested. So the external microcontroller is superfluous. That should make the setup smaller, cheaper and easier. By now I don&#8217;t have a new board, I just bypass the controller. Communication is done via serial port directly connected to the Telit module.</p>
<p><strong>How to develop in Python for the GM862</strong></p>
<p>To develop python scripts you need to download the python package from <a href="http://www.roundsolutions.com/techdocs/">roundsolution&#8217;s techdocs page</a>. Next write a &#8220;hello world&#8221; script and upload it with your favorite terminal application. Note, that using print statements for debugging will not work as expected. You have to redirect stdout to the serial port to be able to see them in your terminal. <a href="http://www.digitaldawgpound.org/nick84/post=222#comment-5441">Joe</a> pointet out that solution.</p>
<p>According to the documentation, it should be possible to get seperate output for debugging, stdout, etc. but I didn&#8217;t manage to get that up and running so I was stuck in trail and error. After uploading the script and starting the execution, the module takes some time to compile the python code. If it fails, it fails silently, what is a bit nasty. <a href="http://www.digitaldawgpound.org/nick84/post=222">Nick</a> has a nice writeup of how to develop with python for the GM862 in his blog. Developing and debugging turned out to be not that easy but it works.</p>
<p><strong>Posting twibbled tweets</strong></p>
<p>To piggybacking on twitter and twibble, I created a twitter account. I wrote a test script that uses HTTP over GPRS to post messages to twitter. As posting to twitter is secured with HTTP basic authentication, I hard wired my script to post my auth value. <a href="http://curl.haxx.se/">curl</a> is very handy to test HTTP communication on the command line of your PC. Using the -v switch shows the encoded auth value, that you need.</p>
<p>Next I fetched the position from the GPS and formatted the message accordingly. To enable twibble to grab the position, it must be formatted like this: &#8220;&lt;message&gt; L:&lt;lat&gt;,&lt;lon&gt;:&#8221;.</p>
<p>The script now just fetches the position and posts it to twitter every two minutes. This can be improved by posting the position only if the module was moved.</p>
<p><a title="twitter.jpg" href="http://tinkerlog.com/wp-content/uploads/2007/09/twitter.jpg"><img alt="twitter.jpg" src="http://tinkerlog.com/wp-content/uploads/2007/09/twitter.jpg" /></a></p>
<p><strong>Tracking</strong></p>
<p>Now I can use Google Maps to fetch a kml file, which is generated by the twibble service out of my twitter messages. With the new feature to embed Google Maps without an API key, it&#8217;s even easier.</p>
<p><iframe marginwidth="0" marginheight="0" src="http://maps.google.com/maps?q=http:%2F%2Fapi.twibble.de%2Fstatuses%2Fuser_timeline%2F9600baud.kml&amp;ie=UTF8&amp;ll=53.5596,9.946885&amp;spn=0.0124,0.09063&amp;om=1&amp;output=embed&amp;s=AARTsJoZP6xr9gOqZRW-Cf_8rosrNn4Yzw" frameborder="0" width="425" scrolling="no" height="350"></iframe><br />
<small><a style="COLOR: #0000ff; TEXT-ALIGN: left" href="http://maps.google.com/maps?q=http:%2F%2Fapi.twibble.de%2Fstatuses%2Fuser_timeline%2F9600baud.kml&amp;ie=UTF8&amp;ll=53.5596,9.946885&amp;spn=0.0124,0.09063&amp;om=1&amp;source=embed">GrÃ¶ÃŸere Kartenansicht</a></small></p>
<p>
<strong>Links and downloads</strong></p>
<ul>
<li><a title="twibble" href="http://www.das-zentralorgan.de/twibble/" target="_blank">twibble</a>, a location aware twitter client for smartphones</li>
<li>source: <a title="tracker-python-001.zip" href="http://tinkerlog.com/wp-content/uploads/2007/09/tracker-python-001.zip">tracker-python-001.zip</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/09/23/using-twitter-and-twibble-for-mobile-tracking/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Firmware for the GPS tracking device</title>
		<link>http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/</link>
		<comments>http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 22:13:34 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[avr]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[gsm]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/</guid>
		<description><![CDATA[After some trouble with my SMS sending routine I am finally able to show some working code.
Features so far

Displays menu via serial port if attached to PC
Can run unattended or interactively for debugging
Fetches GPS positions and sends them via SMS every two minutes

If the circuit is powered on, the following sequence will be executed:

Boot up, [...]]]></description>
			<content:encoded><![CDATA[<p>After some trouble with my SMS sending routine I am finally able to show some working code.</p>
<p><strong>Features so far</strong></p>
<ul>
<li>Displays menu via serial port if attached to PC</li>
<li>Can run unattended or interactively for debugging</li>
<li>Fetches GPS positions and sends them via SMS every two minutes</li>
</ul>
<p>If the circuit is powered on, the following sequence will be executed:</p>
<ol>
<li>Boot up, switch on the GPS-GSM module</li>
<li>Initialize the modem</li>
<li>Fetch the GPS position, redo until position is fix</li>
<li>Parse and format position</li>
<li>Send formatted position as link to Google Maps as SMS</li>
<li>Wait 120 seconds</li>
<li>Goto 3</li>
</ol>
<p><strong>Rebuilding it</strong></p>
<p>Well, now you have all information and sources to rebuild and program this device, at least you  should. If not, please tell me, what is missing.</p>
<p>But I had some hints in the comments that this can be done easier with the built-in Python. There also other very promissing sources and that is definetely the next thing, that I want to try out. If that works fine, which is not really doubtful to me, I could drop nearly all the external components. That would make it cheaper, easier and smaller.</p>
<p>Nevertheless, the firmware can be useful, if you would like to see, which commands to use to talk to the Telit module.</p>
<p><strong>Links</strong></p>
<ul>
<li>Part I: <a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">Interfacing an AVR controller to a GPS Mobile Phone</a></li>
<li>Part II: <a href="http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/">Using Google Maps with a mobile GPS tracker</a></li>
</ul>
<p><strong>Downloads</strong></p>
<ul>
<li>Firmware:<a href="http://tinkerlog.com/wp-content/uploads/2007/08/beacon-v0.03.zip" title="beacon-v0.03.zip">beacon-v0.03.zip</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Using Google Maps with a Mobile GPS Tracker</title>
		<link>http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/</link>
		<comments>http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/#comments</comments>
		<pubDate>Sat, 28 Jul 2007 13:40:48 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[avr]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[gsm]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago I posted about how to interface an AVR microcontroller to a Telit GM862. You can read it here: <a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/" rel="bookmark" title="Permanent Link to Interfacing an AVR controller to a GPS Mobile Phone">Interfacing an AVR controller to a GPS Mobile Phone.</a><br />
That post got listed on <a href="http://www.hackaday.com/2007/07/15/sms-tracking-with-a-gps-gsm-enabled-avr/" target="_blank">Hack-A-Day</a>, <a href="http://www.engadget.com/2007/07/17/diyer-concocts-homegrown-gsm-gps-tracking-device/" target="_blank">Engadet</a> and <a href="http://www.makezine.com/blog/archive/2007/07/interfacing_an_avr_contro.html" target="_blank">Makezine</a> among many others! w00t! Thanks for posting and reading it, I really appreciate it.</p>
<p>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.<br />
<img src="http://tinkerlog.com/wp-content/uploads/2007/07/google_maps2_small.png" alt="google_maps2_small.png" /></p>
<p><span id="more-18"></span></p>
<p><strong>How does it work?</strong></p>
<p>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.</p>
<p>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.</p>
<ul>
<li>Power on the circuit.</li>
<li>Power on the GM862 module (done by the ATmega8)</li>
<li>Initialize the modem.</li>
<li>Initialize the GPS module (may be omitted).</li>
<li>Request a GPS position (repeat until the position is fix).</li>
<li>Send an SMS with GPS position to an SMS-to-Email service.</li>
<li>Open your email and click the Google Maps link.</li>
</ul>
<p><strong>More details</strong></p>
<p>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.</p>
<p>Starting the controller gives the following menu on the terminal:<br />
<code><br />
------<br />
Beacon v0.02 2007/07/28<br />
s - Change sms phone number<br />
o - Switch modem on/off<br />
i - Init modem<br />
m - Send SMS<br />
c - Cold start GPS<br />
p - Request GPS<br />
------<br />
key &gt;<br />
</code></p>
<p>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.</p>
<p>Initializing the modem is done with the following sequence of AT commands:</p>
<ul>
<li><code>AT</code>,  say hello</li>
<li><code>AT+IPR=19200</code>, set the baud rate to 19200</li>
<li><code>AT+CPIN=&lt;pin&gt;</code>, set your PIN for the SIM card</li>
<li><code>AT+CMEE=2</code>, choose extended error messages</li>
</ul>
<p>The modem should respond with the status LED blinking slower, if the PIN matches and the network is reachable.</p>
<p>Initializing the GPS is optional, as the modul starts the GPS on power on. You can force a cold or a warm start.</p>
<ul>
<li><code>AT$GPSR=1</code>, issue a cold start</li>
<li><code>AT$GPSR=2</code>, issue a warm start</li>
</ul>
<p>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.</p>
<p>The current position is requested by sending</p>
<ul>
<li><code>AT$GPSACP</code>, read the acquired position</li>
</ul>
<p>The response contains information about current time and date, the position and the number of available satellites.</p>
<p>To send send an SMS, send the following commands:</p>
<ul>
<li><code>AT+CMGF=1</code>, select text sms format</li>
<li><code>AT+CMGS="&lt;phone number&gt;"</code>, send the message to the given phone number. This command responds with an prompt <code>&gt;</code>. Now the text of the SMS can be transmitted. The message has to end with <code>0x1A</code>.</li>
</ul>
<p><strong>Parsing the GPS position</strong></p>
<p>The position string received from the GPS looks like this:</p>
<pre class="prettyprint">
GPSACP: 131924.999,5343.9291N,00954.7841E,2.6,34.0,3,29.78,0.32,0.17,
130707,07</pre>
<p>All tokens are separated with comma. The tokens are:</p>
<ul>
<li>time, hhmmss.SSS</li>
<li>position, latitude, degrees and minutes</li>
<li>position, longitude, degrees and minutes</li>
<li>hdop, horizontal diluition of precision</li>
<li>position, altitute, meters</li>
<li>fix, 0=invalid, 2=2D, 3=3D</li>
<li>cog, course over ground</li>
<li>spkm, speed in km</li>
<li>spkn, speed in knots</li>
<li>date, ddmmyy</li>
<li>nsat, number of satellites</li>
</ul>
<p>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.</p>
<p><strong>Sending a Google Maps link</strong></p>
<p>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:<br />
<code></p>
<p>http://maps.google.com/maps?q=&lt;lat&gt;,&lt;lon&gt;%28&lt;message&gt;</p>
<p>%29&amp;t=k&amp;z=&lt;zoom&gt;<br />
</code><br />
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).<br />
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.</p>
<p><img src="http://tinkerlog.com/wp-content/uploads/2007/07/mail_small.png" alt="mail_small.png" /></p>
<p><strong>Conclusion</strong></p>
<p>If everything went well, you should be able to click the link and see your browser opening Google Maps with your position.</p>
<p><img src="http://tinkerlog.com/wp-content/uploads/2007/07/google_maps3_small.png" alt="google_maps3_small.png" /></p>
<p>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.</p>
<p><strong>Links</strong></p>
<ul>
<li>Part I:<a href="http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/">Interfacing an AVR controller to a GPS Mobile Phone</a></li>
<li>Part III: <a href="http://tinkerlog.com/2007/08/08/firmware-for-the-gps-tracking-device/">Firmware for the GPS tracking device</a></li>
<li><a href="http://mapki.com/wiki/Google_Map_Parameters">Google Maps request parameters</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Interfacing an AVR controller to a GPS Mobile Phone</title>
		<link>http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/</link>
		<comments>http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 13:46:39 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[avr]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[gsm]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Part II <a href="http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/" rel="bookmark" title="Permanent Link: Using Google Maps with a Mobile GPS Tracker">Using Google Maps with a Mobile GPS Tracker</a> is online.</p>
<p>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.</p>
<p>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.</p>
<p><a href="http://www.zooomr.com/photos/9600baud/2687281/" title="Photo Sharing"><img src="http://static.zooomr.com/images/2687281_c4b1d8d0e3.jpg" alt="IMGP1475" height="409" width="500" /></a></p>
<p><span id="more-14"></span></p>
<p><strong>Materials</strong></p>
<p>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.</p>
<p>Here are some of the features of this GSM-GPS module:</p>
<ul>
<li>Quad band GSM</li>
<li>17mA average stand-by, 3.5mA in low-power mode</li>
<li>250mA average operating current</li>
<li>SiRF III GPS Receiver Built In</li>
<li>Data, Voice, SMS, and Fax</li>
<li>Data speeds up to 57.6kbps</li>
<li>Supply voltage : 3.4-4.2V</li>
<li>CMOS Camera Capable</li>
<li>Python Interpreter built-in</li>
</ul>
<p>Voice means you are not limited to mobile tracker applications. You could attach a speaker and a microphone to build a complete mobile phone!</p>
<p>So here is a list of what I purchased to get the first integration done.</p>
<ul>
<li>Telit GM862-GPS modul, <a href="http://www.roundsolutions.com/gsm-modem/index.htm">roundsolutions</a>: 126â‚¬, or Sparkfun: <span class="prod-price"><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=7917">CEL-07917</a>, $183.95<br />
</span></li>
<li>GM862 Evaluation Board, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=277">CEL-00277</a>, $29.95</li>
<li>Quad band antenna, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=675">CEL-00675</a>, $7.95</li>
<li>GPS antenna 3V, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=464">GPS-00464</a>, $14.95</li>
<li>2 interface cables for antenna, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=285">GPS-00285</a>, $8.95</li>
<li>optional: PolymerLithium Ion Batteries, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=341">PRT-00341</a>, $7.95</li>
<li>optional: LiPoly Charger, Sparkfun: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=726">PRT-00726,</a> $16.95</li>
<li>ATmega8 microcontroller, ca. 2â‚¬</li>
<li>Resistors: 100, 10k, 22k, 27k, 2 x 47k, 2 x 100k, ca. 1â‚¬</li>
<li>Capacitors: 2 x 22p, 100n, 10u, ca. 2â‚¬</li>
<li>LED, 0.10â‚¬</li>
<li>Transistor, BC337, 0.10â‚¬</li>
<li>Prototyping board, 3â‚¬</li>
<li>optional: bread board</li>
</ul>
<p>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.</p>
<p><strong>Circuit</strong></p>
<p>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 <a href="http://www.kh-gps.de/tb2.htm">Trackbox2</a>.</p>
<p>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.</p>
<p><a href="http://tinkerlog.com/wp-content/uploads/2008/01/beacon.png" title="Beacon schematic"><img src="http://static.zooomr.com/images/2686902_8e88930d84.jpg" alt="GM862_circuit" height="265" width="500" /></a></p>
<p>As you can see, there are very few connections really required to the GM862. You have to connect the following on the breakout board:</p>
<ul>
<li>RX, seriell modem communication</li>
<li>TX, seriell modem communication</li>
<li>RTS to ground, no handshake is used.</li>
<li>Status LED</li>
<li>On/off to power on the module</li>
<li>VCC and GND</li>
</ul>
<p>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.</p>
<p><strong>Operation</strong></p>
<p>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:</p>
<pre class="prettyprint">
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</pre>
<p>So now you know where I am living <img src='http://tinkerlog.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Conclusion</strong><br />
That&#8217;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.</p>
<p><strong><a href="http://www.zooomr.com/photos/9600baud/2687278/" title="Photo Sharing"><img src="http://static.zooomr.com/images/2687278_5c4439c836.jpg" alt="IMGP1490" height="375" width="500" /></a></strong></p>
<p><strong>Links</strong></p>
<ul>
<li>Part Two:<a href="http://tinkerlog.com/2007/07/28/using-google-maps-with-a-mobile-gps-tracker/" rel="bookmark" title="Permanent Link: Using Google Maps with a Mobile GPS Tracker">Using Google Maps with a Mobile GPS Tracker</a></li>
<li><a href="http://www.kh-gps.de/tb2.htm">Trackbox2</a>, great information about interfacing an AVR to a GM862, helped me a lot. In german.</li>
<li><a href="http://www.sparkfun.com/commerce/present.php?p=Port-O-Rotary">Portable Rotary Cellular Phone</a>, tutorial at Sparkfun on how to use a GM862. There is also a <a href="http://forum.sparkfun.com/viewforum.php?f=17">forum</a>, that has informations about GSM and GPS.<a href="http://www.roundsolutions.com/"><br />
</a></li>
<li><a href="http://www.roundsolutions.com/">roundsolutions.de</a>, retailer for the GM862 with a great forum.</li>
<li><a href="http://www.telit.co.it/modulef.asp?famId=7&amp;famName=GM862%20Modem%20Family">Telit</a>, all specs and guides for the GM862.</li>
</ul>
<p><strong>Downloads</strong></p>
<ul>
<li>Eagle schematics: <a href="http://tinkerlog.com/wp-content/uploads/2007/07/beacon.zip" title="beacon">beacon.zip</a></li>
<li>Eagle schematics as png: <a href="http://tinkerlog.com/wp-content/uploads/2008/01/beacon.png" title="beacon schematics">beacon.png </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone/feed/</wfw:commentRss>
		<slash:comments>105</slash:comments>
		</item>
	</channel>
</rss>
