Tutorial – Arduino and MediaTek 3329 GPS

Learn how to use MediaTek 3329-based GPS shields with Arduino in Chapter 19 of our Arduino Tutorials. The first chapter is here, the complete series is detailed here. If you have an EM406A GPS module, please visit the separate tutorial. Updated 15/01/2014

Introduction

In this instalment we will introduce and examine the use of the Global Positioning System receivers with Arduino systems. What is the GPS? In very simple terms, a fleet of satellites orbit the earth, transmitting signals from space. Your GPS receiver uses signals from these satellites to triangulate position, altitude, compass headings, etc.; and also receives a time and date signal from these satellites.

The most popular GPS belongs to the USA, and was originally for military use – however it is now available for users in the free world.

Interestingly, the US can switch off or reduce accuracy of their GPS in various regions if necessary, however many people tell me this is not an issue unless you’re in a combat zone against the US forces. For more information, have a look at Wikipedia or the USAF Space Command GPS Ops Centre site. As expected,  other countries have their own GPS as well – such as Russia, China, and the EU is working on one as well.

So – how can us mere mortals take advantage of a multi-billion dollar space navigation system just with our simple Arduino? Easy – with an inexpensive GPS receiver and shield. In this tutorial we’ll use a GPS shield based on the MediaTek3329 GPS receiver from Tronixlabs.

Unlike the EM406A used in the other tutorial, the whole lot is all on one shield – and after some experimenting has better reception. Plus there’s an onboard SD card socket which we’ll use for a GPS logging device. The only catch is that you need to solder the stacking headers yourself. (update – if purchased from Tronixlabs these will be fully assembled):

Linksprite Arduino GPS SD card shield

Apart from the GPS shield we’ll also be using a typical Arduino-compatible LCD shield and of course an Arduino Uno or compatible. Finally before getting started, you need to set the two jumpers on the GPS shield as shown in the following image:

Linksprite GPS Arduino shield jumpers

By doing this the serial data lines from the GPS receiver can be connected to Arduino D2 and D3 – which we will use with SoftwareSerial. The benefit of doing it this way is that you can then upload sketches without any hardware changes and also use the serial monitor and GPS at the same time. So let’s get started.

Testing your GPS shield

Simply connect your GPS shield as described above to your Arduino Uno or compatible, and upload the following sketch:

Note the use of SoftwareSerial in the sketch. As mentioned earlier, the GPS data is transferred to the Arduino via D2/D2 – which we set up as a software serial port.

If possible try to get your hardware close to a window, then open the serial monitor window. The first time you power up your receiver, it may take a  minute or so to lock onto the available satellites, this period of time is the cold start time.

The subsequent times you power it up, the searching time is reduced somewhat as our receiver stores some energy in a supercap (very high-value capacitor) to remember the satellite data, which it will use the next time to reduce the search time (as it already has a “fair idea” where the satellites are).

Moving on, after a few moments you should be presented with a scrolling wall of text, for example:

Arduino GPS raw NMEA data

What on Earth does all that mean? For one thing the hardware is working correctly. Excellent! Now how do we decode these space-signals… They are called NMEA codes. Let’s break down one and see what it means. For example, the line:

  • $GPRMC tells us the following data is essential point-velocity-time data;
  • 100748.000 is the universal time constant (Greenwich Mean Time) – 10:07:48 (hours, minutes, seconds). So you now have a clock as well.
  • A is status – A for active and data is valid, V for void and data is not valid.
  • 3754.9976  is degrees latitude position data = 37 degrees, 54.9976′
  • S for south (south is negative, north is positive)
  • 14507.0283 is degrees longitude position data = 145 degrees, 07.0283′
  • E for east (east is positive, west is negative)
  • 0.00 is my speed in knots over ground. This shows the inaccuracy  that can be caused by not having a clear view of the sky
  • 263.36 – course over ground (0 is north, 180 is south, 270 is west, 90 is east)
  • 140114 is the date – 14th January 2014
  • the next is magnetic variation for which we don’t have a value
  • checksum number

Thankfully the data is separated by commas. This will be useful later when you log the data to a text file using the SD card, as you will then be able to use the data in a spreadsheet very easily. For more explanation about the data, here is the NMEA Reference Manual that explains them all.

Extracting the GPS data

You can’t decode all that NMEA on the fly, so thankfully there is an Arduino library to do this for us – TinyGPS. So head over to the library website, download and install the library before continuing.

Now with the same hardware from the previous example, upload the following sketch:

How this works is quite simple. In void loop() the sketch waits for data to come from the GPS receiver, and then checks if it’s valid GPS data. Then it passes over to the function getgps() which uses the function:

to extract the location data and place it in two variables. Next, another function:

will extract the date and time data, and place them in the pre-determined variables. Finally the use of

and

can be assigned to variables as they store the altitude and speed respectively. These functions will be commonly used across all the examples, so you can see how they can be used.

To test the sketch, position the hardware and open the serial monitor. After a moment you should be presented with the GPS data in a much more useful form, for example:

Arduino GPS data

At this point you should be able to form ideas of how to harness that data and display or work with it in a more useful way. Useful hint – you can enter coordinates directly into Google Maps to see where it is, for example:

GPS data in Google Maps

 A portable GPS display

Now that you can extract the GPS data, it’s a simple matter of sending it to an LCD shield for display. Just add the LCD shield to your hardware and upload the next sketch. Be sure to change the values in the LiquidCrysal LCD… line if your shield uses different digital pins.

Again, position the hardware and your current position should be shown on the LCD, for example:

Arduino GPS LCD

A GPS Clock

Armed with the same hardware you can also create a GPS clock. With this you can finally have a reference clock and end all arguments about the correct time without calling the speaking clock. Just use the same hardware from the previous example and upload the following sketch:

Now position the hardware again, and after a moment the time will appear – as shown in this video.

Unless you live in the UK or really need to know what GMT/UTC is, a little extra work is required to display your local time. First you will need to know in which time zone you are located – find it in this map.

If your time zone is positive (e.g. GMT +10) – you need to add 10 to your hour value, and if it’s over 23 you then subtract 24 to get the correct hours.

If your time zone is negative (e.g. GMT – 5) – you need to subtract 5 from your hour value, and if it’s under zero  you then add 24 to get the correct hours.

GPS Speedometer

Just as with the clock, it’s easy to display the speed readings with the LCD. Using the same hardware as above, enter and upload the following sketch:

Now position the hardware again, and after a moment your speed should appear. You might get some odd readings if indoors, as the receiver needs data from several satellites to accurately determine your speed. The sketch is written for km/h, however you can replace the display lines with the section that is commented out to display miles per hour.

So at this point find a car and driver, an external power supply and go for a drive. You may find the GPS speed is quite different to the vehicle’s speedometer.

Build a GPS logging device

And for our final example, let’s make a device that captures the position, speed and time data to SD card for later analysis. The required hardware is just the GPS shield and Arduino Uno or compatible board – plus an SD memory card that is formatted to FAT16. SDXC cards may or may not work, they’re quite finicky – so try and get an older standard card.

Now enter and upload the following sketch:

This will append the data to a text file whose name is determine in line 34 of the sketch. If you are using a different GPS shield or a separate SD card shield you may need to change the digital pin value for the chip select line, which is found in lines 14 and 18. The data in our example is logged every ten seconds, however you can change the frequency using the delay() function in line 73.

When you’re ready to start capturing data, simply insert the card and power up the hardware. It will carry on until you turn it off, at which point the data file can be examined on a PC. As an example capture, I took the hardware for a drive, and ended with a file containing much data – for example:

Arduino GPS logging example data

For a more graphical result, you can import the data using a third-party service into Google Maps to get a better idea of the journey. But first, the text file requires a little work. Open it as a text file using a typical spreadsheet, which will then ask how to organise the columns. Delimit them with a space, for example:

delimit Arduino GPS data

Which will give you a spreadsheet of the data. Now delete all the columns except for the latitude and longitude data, and add a header row as such:

GPS data in spreadsheet

Now save that file as an .xls spreadsheet. Next, visit the GPS Visuliser website, and upload the file using the box in the centre of the page. Select “Google Maps” as the output format, and your trip will be presented – for example:

GPS trip map

There are many options on the visualiser site, so if you end up using it a lot – consider giving them a donation.

Conclusion

Now you have some easy example sketches that demonstrate how to extract and work with data from your GPS shield. For the curious, the static GPS locations displayed in this tutorial are not our current location. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, GPS, Mediatek 3329, shield, SKM58, tronixlabs, tronixstuff, tutorial0 Comments

Book – “Arduino Workshop – A Hands-On Introduction with 65 Projects”

Over the last few years I’ve been writing a few Arduino tutorials, and during this time many people have mentioned that I should write a book. And now thanks to the team from No Starch Press this recommendation has morphed into my new book – “Arduino Workshop“:

shot11

Although there are seemingly endless Arduino tutorials and articles on the Internet, Arduino Workshop offers a nicely edited and curated path for the beginner to learn from and have fun. It’s a hands-on introduction to Arduino with 65 projects – from simple LED use right through to RFID, Internet connection, working with cellular communications, and much more.

Each project is explained in detail, explaining how the hardware an Arduino code works together. The reader doesn’t need any expensive tools or workspaces, and all the parts used are available from almost any electronics retailer. Furthermore all of the projects can be finished without soldering, so it’s safe for readers of all ages.

The editing team and myself have worked hard to make the book perfect for those without any electronics or Arduino experience at all, and it makes a great gift for someone to get them started. After working through the 65 projects the reader will have gained enough knowledge and confidence to create many things – and to continue researching on their own. Or if you’ve been enjoying the results of my thousands of hours of work here at tronixstuff, you can show your appreciation by ordering a copy for yourself or as a gift 🙂

You can review the table of contents, index and download a sample chapter from the Arduino Workshop website.

Arduino Workshop is available from No Starch Press in printed or ebook (PDF, Mobi, and ePub) formats. Ebooks are also included with the printed orders so you can get started immediately.

LEDborder

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, Arduino Workshop, book, books, cellular, clocks, display, distance, ds1307, DS3232, education, EEPROM, freetronics, GPS, graphic, GSM, hardware hacking, I2C, internet, LCD, learning electronics, lesson, no starch press, numeric keypad, part review, product review, projects, RDM630, RDM6300, relay, review, sensor, servo, SMS, time clock, timing, tronixstuff, tutorial, twitter, wireless, xbee13 Comments

Moving Forward with Arduino – Chapter 19 – GPS part II

Learn more about Arduino and GPS in chapter nineteen 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.

Updated 24/01/2013

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.

“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, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half 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:

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). 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:

exam19p1currss

Here is the schematic:

exam19p1schematicss

 

Although the sketch (download) 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:

exam19p1boardss

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.

gps_satellite_nasa_art-iif

 “You went… where?”

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. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

Download the Example 19.2 sketch from here.

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

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 LibreOffice Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

import

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

gpslogcsv

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 http://www.gpsvisualizer.com/, 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:

gpswalk

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.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, COM-09622, DEV-09802, GPS, learning electronics, lesson, microcontrollers, RTL-10709, tronixstuff, tutorial2 Comments

Tutorial – Arduino and EM406A GPS

Learn how to use GPS and Arduino in chapter seventeen 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. If you have a MediaTek 3329 GPS module, please visit the separate tutorial.

Updated 14/01/2014

In this instalment we will introduce and examine the use of the Global Positioning System receivers with Arduino systems. What is the GPS? In very simple terms, a fleet of satellites orbit the earth, transmitting signals from space. Your GPS receiver uses signals from these satellites to triangulate position, altitude, compass headings, etc.; and also receives a time and date signal from these satellites. The most popular GPS belongs to the USA, and was originally for military use – however it is now available for users in the free world.

Interestingly, the US can switch off or reduce accuracy of their GPS in various regions if necessary, however many people tell me this is not an issue unless you’re in a combat zone against the US forces. For more information, have a look at Wikipedia or the USAF Space Command GPS Ops Centre site. As expected,  other countries have their own GPS as well – such as Russia, China, and the EU is working on one as well.

So – how can us mere mortals take advantage of a multi-billion dollar space navigation system just with our simple Arduino? Easy – with an inexpensive GPS receiver and shield. When searching for some hardware to use, I took the easy way out and ordered this retail GPS packwhich includes the required Arduino shield and header sockets, short connecting cable and an EM-406A 20-channel GPS receiver with in-built antenna:

packcontentsss

For reference now and in the future, here is the data book for the GPS receiver: EM-406 manual.pdf. All you will need is an Arduino Uno or 100% compatible board, and the usual odds and ends. When it comes time to solder up your shield, if possible try and sit it into another shield or board – this keeps the pins in line and saves a lot of trouble later on:

howtosolderss

And we’re done:

readyfor-workss

Please notice in the photo above the cable is a lot longer between the shield and the GPS receiver. This was an extra cable, which makes things a lot more convenient, and it never hurts to have a spare. Finally, on the shield please take note of the following  two switches – the shield/GPS power switch:

shieldonoffss

and the UART/DLINE switch:

uartdliness

For now, leave this set to UART while a sketch is running. When uploading a sketch to the board, this needs to be on DLINE. Always turn off your GPS shield board before changing  this switch to avoid damage.

Is anyone out there?

Now, let’s get some of that juicy GPS data from outer space. You will need:

Once you have your hardware assembled, upload the following sketch:

Now for desk jockeys such as myself, there is a catch – as a GPS receives signals from satellites the receiver will need to be in line of sight with the open sky. If you have your desk next to a window, or a portable computer you’re in luck.  Look at the LED on your GPS receiver – if it is blinking, it has a lock (this is what you want); on – it is searching for satellites; off – it is off (!). The first time you power up your receiver, it may take a  minute or so to lock onto the available satellites, this period of time is the cold start time.

This will be in ideal conditions – i.e. with a clear line of sight from the unit to the sky (clouds excepted!). Once this has been done, the next time you power it up, the searching time is reduced somewhat as our receiver stores some energy in a supercap (very high-value capacitor) to remember the satellite data, which it will use the next time to reduce the search time (as it already has a “fair idea” where the satellites are). Now open the serial monitor box, sit back and wait a moment or two, and you should be presented with something very similar to this:

example17p1data

What a mess. What on earth does all that mean? For one thing the hardware is working correctly. Excellent! Now how do we decode these space-signals… They are called NMEA codes. Let’s break down one and see what it means. For example, the line: $GPRMC,165307.000,A,2728.9620,S,15259.5159,E,0.20,48.84,140910,,*27 Each field represents:

  • $GPRMC tells us the following data is essential point-velocity-time data;
  • 165307.000 is the universal time constant (Greenwich Mean Time) – 16:53:07 (hours, minutes, seconds). So you now have a clock as well.
  • A is status – A for active and data is valid, V for void and data is not valid.
  • 2728.9620 is degrees latitude position data = 27 degrees, 28.962′
  • S for south (south is negative, north is positive)
  • 15259.5159 is degrees longitude position data = 152 degrees, 59.5159′
  • E for east (east is positive, west is negative)
  • 0.20 is my speed in knots over ground. This shows the inaccuracy  that can be caused by not having a clear view of the sky
  • 48.84 – course over ground (0 is north, 180 is south, 270 is west, 90 is east)
  • 140910 is the date – 14th September, 2010
  • the next is magnetic variation for which we don’t have a value
  • checksum number

Thankfully the data is separated by commas. This will be useful if you are logging the data to a text file using a microSD shield, you will then be able to use the data in a spreadsheet very easily. Later on we will work with data from other codes, but if you can’t wait, here is the NMEA Reference Manual that explains them all. In the meanwhile, how can we convert the location data (longitude and latitude) received into a position on a map?

  • Visit this website
  • In the box that says “paste your data here”, enter (for example, using my data above)

For example:

visualiser

Then click “Draw the Map”, and you will be presented with a Google map in a new window that you can zoom around in, change views and so on. Interestingly enough the coordinates returned in the test above were accurate down to around three meters. Later on that website will be of great use, as you can import text files of coordinates, and it will plot them out for you. If you use this mapping site a lot, please consider making a donation to help them out. Now as always, there is an easier way. The purpose of the previous demonstrations were to see the raw data that comes from a receiver, and understand how to work with it.

gps_satellite_nasa_art-iif

Moving on… now we can receive GPS signals – and in the past we have used LCD modules – so we can make our own variations of portable (!) GPS modules and other devices. At this point you will need to install another Arduino library – TinyGPSSo download and install that before moving forward.

“My First GPS”

Using various pieces of hardware from the past, we will build a simple, portable unit to display our data.

You will need:

  • Arduino Uno or compatible board
  • a suitable GPS setup – for example the GPS shield bundle
  • An LCD with HD44780 interface that has the ability to connect to your Arduino system. The size is up to you, we’re using a 20 x 4 character unit. If you have dropped in or are a bit rusty on LCDs, please read chapter twenty-four;
  • An external power supply for your setup (if you want to walk up and down the street at midnight like I did) – for example, a 9V battery snap soldered to a DC plug is a quick and dirty solution!

Luckily I have made an LCD shield in the past which works nicely, and doesn’t use digital pins D0 and D1 – these are used by the GPS shield to get the data back to the Arduino. Therefore the whole lot just plugged in together as shields do. Here is the sketch for your consideration:

Before uploading the sketch, turn off the GPS shield, set the DLINE/UART switch on the GPS shield to DLINE, upload the sketch, then set it back again, then back on with the GPS shield. So here it is all thrown together in my lunch box:

exam17p2boxss

And a close-up view of the LCD. There was not room for the course data, but you can modify the sketch accordingly. The data will be a little off due to the photo being taken indoors:

exam17p2lcdss

Now for some outdoor fun. In the video clip below, we take a ride on the bus and see our GPS in action. I had to take an old bus that wasn’t full of security cameras, so the ride is bumpy:

sl250ss

As we have a lot of electronics in this setup, it would be interesting to know the current draw – to help plan for an appropriate power supply. The trusty meter gives us:

exam17p2currentss

Wow – a maximum of 122 milliamps even with that LCD backlight blazing away. So when we make some GPS logging devices without such a monstrous LCD, we should be able to get the current draw down a lot more. The purpose of this example was to show how you can manipulate the data from the GPS receiver.

“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, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half 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:

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). 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:

And the sketch:

Although the sketch 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.

”You went… where?”

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. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

And here is the sketch:

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

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 LibreOffice 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 http://www.gpsvisualizer.com/, and use the Get Started Now box in the middle of the web page. SelectGoogle 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.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, beginnner, education, GPS, GPS-09123, learning electronics, lesson, microcontrollers, RTL-10709, tutorial13 Comments


Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: