Monday, October 11, 2010

Moving Forward with Arduino – Chapter 19 – GPS part II

This is part of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe.

The first chapter is here, the complete series is detailed here.

Welcome back fellow arduidans

In this instalment we will continue to examine the use of our GPS system and Arduino through creating two more applications. Some of them may seem simple, but we will build on them later on to make more complex things. To review previous information, the first GPS instalment was chapter seventeen.

Example 19.1 – “Household official time”

At home we often have various discussions about what the actual time is. At first it sounds silly, but when you have clocks on the microwave, kitchen wall, VCR (yes), wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my mother has all her clocks ten minutes fast. Insanity may prevail!

So let’s make a nice big LED-display reference clock – something that wouldn’t look out of place in a radio or television studio:" src="" height="143" alt="" style="display: block; margin-left: auto; margin-right: auto; border: 1px solid #333333;" width="291" />

Then when people start arguing over the time, you can point at your new clock and smile. From a hardware perspective, we will combine three or four things: our Arduino board, our GPS system, and the MAX7219 display driver. We will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • Maxim MAX7219 display driver IC
  • two four-digit, seven-segment LED displays (common cathode), such as Farnell 5014920 or Digikey 67-1442-ND. You could also rig up four separate digits with some patience;
  • one 1 kilo ohm resistor
  • one 10 kilo ohm resistor
  • one single pole, double-throw switch
  • a nice breadboard and some connecting wire
  • a separate 5V power supply – all those LED segments are thirsty, the completed clock uses under 350 milliamps with a brightness setting of 8:

Here is the schematic:

Although the sketch (ex19.1.pdf) may seem quite complex, it is just made up of things we have already examined in the past. The only unfamiliar part could be the MAX7219 display driver IC, which in itself is quite easy to use. There is a full part review and explanation here. It is most likely that everyone will have different LED display units, as the 4-digit modules can be hard to track for some people or too expensive –  so some more explanation is in order.

You will need common-cathode display modules. If you line the digits up from left to right, they will be numbered zero to nine with respect to the MAX7219 – so connect MAX7219 pin 2 to the cathode of your first display, and so on. With regards to the anodes (a~g and dp [decimal point]) – link each anode type together.

For example, if you have eight separate 7-segment display modules, connect each ‘a’ pin together, then to MAX pin 14. And so on. Here is the board layout – a real mess:

And our action video:

An interesting twist you might find of interest is the function:


Which allows you to alter the brightness of the LED display(s). The range is 0 to 18 – in my examples it has been set to 8. You could then make your clock dim the display brightness between (for example) 11pm and 5am – so when you wake up in the middle of the night the display won’t act like a frickin’  laser-beam burning into your eyeballs. Furthermore, dropping the brightness reduces the power consumption.

Anyhow, I hope you found the sketch and operation easy to understand, however if you have any questions – please ask in our Google Group.

Now it is time for what most of you have been waiting for – making a GPS tracking device. Now before you get too excited, it would be proper to make sure you have the permission of someone before you track them.

Example 19.2 – “You went… where?”

From a hardware perspective this example is a lot easier that you think – it is just the hardware from example 17.1 and a microSD card shield.  The sketch is even easier. You will need to install the SdFAT library first of all. Then restart your Arduino software, and select File > Examples > SdFat > SdFatGPS_CSVSensorLogger. That will be our sketch. Thanks to ladyada and Bill Greiman for their work on that sketch and library. Those two have really done all the hard work for us, thanks guys!

Then, we will need the following items:

And here it is:

Although the hardware wasn’t that interesting to plug together, what can be done with it and the data it captures is quite fascinating. To generate some sample data, I have taken the hardware for a walk to the post office. We will now open the file produced by our hardware and examine it further. If you would like to follow along, you can download the file from here.

The file is a typical, comma-delimited text file. You can examine it further using common spreadsheet software such as Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

You can see that the data delimits quite easily. Just click “OK” and the file will be presented to you.

So as you can see, there is time, date (remember – GMT), latitude and longitude, my speed (with a couple of anomalies) and random sensor data results (see the sketch). We can have this data converted into a much more useful form by using the GPS Visualiser website. Save the data as a .csv file. Then visit, and use the Get Started Now box in the middle of the web page. Select Google Maps as the output format, then upload the file. This will result in the following:

Just like normal Google Maps there are many display options you can choose from, and the GPS Visualiser web site has many tutorials about making the most of their service. If you look in detail you will see some “jittering” along parts of the track that are not representative of my movements (though I had just taken my morning coffee). This could be the result of the receiver module moving about in all three axes during my walk, one would imagine it would be a lot smoother inside a motor vehicle. So have fun with that.

Thus concludes our second chapter about Arduino and GPS. There will be another GPS chapter, most likely chapter twenty-one, so please subscribe to receive updates (see top-right of page). If you have any comments at all please use our dedicated Google Group – please sign up, it’s free and we can all learn something. If you would like to showcase your work from this article, email a picture or a link to john at tronixstuff dot com. You might even win a prize!

High resolution photos from this article are available in flickr.

Once again, thanks to Limor Fried (ladyada) and Bill Greiman for their work on the GPS logger library and sketch.

Please subscribe (see the top-right of this page) to receive notifications of new articles.

So have fun, stay safe and see you for our next instalment!

No comments:

Post a Comment