reverse engineered

Arduino GPS Clock

I had a Holux M-1000B Bluetooth GPS module that was just gathering dust in my room. I had bought it from DealExtreme back in the days when I had GPS-less (but external GPS capable) Nokia E51. Upgrading to a Nokia E52 has since made this receiver redundant. However, since getting an Arduino, and being put off by the price of GPS shields for them, I decided to use the GPS receiver I already have.

Once the receiver is connected to satellites, the device just spews GPS NMEA V3.01 data at you via Bluetooth SPP or a virtual USB COM port on the PC. Building Arduino projects are a bit like playing with Lego as a child - You spend hours rooting through the big box for one part (only in the case of Arduinos, it’s the delivery of parts from electronics suppliers) and when you get it, you can finally finish it. The project sits on your desk for about 1 day to be admired, and then it gets dissembled, never to be rebuild (well, unless it’s really good).

Despite opening the board up and finding the appropriate points to probe it was easier just to leave the GPS on the window ledge, and connect it to the PC via bluetooth. I could then pipe the output from the GPS serial port to the Arduino serial port. The settings for the GPS COM port are 38400 baud 8,N,1 if you want to look at what the device is sending out. Because NMEA is an ASCII based protocol, parsing programs are trivial to write. Below is a sample Linux command and some sample NMEA output sentences:

user@host:~$ cat /dev/rfcomm1

Once you have verified that the GPS is working, it is time to pipe (redirect) the output from the GPS out to the Arduino. My GPS is connected at /dev/rfcomm1, and my Arduino is connected at /dev/ttyUSB0, so the command to first setup the device at the appropriate baud rate, and then redirect would be this:

stty -F /dev/ttyUSB0 38400
sudo cat /dev/rfcomm1 > /dev/ttyUSB0

Because the device has no configurable parameters, there is no need to transmit to the device. Therefore only a one way redirect is required.

#include <WString.h>                // include the String library
#include <nokia_3310_lcd.h>            //include LCD library

Nokia_3310_lcd lcd=Nokia_3310_lcd();    //instantiate LCD class char buffer[250]; //initialise char buffer boolean DST=false; //DST enabled? else UTC

void setup() { Serial.begin(38400); //initialise serial port lcd.init();                             //initialise LCD }

void loop(){    int ptr =0;    while(Serial.available() > 0) { //while there is serial data, read it      buffer[ptr]=<b >Serial</b></b>.read(); //store it in the buffer      Serial.println(buffer[ptr]);      if(buffer[ptr]==’/n’){ //break on newline        break;      }      ptr++;;    }

  if(((String) buffer).contains(”$GPGGA”)){ //cast char array as string to use strsearch     if(DST){ //if DST enabled, do some nifty shufty stuff       int hour=atoi((char)(buffer7,buffer[8])); //cast hour chars from buffer as char, and convert to int       if (hour==23){         buffer7=(char)0; //midnight case         buffer[8]=(char)0;       }else{         hour++;                                  //increment hour         char* hourchar;         itoa(hour,hourchar,10);                  //convert int to char*         buffer7=hourchar1;         buffer[8]=hourchar[0];       }     }     int j=0;     <span style=“color: #CC6600;”>for</span>(int i=7;i<13;i++){       lcd.writeCharBig((j++)*12,0,buffer[i],0); //write date to screen.     }   } }


You might notice that the methods in the Nokia_3310_lcd class have changed since my last project. I was planning to rewrite that class myself, but I’m glad I had a google before I did. Thanks to Andy for this updated library. This library is much leaner and more functional than the one supplied by nuelectronics.

This device project will probably exist for roughly 24 hours before being I get bored of it and need the Arduino board for something else. :)

Arduino GPS Clock

comments powered by Disqus