SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By coms418
Hi all, I am putting myself down as a newbie for now.
I have been playing around with my Arduinos for about a month now.
I have managed to get a couple of projects type tested and sort of working.
The local Amateur Radio club that I am a member has asked me if I could make a GPS locked clock for the next field day, I said yes its in March the 19th - 20th.

I have some lovely large 7 segment displays size of them is 180mm x 230mm, could read the clock from 100 paces, lol.

Now on to my problem, its going to be a simple error on my part but I have been trying to get a stupid GPS to talk to an Arduino now for 5 days, and are starting to lose it...

Now I have tested the GPS unit, its a ublox unit that outputs data at 9600 bps and needs to be inverted and buffered to correct rs232 levels for a PC to read it, this is no problem works fine.
Talking about rs232 data into the cpu, correct me if wrong the voltage swing for the TTL GPS data should it be 0v - 5v signal or 5v to 0v I have tried it all and the input pin should be the pin 3 on the area marked PWM, right?

The Arduinos are the mega ones 1x 1280 , 1x 2560, I have a really big project latter on thats going to need some space

With the IDE there is a couple of demos, TimeGPS, now with a little code change from 4800 to 9600 it should read the GPS and output the data via the serial port display to right in front of me, NOTHING, zip, narder.

I have check everything at least ten times now and I am ready to say sorry no I am not doing it, plus the talk on these micros no, I normally give very good talks on what ever I am explaining at levels the people can understand.

I was hoping some one might be able to point out what I have done wrong.

If is really the start to many projects that require a gps not only for UTC time but location and height.

I am looking forward to any help, I am to young to have Grey hairs..

By esklar81

First: Inhale deeply :)

Second: You're probably not too young for gray hair. I believe I've had some gray hair longer than I've had a university degree, and I was the youngest in my class.

Third: Exhale slowly.

Now, on to what you asked:

1) For us to provide you with specific help (and there's an excellent chance one or more of us will try), it's useful for you to provide specific information. For example, a link to the datasheet for the GPS unit might well lead to an answer. There are lots of different communications protocols that can be converted to RS232, but I'm not going to guess which one your GPS is using. On a related note, what did you use to do the conversion to RS232?

2) If all else fails, use an oscilloscope (or a signal analyzer, if that's handier) to watch the output of the GPS. That should tell you, at least, what the voltage and clock speed are.

3) There's no way to tell if you're using the correct input pin on the Arduino without seeing your code. There are lots of pins suitable for reading digital inputs, but different ones are set up (both in software and hardware) for different purposes. If a pin was specified in a sample sketch, what communications protocol does the GPS for which that sketch was written use?

Happy Hunting,
By n1ist
If the GPS is outputting TTL serial, and you are connecting it to the Arduino, you don't need an inversion. If both run on the same voltage (either 3.3V or 5V), just connect the serial out from the GPS to the serial in to the Arduino.

If you are trying to connect the TTL serial from the GPS to a PC or other true RS232 level device, just use a MAX232 or MAX3232 level shifter to do the conversion.

The inversion confusion comes from the fact that a 0 is 0V in TTL and +3 to +15V in RS232. A 1 is close to VCC (3.3 or 5V) in TTL, and -3 to -15V in RS232. The MAX232 or similiar takes care of all of the translations.

I would start by cutting the problem in half. Get a level shifter, and connect the GPS to your PC. This will let you see if it is working and configured correctly. You can then take the level shifter and connect it instead between the PC and Arduino to debug that side of the code.
By coms418
HI there all,
thanks for the replies,
the GPS is a ublox ANTARIS 4 GPS module model number of the unit I have is TIM-4H the standard speed on the nmea port is 9600 with heaps of strings IE:GGA, RMC,GSA,GSV,GLL,VTG,ZDA. if I put it on 4800 I only get 2 strings GGA, RMC I know a lot of data and heaps will not be used.
Datasheet for GPS ... 107%29.pdf

This unit takes 60 seconds from cold to full lock.
As I said earlier it is running at 9600 bps, I know the data is correct as I am capturing it on the PC, on the output of the gps I am getting just under 3 volts on the data signal, I have it running through a max232 for the pc, in fact just using it as an inverter TTL buffer.
So I know the levels and speed is correct looking at the demo code supplied with the tinygps library standard it uses pin 3 for the data from the GPS correct?
As I also said I an learning this micro and I have heap of project to build, two of which (not including this one) require GPS data

Just to prove to myself, I have tried the signal straight from the gps and the inverted, zero data is being shown on the serial terminal. only thing is the Waiting for GPS time ..., so at least I know the serial monitor works.

I have also tried a couple of other GPS units, a trimble ace3 unit , a generic gps, used it in my APRS tracker works perfect true rs 232 voltage output and the old handheld Magellan unit, All powered antennas mounted outside

Sorry to bore people but that is the setup at the moment, various test gear, HP CRo 54602b 4 Channel, and the normal test gear meters and so on.

Many Thanks for the people that are helping, means a lot.

NOW the demo code


* TimeGPS.pde
* example code illustrating time synced from a GPS

#include <Time.h>
#include <TinyGPS.h> //
#include <NewSoftSerial.h> //
// GPS and NewSoftSerial libraries are the work of Mikal Hart

TinyGPS gps;
NewSoftSerial serial_gps = NewSoftSerial(3, 2); // receive on pin 3

const int offset = 1; // offset hours from gps time (UTC)
time_t prevDisplay = 0; // when the digital clock was displayed

void setup()
Serial.println("Waiting for GPS time ... ");

void loop()
while (serial_gps.available())
gps.encode(; // process gps messages
if(timeStatus()!= timeNotSet)
if( now() != prevDisplay) //update the display only if the time has changed
prevDisplay = now();

void digitalClockDisplay(){
// digital clock display of the time
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");

void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
if(digits < 10)

time_t gpsTimeSync(){
// returns time if avail from gps, else returns 0
unsigned long fix_age = 0 ;
gps.get_datetime(NULL,NULL, &fix_age);
unsigned long time_since_last_fix;
if(fix_age < 1000)
return gpsTimeToArduinoTime(); // return time only if updated recently by gps
return 0;

time_t gpsTimeToArduinoTime(){
// returns time_t from gps date and time with the given offset hours
tmElements_t tm;
int year;
gps.crack_datetime(&year, &tm.Month, &tm.Day, &tm.Hour, &tm.Minute, &tm.Second, NULL, NULL);
tm.Year = year - 1970;
time_t time = makeTime(tm);
return time + (offset * SECS_PER_HOUR);
By fll-freak
Stupid question #1: Are you using this outdoors with a view of the satelites? "All" GPS units will not work deep inside a building. Some may work at a window. Some will work under a tree. "All" will work in a wide open area with a clear view of the sky.

At the frequency of the GPS, anything with water in it will kill the signal. I have a GPS repeater at work (yes it is legal; registered with the FAA, FCC, and Coast Guard) that did not work when it rained. The outside randome would get a thin film of water on it and poof, no more signal.

Some window glasses (especialy tinted car glass) will also kill the signal.
By coms418
yes the antenna is outdoors is a clear area, with a level converter on the gps so it can talk to the PC at 9600 bps I get data, standard GPS nema not SiRF.
Now I have tried all the GPS modules I have and they all work on the pc, BUT not on the stupid arduinos.
I have informed the club members that I am having major problems with building a simple clock, they are all amazed that the simple things in life are just not working, I have given demos/talks on GPS technology, APRS uses in the amateur radio world and many others, even built a heap of projects for them.
So you might say I have been involved in electronics for a good part of 30 plus years.

So currently I have put all the bits outlay and built for the project in a big box the display is big.
Now remember that the gps was / is important to this project and is even more important to the next two projects, of which if I can not get a simple gps signal to pass through the arduino to its serial port, I give up, may be its time to hang up the soldering iron, pack up the test gear, put the computer back in its box, and do what 90% of the world does and veg out in front of the TV becoming brain dead.

If some one wants to see if they can help a fellow electronics nut out please do so, as I am so close to the edge it is not a laughing matter anymore.

By fll-freak
Stupid question #2
Do you have a common ground?

Stupid question #3
Do you have the Rx and Tx signals set right? There is not a standard way on how that stuff gets labeled. Is it Rx from the point of view of the device it is printed on or the other device.

Stupid question #4
Since you have all these level converters, can you get the Arduino to send data to the PC?

Stupid question #5
An Arduino Duemilanove has a native serial port on pins 0 and 1. My experience is if you use these, they conflict with the USB uart and something must be disconnected. If my memory serves me, I had to disconnect my level shifter on pins 0/1 if I want to reprogram.
If you are using the software uart, then check what pins it is configured for.
By coms418
All is using a common ground, I would not be that stupid to forget basic electronics and electrical practices .

Because that output from the GPS is inverted as it normally would talk to a real computer via a max232 line level inverter, now the GPS' (more than one) all work to the PC that is, now I know the max232 output on 232 is +-10 volts I know that this is the reason why I have an 74HC04 schimitt-trigger inverters one of these is from the output of the gps via the 7404 to the stupid arduino the max 232 is to the pc to allow me to see if all is well.

Now because I am now all worked up over nothing I have used other peoples demo programs to make sure the cpu still works, I am getting text data via the usb serial port monitor so I would say that is working, just that nothing parses the gps info, as I keep stating very important to me.

I understand that the arduinos on the data/pwm pin 0,1 is the usb uart I full understand that, when using over peoples code the first thing I look for is the speed they are talking / receiving data from the GPS unit (i need 9600) so that gets changed and the next to do is the port (pins used changed if need) make sure they are not being used, now from what I have seen using the CRO when the serial ports are enabled the TX port gets held high via a resistor in the chip , I believe, and the receive is some where near OV in voltage.

Now I have four GPS antennas to choose from.
one is on a table is the back yard in the clear, and two different types are on the sheds roof, of which directly under that is my radio shack / electronics butchery place, well thats what it is like at the moment

I gave up on the ardunios on the weekend and just threw them against the wall in the pile of all the stuff I have bought for the clock project.

Surely someone out there has made a GPS locked clocked that uses 4 7 segment displays that are multiplexed.

to me it sounds like basic clock 101.

By trialex
Here's an example of using a GPS to run a clock using arduino ... 1246883781.

I'd start with a serial "pass through"-type sketch on the arduino. This is what the above link does - it has the GPS connected to a software-based serial port, and outputs the time on the hardware serial port. If you load that sketch, then hook it up like:

GPS --------> arduino (pins 8/9, anything but 0/1) ------> PC

Can you see the time output to the PC?

The datasheet for your GPS isn't the clearest in regards to the serial port output protocol - it doesn't seem to be true RS232 or TTL, or maybe I'm not reading it properly. Is that why you are using the inverter?

You could get a GPS module that is known to work well with the arduino, like the EM-406.
By coms418
I have been thinking of this all day and night , I need to at least see some thing working before the people in the white suits go to take me away.

NOW doe the tinygps libary read and understand nema 0183 which is my understanding the true GPS standard OR does it use SiRF.

All my GPS units output nema 0183, I have one if I reprogram it will output Sirf, but I really dont want to cut the cable this is the one I use in the car when I am mapping / GISing.

I dont feel like getting everybody upset as I all ready am, tried, frustrated, upset and now not sleeping as my brain is just not switching off at night its thinking about the project.

Even to the point that my biggest hobby has taken a dive because for the ardunio gear is in front of me remiding me every time I come out here.
I look forward to the answers people have, I am just hoping that its not based on Sirf.

cheers Paul
By coms418
Ok I have shoved the code into the IDe and complied it shoved it into the 1280 ardunio, gps wired up to the power pins and the output data from the gps is directly put to pin 9 on the PWM input.
GPS is outputing data happily the lock / second sync led if flashing, but still no one work of data out of the serial port.

I just do not understand it why not work?

Does this mean I have to buy one of those gps units from one of the online arduino sellers, I will be very upset if thats the case, brade new gps units and powered antennas going to waste.

Thats it I call it a night and going to stop banging my head against this wall and bench

cheers Paul
By n1ist
Once again, you do not need an inverter. Just connect the GPS directly to the Arduino. The GPS's TXD1 connects to pin used for the soft UART's receiver.

By coms418
My question is,
the tinygps library or even the nema one

Does it need to be in SiRF fromat or NEMA 0183 Format.

This is what I think is the problem, the library info does not talk about standards of what it expects to hear they just say gps, well there is a couple of apples that work like that.

Simple is it looking for Sirf or good old nema 0183............

Many Thanks people, I am way to tried and frustrated tonight in fact I am playing around with the moon tonight doing some EME


By trialex

Very few of the modules that typical hobbiests will be using with the arduino+tinyGPS libraries will use the Sirf protocol.