Introduction: Arduino GPS Logger

Have you ever wanted to log your coordinates and check your route on a map? Check a car's or truck's route? See your bike tracking after a long journey? (Or spy on y̶o̶u̶r̶ ̶w̶i̶f̶e someone using your car? :) ) It is all possible with the help of this little device. It is called a GPS logger, not a GPS tracker, as you do not have the opportunity to check it on the go. The data is saved to an SD card and you can check your journey afterwards.

The device is a small plastic box with an Arduino inside. The Nano uses a GPS module to track its position and an SD card to log it. There is also a small RGB LED for feedback. If you are familiar with the things used, you can make this device in an hour. I am going to write a step by step instructable on the build so let's get started.

I usually use the phrase 'SD card' during the instructable but what I really mean is a micro SD card.

I know that anybody can use a smartphone to do this, but where is the fun in that?

PS: I completely trust my wife (for now :) )

Supplies

Things you will need:

  • Arduino Nano compatible board
  • GPS module (U-blox NEO 6M with UART)
  • SD card module
  • SD card
  • RGB LED (optional, but very useful)
  • Resistors for the LED (3 pieces of around 330 Ohm, can even be 1K with high intensity LEDs)
  • Small plastic box
  • DC connector
  • 12V Car cigarette lighter plug (optional)

Tools:

  • Soldering iron and solder
  • Basic tools
  • Electric drill
  • Double sided tape or hot glue (Come on, everybody loves hot glue)
  • PC to program the Arduino

Step 1: Drill the Box

Sadly I do not own a 3D printer, so I have to order a small plastic enclosure from China and drill holes onto it. The box needs to be small, but big enough to fit all the electronics inside. If you gather the components you will definitely realize how big it should be. I ordered 5 little black enclosures, as I also needed a few of them for another project. The casing must not be metal, as the GPS module will not be able to track any GPS satellites.

You will need two holes. One for the DC connector and one for the LED. If you wish to not use an LED, you obviously only have to drill one hole. For my DC connector, I needed an 8mm hole, and for the LED a 5mm hole.

Step 2: Soldering

If your Nano comes without the headers soldered, you can solder them into place or leave it as it is, so it will be really flat. If you choose to not use the headers, solder the components to the Arduino in the Connecting things step. If you use the Nano with the male headers, solder female headers to the wires. You might want to use heatshrink tubes to insulate everything well.

If you choose to use an RGB LED as I did, you will need to solder the resistors to the cathodes. I use a common anode type of LED. ( If you use a common cathode type, you should solder the resistors to the anodes, modify the code and connect it to GND instead of 5V.)

The NEO-6M GPS module has 4 connectors. We will only use 3 of them, VCC, GND and Tx. The GPS module uses serial communication and we will use software serial to read it. VCC goes to 5V, GND to GND and Tx to Arduino pin D9.

The micro SD card module has 6 connectors. It uses SPI communication. Arduino D11 will go to MOSI, D12 to MISO, D13 to SCK and D4 to Chip Select or CS.

You need two wires for the DC connector. One is for GND and the other for the 5-12V DC. You can use various power supplies to power the device. You can use a 12V car cigarette plug (not 24V truck cigarette plug), 2 or 3 cell LiPo batteries, 5V power banks or anything that gives you 5-12V DC.

Step 3: Programming

You can use my sketch to log the position of the device or you can write your own.

If you choose to use my sketch, you will have to download the program code and the SdFat library. Extract the files and move the folders to your Arduino folder. The SdFat folder goes to the libraries folder.

Plug your Arduino to your PC. Make sure that you have all the necessary drivers installed. In the Arduino IDE choose your board and the appropriate port. Open the project, hit upload and pray. If everything goes well, you should have no errors and your GPS logger firmware is ready to use.

You don't have to create the log file manually, the program will create one, if it detects no log.txt on the SD card.

Step 4: Connecting Things

You should make the connections as written below. The pictures can help. Make sure to have secure contacts, as the device may get shocks or shakes during the ride.

Connect the LED Anode to Arduino 5V, RED to D3, GREEN to D5 and BLUE to D6. You can use other pins if you would like to, but keep in mind, that you have to change the definitions in the program code too.

Connect the GPS VCC to Arduino 5V, GND to GND and Tx to D9.

Connect the SD module MOSI to Arduino D11, MISO to D12, SCK to D13 and CS to D4. You can not use other pins for these connections, the only variable one is CS, which you have to change in the program code.

Connect the GND of the DC connector to Arduino GND. Connect the 5-12V of the DC connector to Arduino VIN. Do not connect it to 5V!

It is advised to mount all the components to the base of the enclosure so the top can be removed. (I secured everything to the top so I can easily access the SD card. The only thing on the base is the DC connector. This would not be a problem with a custom designed 3D printed enclosure.)

You can use double sided tape or hot glue. You can even secure the modules with small bolts.

Step 5: Test and Map

To test the device, you need to power it up. The feedback LED will tell you about the status of the device. It might need a few minutes (especially the first time) to track enough satellites. Once it can see enough satellites, the time and position will be logged to the micro SD card, and the program will wait 20 seconds. You can tell it by the LED. It will be green for a really short time, then blue. You can fiddle around in my code, if the logging interval is too short for you (set the sleeptime definition as desired in milliseconds). If the device sees no satellites, the LED will flash RED. If it sees some, but not enough, it will flash YELLOW. The device will only log the position if it tracks more, than 5 satellites and the data quality reported by the GPS is 1. It will log the date, time, longitude, latitude, speed, data quality and the number of tracked satellites. If there is no SD card connected or it is not detected, the LED will flash with RED and BLUE lights.

To see your route on map, you need the data from the micro SD card. You have to copy the content of the txt log file and paste it to excel. You will need to copy the longitude and latitude columns of your worksheet.

Paste the data to this website to see the results:

http://www.gpsvisualizer.com/map_input?form=data

You have to uncheck the 'Open in new window' option. It might give a warning about the data, but don't worry, it will work. Hit the 'Draw the map' button real fast and hard and there you have it.

Step 6: Done and Notes

You are done! C̶o̶n̶g̶r̶a̶t̶h̶s̶u̶a̶t̶i̶o̶n̶!̶ ̶C̶o̶n̶g̶r̶a̶s̶u̶l̶a̶t̶i̶o̶n̶!̶ ̶C̶o̶n̶g̶r̶a̶t̶! Grats!

Notes:

  • The GPS connection needs some time to be established
  • It is faster if you try it in the open air, but it also works in cars and trucks
  • Do not use more than 12V to power the device
  • The feedback LED is optional
  • The date and time data can be corrupted, in which case special characters appear in the position of corrupt characters. The GPS module sends the corrupt data, so I could not find a workaround.
  • Do not look directly at the operational end of the device
  • Do not submerge the device in liquid, even partially

When powering the device from 12V for a long period of time, the voltage regulator on the Arduino might get hot. It is not in the notworkingorresetting hot range, but in the hottothetouchbutitshouldbeokay range. Using more than 12V might damage the onboard voltage regulator.

Now you are ready to use this little gadget to log your journey and map it while having a cake. Once you are done, I have to say: Unbelievable! You, Subject Name Here, must be the pride of Subject Hometown Here.

1 Hour Challenge

Participated in the
1 Hour Challenge