Raspberry Pi & the Neo 6M GPS

146,026

90

50

Introduction: Raspberry Pi & the Neo 6M GPS

About: 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), Wind, and veggie oil fueled diesel generator power for 6 yea…

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

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

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!

2 People Made This Project!

Recommendations

  • STEM Contest

    STEM Contest
  • Role Playing Game Challenge

    Role Playing Game Challenge
  • CNC Contest

    CNC Contest

50 Comments

0
Nico10101
Nico10101

Question 7 months ago

Hello I have a Problem here I have followed the tutorial and almost everything works fine. The Problem the GPS Modul gets a fix but if I run the code the Fix is gone and the output is: "Latitude:0.0 Longitude:0.0". Does anyone have the same Problem, or have any knowledge how to fix this?

0
jeremiahlandi
jeremiahlandi

Question 9 months ago on Step 4

0
sspence
sspence

Answer 9 months ago

Thank you for those links. I never got back to this project, and don't have any plans on doing so in the near future.

0
AlfredI2
AlfredI2

Question 1 year ago on Step 1

will bluetooth still work if we do this?

0
Adithya Pro
Adithya Pro

Question 2 years ago on Step 4

Please tell me how to write the data into excel sheet

0
AndreasD28
AndreasD28

3 years ago

In JESSY and STRETCH I had to:

sudo nano /etc/default/gpsd

USBAUTO="false"

DEVICES="/dev/serial0"

fabiotnt already mentioned this in his reply to DannielS1

0
LukeC45
LukeC45

3 years ago

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

0
fabiotnt
fabiotnt

Reply 3 years ago

Try to use ttyS0
To check ttySO communication:

To check baud rate

stty -F /dev/ttyS0

Then to check communication:

cat /dev/ttyS0
0
DannielS1
DannielS1

4 years ago

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!!!!

0
fabiotnt
fabiotnt

Reply 3 years ago

Tiene que cambiar lo dispositivo en cgsp config.
nano /etc/default/gpsd

cambie ttyAMA0 por ttyS0

0
sspence
sspence

Reply 4 years ago

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

dtoverlay=pi3-miniuart-bt
Exit the editor saving your changes and then:

sudo reboot

0
ManoelG3
ManoelG3

3 years ago

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

0
profeciak
profeciak

3 years ago

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?

2
rgrokett
rgrokett

3 years ago

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
https://learn.adafruit.com/adafruit-ultimate-gps-hat-for-raspberry-pi/use-gpsd

0
MartineH1
MartineH1

4 years ago

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?

0
tandjoeng
tandjoeng

Reply 3 years ago

i got same issue with you MartineH1

0
MartineH1
MartineH1

Reply 3 years ago

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

0
tandjoeng
tandjoeng

Reply 3 years ago

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?