Ublox NEO-6 GPS feeding an Arduino MEGA 2560 to display Latitude & Longitude on an LCD screen

The Ublox NEO-6 board cost about £5 with its antenna, including delivery. This feeds an Arduino MEGA 2560 with a 1602/HD44780 LCD Screen-Keypad Shield (for MEGA). I didn’t actually use the keypad buttons, but they are easy to program in. You might use one to flip between Lat/Long and Maidenhead Locator, for instance.

I fed about 4V, smoothed a bit, into the Vcc (+) and Gnd (-) on the NEO-6 card and 12V into the Arduino (when not powered via the USB cable from the PC).

The serial data came from the Tx pin on the NEO-6 and fed the pin 19 (Tx again!) on the Arduino board. (I did think Tx on the NEO-6 should feed Rx on the Arduino board, but that didn’t work). The NEO-6 drew about 70mA typically, but the current varied a lot.

The wiring diagram is simple. I used a 5V regulator on the project breadboard to power the NEO-6. The regulator got a bit hot, so I put a heatsink on it.



The ‘o’ in the top RH corner of the display indicates that the program has initialised and entered the main loop. The ‘s’ in the bottom RH corner indicates that the serial telemetry from the GPS card is being received (the white wire in the picture above). A flashing red LED on the NEO-6 card indicates satellites have been detected. When the lat/long display updates, then the NEO-6 has found a position.

I used float type variables lat and lon to hold the latitude and longitude floating point numbers. These seemed to hold 6 significant digits reliably. I used the dtostrf() function to format the numbers for display.

My lab/shack is well screened with sheets of insulation covered in aluminium foil, so GPS satellite signals are very weak. My Garmin Etrex GPS could see no satellites at all. The NEO-6 (with its separate little patch antenna plugged in) not only found satellites (a red LED on the board flashed), it also locked on to give a position. So the NEO-6 has a useful sensitivity. The little coax antenna socket has 3.3V on it, so I’m guessing the little patch antenna is active, not passive.

I compared the Etrex readings with the NEO-6 readings for the same position. They agreed up to the third decimal place (of degrees). I took the maximum and minimum readings over about an hour. Here are the differences between maximums and minimums:

    Etrex                    NEO-6

Lat:       0.00006                0.00014

Long:    0.00040                0.00025

So the Etrex varied less on latitude and the NEO-6 varied less on longitude, as different satellites dropped in and out.

I found that when I switched the IDE to Due that the program would not compile as the  dtostrf() function was missing. I’ll try to re-write the program in order to avoid dtostrf(). There seems to be some inconsistency between the libraries for the different types of Arduino.

Program below (supplied as is, no liability):

// GPS_NEO6_position_read-out_V3 (c) GJ Coyne G3YJR
#include <LiquidCrystal.h>
#include <TinyGPS.h>

float lat = 54.123456, lon = -2.123456; // declare variables for lat and long
static char lat_ch[13], lon_ch[13];

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);         // Set LCD interface pins

TinyGPS gps;                                            // declare gps object

void setup(){

Serial.begin(9600);              // connect Serial0 for PC comms

lcd.begin(16, 2);                    // initialise LCD screen
lcd.clear();                              // clear the LCD screen

Serial1.begin(9600);            // connect gps input on pin 19, Serial1

dtostrf(lat,10,5,lat_ch);       // lat_ch 10 chars, 5 after decimal point
dtostrf(lon,10,5,lon_ch);     // lon_ch 10 chars, 5 after decimal point

lcd.setCursor(0,0);               // col 0, row 0 (top row)
lcd.print(“LAT “);
lcd.setCursor(3,0);               // col 3, row 0 (top row)

lcd.setCursor(0,1);               // col 0, row 1 (bottom row)
lcd.print(“LON “);
lcd.setCursor(3,1);               // col 3, row 1 (bottom row)


void loop()

lcd.setCursor(15,0); lcd.print(“o”);   // ‘o’ in top rh corner for ‘On’
lcd.setCursor(15,1); lcd.print(” “);    // clear serial i/p received field
while(Serial1.available())     // check gps serial i/p data on pin 19, Serial1

// lower-case ‘s’ in top rh corner for Serial o/p received
lcd.setCursor(15,1); lcd.print(“s”);

if(gps.encode(Serial1.read()))     // fetch gps data


gps.f_get_position(&lat,&lon); // fetch latitude and longitude

dtostrf(lat,10,5,lat_ch);             // lat_ch 10 chars, 5 after decimal point
dtostrf(lon,10,5,lon_ch);          // lon_ch 10 chars, 5 after decimal point

lcd.setCursor(0,0);                    // col 0, row 0 (top row)
lcd.print(“LAT “);
lcd.setCursor(3,0);                    // col 3, row 0 (top row)

lcd.setCursor(0,1);                   // col 0, row 1 (bottom row)
lcd.print(“LON “);
lcd.setCursor(3,1);                   // col 3, row 1 (bottom row)





4 thoughts on “Ublox NEO-6 GPS feeding an Arduino MEGA 2560 to display Latitude & Longitude on an LCD screen

  1. Thanks Graham. I’ve been playing with Microchip PIC devices on stand alone boards for years now with a whole range of projects under my belt… but I’ve never got round to exploring an Arduino based product (yep, they use the same Microchip PIC’s – but they are wrapped inside a more nuanced IDE and a wide range of open source library code).

    I spotted your post in my email client this morning and for some reason it gave me a kick to start exploring. I’ve just bought my first MEGA2560 board and an LCD display panel and will explore starting with nothing more than a hello world flashing LED. We’ll go from there.

    The boards are cheap and the libraries are pretty good from what I hear.

    Thanks again

    Ciaran – G8ZSN


    • Ciaran, you caught this blog article while it was still a draft (yesterday’s!), so I intend add a photo, a diagram and the program.
      It should be easy to add a Maidenhead Locator calculator to the GPS code.

      It sounds like you have done more PIC programming than me. I intend to do a more advanced Arduino based project later and the GPS project has been a warm-up, rediscovering the IDE and familiarising myself. Yes, the boards are good value. I’ll try the Due board next. Barry G8AGN has suggested the Due to me for improved calculation accuracy.

      I hope you have fun with the Arduinos.

      73 Graham


      • I think I will have fun Graham and thanks for responding

        Separately I’m not sure if you spotted an original post of mine a few months ago, regarding the fix to your boiler timer (capacitor dropper PSU). I’d had exactly the same problem, diagnosed and fixed the cause the same way only to spot a day or so later you’d resolved the same problem. I posted a kind of introduction / thank you at that time. Quite a few folks say hi as a result (after they read my blog on my site conehead.org)

        Yes I’ve been using PIC’s for years now, combinations of the old 8 bit, 16 bit and the lions share using PIC32MX families. I used 80Mhz (12.5nS cycle time) parts and so for sampling and timing events they’re not too bad. The Mega is much slower at 16Mhz, but still more than fast enough for a lot of real world applications. I’m quite looking forward to seeing the IDE, because although I’ve used the Microchip IDE for all my development, it is a bit basic and has all sorts of gotchas for the unwary. I’m guessing Arduino will be somewhat more refined.

        Anyway – keep well, and keep your distance




      • Yes thanks for your earlier reply regarding the Honewell. Great minds…! It looks like my reply didn’t take. I don’t get on to 40m much, but I try to get a few points for the Sheffield & District Wireless Society in 40m CW contests occasionally.
        Yes, I’ve used Microchip IDE. I run the Arduino IDE on Ubuntu Linux. It sometimes loses the USB port to the Arduino, but seems fairly well behaved.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s