{"id":1106,"date":"2012-10-17T13:30:46","date_gmt":"2012-10-17T05:30:46","guid":{"rendered":"http:\/\/www.rocketscream.com\/blog\/?p=1106"},"modified":"2013-06-10T14:24:30","modified_gmt":"2013-06-10T06:24:30","slug":"vehicle-tracking-logging-using-tralog-shield","status":"publish","type":"post","link":"https:\/\/www.rocketscream.com\/blog\/2012\/10\/17\/vehicle-tracking-logging-using-tralog-shield\/","title":{"rendered":"Vehicle Tracking &#038; Logging Using TraLog Shield"},"content":{"rendered":"<p>Last week when we posted an <a title=\"WISMO228 Library Update\" href=\"http:\/\/www.rocketscream.com\/blog\/2012\/10\/06\/updated-wismo228-library-for-arduino\/\" target=\"_blank\">update to the WISMO228 library for Arduino<\/a>, we mentioned we were using the TraLog shield as a vehicle tracking &amp; logging device. We finally found some time in between everything to write this post and illustrate what the TraLog shield is capable of.<!--more--><\/p>\n<p>Years back, when we were doing a freelance job making a <a title=\"Tea Brewing Machine\" href=\"http:\/\/www.flickr.com\/photos\/53660215@N05\/5997323817\/\" target=\"_blank\">tea brewer machine<\/a>, the client asked whether we were interested in making a vehicle tracking device for oil tankers in Indonesia. The job was beyond our capability to accept.\u00a0There were critical safety aspects (oil &amp; gas = explosion proof)\u00a0and most importantly deploying them on thousands of oil tankers in a large country like Indonesia would be a big task (scary too!). We politely declined the offer (and finished the tea brewing machine). But soon after that, we started to toy around with the idea of actually making one! That is basically how the TraLog shield came about.<\/p>\n<p>In this example, the TraLog shield is used to track the position of a vehicle using GPS, transmits the position to a server (<a title=\"Cosm\/Pachube\" href=\"http:\/\/www.cosm.com\" target=\"_blank\">Cosm\/Pachube<\/a> in this case) and also stores the position in non-volatile memory. Hardware requirements:<\/p>\n<ul>\n<li>An Arduino board &#8211; A Duemilanove or Uno.<\/li>\n<li><a title=\"TraLog\" href=\"http:\/\/www.rocketscream.com\/shop\/tralog\" target=\"_blank\">TraLog shield<\/a>\u00a0(with included GSM and GPS antennas) &#8211; Of course!<\/li>\n<li>Micro SD card &#8211; Pre-formatted in FAT32 format.<\/li>\n<li>Car power adapter to DC barrel jack &#8211; Ensure the internal fuse rating is capable of at least 2 A.<\/li>\n<li>SIM card &#8211; Not pin locked and capable of data transfer.<\/li>\n<li>Laptop &#8211; If you want see what&#8217;s happening in the background.<\/li>\n<li>2 CR1220 3 V coin cell &#8211; If you want to maintain the RTC and GPS hot start capability\u00a0in the even of power failure.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogAllYouNeed.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1108\" title=\"TraLog All You Need\" alt=\"\" src=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogAllYouNeed.jpg\" width=\"600\" height=\"402\" srcset=\"https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogAllYouNeed.jpg 600w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogAllYouNeed-300x201.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>As the GSM module requires nearly 2 A of peak current during transmission, the power from the USB port can&#8217;t provide enough\u00a0current. The TraLog shield houses an <a title=\"LT3481\" href=\"http:\/\/www.linear.com\/product\/LT3481\" target=\"_blank\">efficient switch mode buck converter<\/a> which is capable of taking in a higher input voltage like 12 V and regulating it down to 3.6 V (voltage input for the GSM module) without generating a lot of heat like a conventional linear regulator. We were looking for a car adapter plug that has a DC barrel jack plug on the other end to power the system but we couldn&#8217;t find any nearby and buying from Ebay would have meant waiting a lot longer. We ended up buying the cheapest car charger cable we could find that came with a micro USB end (for your fancy cell phones). We ripped off the micro USB end and replaced it with DC barrel jack cut from from an old transformer based AC-DC adapter. As expected, the car charger cable comes with a <a title=\"MC34063\" href=\"http:\/\/www.google.com.my\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;cad=rja&amp;sqi=2&amp;ved=0CCkQFjAB&amp;url=http%3A%2F%2Fwww.onsemi.com%2Fpub%2FCollateral%2FMC34063A-D.PDF&amp;ei=e4d9UKn3DMysrAfpnYEY&amp;usg=AFQjCNFAiRMwHsKOnA8NQtV8h9iBNhPTNg&amp;sig2=0NHNVUI-kLYC_sPk4brBkw\" target=\"_blank\">MC34063<\/a> buck circuit which we removed and connected directly to the fuse section (rated 2.5 A).<\/p>\n<p><a href=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterDefault.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1110\" title=\"Car Power Adapter Default\" alt=\"\" src=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterDefault.jpg\" width=\"600\" height=\"402\" srcset=\"https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterDefault.jpg 600w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterDefault-300x201.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterModified.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1111\" title=\"Car Power Adapter Modified\" alt=\"\" src=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterModified.jpg\" width=\"600\" height=\"402\" srcset=\"https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterModified.jpg 600w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/CarPowerAdapterModified-300x201.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Once we got the all the power requirements sorted out, we were basically left with putting everything else together. The TraLog shield stacked on top of an Arduino board was placed on the dashboard (with a double sided tape) with the GPS active antenna placed next to it. You don&#8217;t have to put the GPS antenna outside the vehicle (like on the roof top) as it works awesomely inside the vehicle.\u00a0If the GPS gets a proper satellite signal fix, the red LED will start to blink every 1 s. We usually get around a 7-8 satellite signal fix with a few more in sight (but not fixed) with the antenna placed inside the vehicle.<\/p>\n<p><a href=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSetupInVehicle.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1112\" title=\"TraLog Setup In Vehicle\" alt=\"\" src=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSetupInVehicle.jpg\" width=\"402\" height=\"600\" srcset=\"https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSetupInVehicle.jpg 402w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSetupInVehicle-201x300.jpg 201w\" sizes=\"auto, (max-width: 402px) 100vw, 402px\" \/><\/a><\/p>\n<p>We used a laptop to monitor the operation of the system.\u00a0We used hyper terminal (old school rocks!) but\u00a0any simple terminal program will do. You can skip this if you think it&#8217;s going to be a big distraction to your driving!<\/p>\n<p><a href=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1113\" title=\"TraLog Serial Port Debug\" alt=\"\" src=\"http:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug.png\" width=\"857\" height=\"575\" srcset=\"https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug.png 857w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug-600x403.png 600w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug-300x201.png 300w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug-768x515.png 768w, https:\/\/www.rocketscream.com\/blog\/wp-content\/uploads\/2012\/10\/TraLogSerialPortDebug-705x473.png 705w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/a><\/p>\n<p>The Arduino sketch (available for download at the bottom of the post) basically performs a GPS coordinate\u00a0acquisition\u00a0every minute (depending how much granularity you need and the cost of GPRS data transmission), transmits the location (longitude &amp; latitude) on GPRS as Cosm feeds, and logs the location and time onto the micro SD card. Sending the coordinates to the Cosm server utilizes a HTTP PUT request implemented by the WISMO228 library. The sketch can be easily modified to send the data to another server (with custom scripts) using either the HTTP PUT or the insecure HTTP GET method provided in the library. The unused I2C and analog pins on the Arduino board can also be used to interface with external sensors (temperature, barometric, pressure, etc) on top of the GPS coordinates.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nif (millis() &gt; scheduler)\r\n{\r\n  \/\/ Set next logging interval\r\n  scheduler = millis() + LOG_INTERVAL;\r\n\r\n  \/\/ Check for new GPS data\r\n  processGPS();\r\n\r\n  \/\/ If new GPS data is available\r\n  if (newGpsData)\r\n  {\r\n    \/\/ Send latest latitude &amp; longitude to Cosm\r\n    processGSM();\r\n    \/\/ Log latitude, longitude, and time onto micro SD card\r\n    processSD();\r\n    \/\/ Latest GPS data logged\r\n    newGpsData = false;\r\n  }\r\n}\r\n<\/pre>\n<p>We created a <a title=\"TraLog - Vehicle Tracking &amp; Logging on Arduino\" href=\"https:\/\/cosm.com\/feeds\/72776\" target=\"_blank\">Cosm feed here<\/a> which has a latitude and longitude data stream. Without graphical geo location mapping, it would be very hard to visualize the movement of the system. Cosm provides a simple <a title=\"Cosm Trails\" href=\"http:\/\/apps.pachube.com\/trails\/\" target=\"_blank\">geo-location mapping utility called Trails<\/a> that can be placed on any regular website. However we found several limitations:<\/p>\n<ul>\n<li>The data points selected from the feeds are spaced out and hence produce jagged way points on the map.<\/li>\n<li>Only the last 24 hours of data is mapped.<\/li>\n<\/ul>\n<p>But, it gives us a rough idea on how everything would look. We are currently looking into writing a server side script that performs a <a title=\"HTTP GET\" href=\"https:\/\/cosm.com\/docs\/v2\/feed\/list.html\" target=\"_blank\">HTTP GET request on the Cosm feeds<\/a> and provides a geo-location mapping visualization using<a title=\"Google Mapping API\" href=\"https:\/\/developers.google.com\/maps\/\" target=\"_blank\"> Google&#8217;s mapping API<\/a>. This will be next in our to do list!<\/p>\n<p>Feel free to try out the code. Feedback is welcomed!<\/p>\n<p><strong>Downloads:<\/strong><\/p>\n<ul>\n<li><a title=\"Vehicle Tracking &amp; Logging Sketch\" href=\"https:\/\/github.com\/rocketscream\/TraLog\/blob\/master\/VehicleTracking.ino\" target=\"_blank\">Vehicle Tracking &amp; Logging Arduino sketch<\/a>.<\/li>\n<li><a title=\"WISMO228 Library for Arduino\" href=\"https:\/\/github.com\/rocketscream\/WISMO228\" target=\"_blank\">WISMO228 library for Arduino<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Last week when we posted an update to the WISMO228 library for Arduino, we mentioned we were using the TraLog shield as a vehicle tracking &amp; logging device. We finally found some time in between everything to write this post and illustrate what the TraLog shield is capable of.<\/p>\n","protected":false},"author":1,"featured_media":1107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[14,40],"tags":[151,36,37,35,38,39],"class_list":["post-1106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-tralog-projects","tag-arduino","tag-gprs","tag-gps","tag-gsm","tag-micro-sd","tag-tralog"],"_links":{"self":[{"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":22,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"predecessor-version":[{"id":1568,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/posts\/1106\/revisions\/1568"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/media\/1107"}],"wp:attachment":[{"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocketscream.com\/blog\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}