Introduction: Raspberry Pi & the Neo 6M GPS

Picture of Raspberry Pi & the Neo 6M GPS

Previously I built a project where I connected a Neo-6M to an Arduino, but this time around, I wanted to show how to use a GPS with the Raspberry PI. Now there are several USB solutions, and apps that work with them, but I wanted to show how to use a $20 GPS module with a a serial UART, and Python code to decode the NMEA strings. Then you can write your own GPS interface, or combine the data with Google Maps.

Parts Needed:

Raspberry PI (any version)

Neo-6M GPS

Female to Female Jumpers

Raspberry Pi accessories like a >1a 5v power supply, SD Card, keyboard, mouse, and a HDMI monitor are needed for any RPI project.

Step 1: Electrical Connection

Picture of Electrical Connection

The first step is to connect the GPS module to the Raspberry PI. There are only 4 wires (F to F), so it's a simple connection.

Neo-6M RPI

VCC to Pin 1, which is 3.3v

TX to Pin 10, which is RX (GPIO15)

RX to Pin 8, Which is TX (GPIO14)

Gnd to Pin 6, which is Gnd

Step 2: Turn Off the Serial Console

By default, the Raspberry Pi uses the UART as a serial console. We need to turn off that functionality so that we can use the UART for our own application.

Open a terminal session on the Raspberry Pi.

The first thing we will do is backup the file cmdline.txt before we edit it.

sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt and press Enter.

The we need to edit cmdlint.txt and remove the serial interface.

Type in sudo nano /boot/cmdline.txt and press Enter.

Delete console=ttyAMA0,115200 and save the file by pressing Ctrl X, Y, and Enter.

Now type in sudo nano /etc/inittab and press enter.

Find ttyAMA0 by pressing Ctrl W and typing ttyAMA0 on the search line.

When it finds that line, press home, insert a # symbol to comment out that line, and Ctrl X, Y, Enter to save.

Type sudo reboot and press Enter to restart the Pi.

Step 3: Testing the GPS

Picture of Testing the GPS

Before we start writing our own code, let's test the GPS by using some off the shelf programs.

Open a terminal session and type sudo apt-get install gpsd gpsd-clients and press Enter.

After that installs, let's start the serial port:

Type stty -F /dev/ttyAMA0 9600 and press Enter.

Now start GPSD:

Type sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock and press Enter.

Now display by typing cgps -s and press Enter.

Step 4: Writing Your Own Python App

Now that I know the GPS module works, I want to write my own software, so that I can act on the values I'm reading. Coming Soon ......

Step 5: Using a Small LCD Display

For best results, a gps sensor needs to be outdoors. But I really don't want to drag my 42" HDMI monitor outside. I'll be adding a 2.8" LCD to this project soon!


LukeC45 (author)2017-09-22

hey everyone, having hard time to talk to neo-m8n (6m)

i have tried

Select Advanced Options -> Serial -> No (disable)
Then Advanced Options -> SPI -> Yes

then reboot

tried tty and Serial1 still no luck, running raspbian july 2017v

ManoelG3 (author)2017-06-02

Very good I'ble. Simple and objective, just one page. Thanks!

profeciak (author)2017-05-08

Have anyone had the problem that after sudo cat /dev/serial0 to see if the GPS is working just fine via the UART there is a list of proper data, and after some time suddenly it stops working and returns to the terminal?

rgrokett (author)2017-05-02

Just FYI for Raspian Jessie, to turn off the Serial Console and turn on the SPI interface, you can just use raspi-config:
$ sudo raspi-config
Select Advanced Options -> Serial -> No (disable)
Then Advanced Options -> SPI -> Yes (enable) & Yes again (load kernel module)
Select Finish and Reboot

You can now skip all of Step 2.
Check the port using:
$ sudo stty -F /dev/ttyAMA0
speed 9600 baud; line = 0;
-brkint -imaxbel

For further info, try the Adafruit tutorial

MartineH1 (author)2017-03-28

I have a problem finding ttyAMA0, I only had tty1, which I then deleted. But I could not find it when I was searching for it. And when trying to test the gps i wrote both tty -F/dev/ttyAMA0 9600, and tty -F/dev/tty1 9600, and non of them worked. Help?

tandjoeng (author)MartineH12017-04-24

i got same issue with you MartineH1

MartineH1 (author)tandjoeng2017-04-24

I found out that my serial port is called serial0, so you should try that. So try writing -F /dev/serial0 9600 instead.

tandjoeng (author)MartineH12017-04-25

thank you MartineH1,

now, i have a new problem. i can't find anything when i type "sudo nano /etc/inittab"

what should i do?

MartineH1 (author)tandjoeng2017-04-27

I don't think the inittab is in use anymore on the Raspberry Jessie. Which Raspi do you have? And what do you want to do?

tandjoeng (author)2017-04-24

i use pi 3 B. i cant find the ttyAMA0. what should i do Mr.sspence?

YohanesC3 (author)2017-04-11

Waiting for your step 4 & step 5 to be posted!

SunilRathodK (author)2016-04-06

Hi, I am not getting the data on the screen. After performing all the steps when i give command cgps -s i get the screen with no data in it. I am using raspberry pi 3. Also when i performed sudo nano /etc/inittab step i did not get any data in the file to comment. Please let me know if i am missing on anything. On a separate note I want to read this data and push to Azure IOT hub. I don't have any FTDI cable hence i was using this approach without FTDI cable. I appreciate your help in this regard too.


Sunil Rathod

kadeka4 (author)SunilRathodK2017-01-06

same with me

oguzdkn (author)SunilRathodK2016-04-16

please check this page. It works for me.. Raspberry pi 3 and Neo 6M GPS

DutchBrony. (author)SunilRathodK2016-04-15

Hi the Raspberry Pi 3 uses the ttyAMA0 for bluetooth, the ttyS0 is the UART port
i also had some trouble figuring that out for myself

sspence (author)SunilRathodK2016-04-07

There is no ftdi cable in this example. The GPS connects directly to the GPIO pins.

addieee (author)2016-12-02


I am working on the gps interfacing with the raspberyy pi. Can i ask for the python code for the gps?



DannielS1 (author)2016-11-30

para la raspberry pi 3 ya no usa el ttyAMA0 si no el ttyS0 este programa solo funciona en raspberry pi 2 y 1, en la 3 no... HELP!!!!

sspence (author)DannielS12016-12-01

Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth.

sudo nano /boot/config.txt
Add at the end of the file

Exit the editor saving your changes and then:

sudo reboot

student-diode (author)2016-08-07

what is the restore line for the backed up files ??

sspence (author)student-diode2016-08-09

What files?

student-diode (author)sspence2016-08-09

you backed up the file cmdline.txt before editing it how to restore the backed up file ?

sspence (author)student-diode2016-08-09

sudo cp /boot/cmdline_backup.txt /boot/cmdline.txt

student-diode (author)sspence2016-08-10

thank you!

David_Dragino (author)2016-06-19

hi all,there is a LoRa/GPS HAT,it applies to projects related to GPS, Lora, and RaspberryPi,you can find it here:,youcan also get the detailed tutorial here

RoudgeM (author)2016-04-07

@sspence sir, I have PM you about the error

SagarS60 (author)2016-04-07

As I Don't Know how to code in python. S, can I code in embedded c??

sspence (author)SagarS602016-04-07

You can use any language you want.

SagarS60 (author)sspence2016-04-07

Thank You

SagarS60 (author)sspence2016-04-07

Thank You

SagarS60 (author)sspence2016-04-07

Thank You

Brendan_Pi (author)2016-01-21

Sorry but ... I'm not in Jessie, so your post doesn't work for guys like me.

Maybe could you add something for us? (adafruit will help you ;-) ).

Soon you will discover a french similar article on pibot-maison!

Brendan_Pi (author)Brendan_Pi2016-01-21

*I am not in Wheezy

My version of RPi is Jessie.

sspence (author)Brendan_Pi2016-01-21

Shouldn't matter. What's the error?

Brendan_Pi (author)sspence2016-01-21

Jessie use systemd, so you have to disable tty like that :

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service

then type "sudo reboot"

Nanuxk (author)2015-12-11

Hi, I have some questions...

What version of Raspberry pi are you using?

And you know how to send the data (coordanations) for an database (MySql) ?

sspence (author)Nanuxk2015-12-12

I have a B+ and a pi2. here is a python to mysql reference.

I have not used it, as my experience is with php/mysql.

Nicolas Magne Tang (author)2015-12-09


Hesham_Gaber (author)2015-09-14

i tried to find a way to operate the gps with a python code, instead of the terminal script to open the application.
so if you have the python code, send it to me

Hesham_Gaber made it! (author)2015-09-09

It works very well but i noticed that the gps has to wait about 2~5 minutes to collect the desired data from the surrounding satellites.

sspence (author)Hesham_Gaber2015-09-09

Some units are slower / faster than others, and it can depend on how many satellites are visible. Slower to connect indoors with few windows.

sspence (author)2015-07-30

I would love to hear from others that have done this, or similar projects. Post your links.

About This Instructable




Bio: Professionally, I'm an IT Engineer (Executive Level) and Electronics Tech. I'm a Amateur Radio Operator (KK4HFJ). I lived off grid, with Solar (PV ... More »
More by sspence:DIY I2C LCD Display with InputsRaspberry Pi & the Neo 6M GPSEarthquake / Vibration Sensor
Add instructable to: