Add a GPS Module to Raspberry Pi

raspberry pi gps module

A raspberry pi gps module that shows no data is usually a wiring, serial-port or sky-view problem. Cross TX and RX, enable the UART, point the antenna at open sky, then read positions through gpsd.

The module talks over the Pi’s serial port, so it needs port setup that other sensor builds skip. It sits alongside the other raspberry pi gpio projects, and the sections below follow the order in which things usually go wrong.

Wiring the module without damaging the Pi

Connect VCC to a 3.3V pin, GND to ground, and cross the data lines. The GPS TX wire goes to the Pi’s receive pin and the GPS RX wire goes to the Pi’s transmit pin, as a Raspberry Pi GPS logger project describes. On the Pi, the UART pins are GPIO14 for TX and GPIO15 for RX, according to a NEO-6M integration guide that uses a Pi Zero 2 W wiring table. So GPS TX lands on GPIO15 and GPS RX lands on GPIO14.

The u-blox NEO-6M uses 3.3V TTL logic, and the same guide warns that connecting 5V will damage the Pi’s GPIO. If your breakout board advertises a 5V supply input, check its documentation before wiring it, because the Pi’s header pins are not 5V tolerant.

A small converter board with a voltage readout, the kind of part used to step a battery down to a steady supply for a Pi.
  • Power: use the 3.3V pin for VCC. The module is listed at 37mA at 3.3V continuous, a load that matters later if you run from a battery.
  • Data lines: if nothing arrives later, swap the two data wires first. It is the cheapest fix and the most common slip.
  • Antenna position: mount the module with its ceramic patch facing the sky, and keep the wires short enough that the board can sit near a window or outdoors.
Generic board hardware for illustration. Find the GPIO header on your own Pi before you connect VCC, GND, TX and RX.

Freeing the serial port from the login console

The Pi must expose its UART as a plain serial device and stop using it for a login shell. Run raspi-config, open the interface options and choose No for login shell access over serial. Then choose Yes for the serial hardware, as the NEO-6M integration guide describes.

The same guide then adds enable_uart=1 and dtoverlay=disable-bt to /boot/config.txt and reboots. The disable-bt overlay turns Bluetooth off and frees the UART for exclusive GPS use. That is a real trade-off: if the project needs Bluetooth on the same Pi, this route removes it.

After the reboot, the guide gives the default serial device on a Pi Zero 2 W as /dev/ttyS0, the mini-UART. Other Pi models may name the device differently, so confirm which serial device your board exposes before editing the gpsd settings.

Getting gpsd to read the module

gpsd sits between the serial port and your programs, so several tools can share one GPS. Install it with sudo apt install gpsd gpsd-clients, which also brings in the client tools.

Next, edit /etc/default/gpsd. The guide sets DEVICES=”/dev/ttyS0″, BAUD=9600 and GPSD_OPTIONS=”-n”. The 9600 value matches the NEO-6M’s default baud rate, so change it only if you have reconfigured the module. The -n flag enables polling mode, which queries the GPS without waiting for client connections. That suits a logger that should start collecting before any program asks for data.

Restart gpsd after saving, then check it visually with cgps -s. That client is the quickest test of the whole chain, because it shows whether gpsd sees the module at all before you write any code.

  • Choose gpsd over reading the port directly when more than one program needs positions, or when you want a Python client such as gpsd-py3 (sudo pip3 install gpsd-py3).
  • Read the port directly only for a one-off check of raw sentences, where gpsd adds nothing.

What the NMEA output looks like

The NEO-6M outputs standard NMEA 0183 sentences at 9600 baud. Each line is plain text that begins with a dollar sign and a sentence name. The integration guide lists GGA, GLL, GSA, GSV, RMC and VTG as the key types.

$GPRMC is the recommended minimum sentence. It carries time, status, latitude, longitude, speed and course, which makes it the one to look for when you only want a position. If you see these lines scrolling past, the wiring and port are correct and any remaining trouble is about satellites.

gpsd decodes these sentences for you. In its output, mode 3 is a 3D fix, mode 2 is a 2D fix and mode 1 is no fix. Treat anything below mode 2 as a position you should not trust or log.

Diagnosing no data and no fix

Work from the cable inwards. First confirm sentences are arriving, then confirm a fix. Indoor failures are common because the module requires clear sky visibility for satellite reception.

Symptom Likely cause Planning use
cgps shows nothing at all GPS TX and RX not crossed, or the wrong device in /etc/default/gpsd Swap the data wires, then check DEVICES is /dev/ttyS0 on a Pi Zero 2 W
Serial port busy or unavailable Login shell still on serial, or Bluetooth still holding the UART Answer No to the serial login shell and add dtoverlay=disable-bt
Data arrives but mode is 1 No satellite fix yet Move to open sky, patch facing up, and allow 30-60 seconds
Data stops or looks wrong after a settings change Baud differs from the module’s 9600 default Set BAUD=9600 unless you reconfigured the module

Wiring and settings come from the NEO-6M integration guide, and the crossover rule from the Raspberry Pi GPS logger project.

Why an indoor fix often fails

The guide advises allowing 30-60 seconds for a cold-start acquisition, and lists a typical cold time to first fix of under 27 seconds on the module itself. Plan for the longer window before you conclude anything is broken. A module with a built-in patch antenna on top can still receive data indoors, as Electronics For You notes. Even so, a windowsill or outdoor spot remains the dependable test, because the requirement is clear sky.

Logging positions to a file

Decide what you want in the file before choosing a method. Raw sentences keep everything, while a position per line is easier to read and plot.

Raw NMEA or GPX files

One open-source logger records raw NMEA frames from a GPS receiver. It depends on Python 2.7 and python-serial, so it reads as an older design. For a current setup, the gpsd route above avoids that dependency. Another project, raspi-gps, records routes as GPX files on the SD card and uses an external GPS Bluetooth module. It shows that file-based tracking works without a network connection.

A protective case suits a field logger. Leave room for the antenna to face the sky once the lid is open.

A simple Python logger through gpsd

The gpsd-py3 library gives you a current packet with packet = gpsd.get_current(). A short script connects once, then loops. Each pass reads a packet, skips it if the mode is below 2, and otherwise appends a timestamp, latitude and longitude as one line. Open the file in append mode and flush after each write, so a sudden power loss costs at most the last line.

Once the port is free, the module streams latitude and longitude. This globe is an illustration of what those coordinates describe.

Filtering on mode matters more than it looks. Without it, the file fills with empty or stale entries during the wait for a first fix. If you also want to capture other readings alongside position, the mpu6050 raspberry pi guide covers motion data, and the sound sensor raspberry pi guide covers audio input.

Running the logger on a battery

A portable build needs a regulated supply for the Pi, and the GPS module’s own draw is modest at 37mA at 3.3V. Start the logger automatically at boot, since you will not have a keyboard in the field. Test the whole unit outdoors for a full cold-start window before relying on it for a trip.

Frequently asked questions

Question Answer
How accurate is the NEO-6M? A NEO-6M integration guide lists the u-blox 6 chip with 50 channels and 2.5 m accuracy. Real results depend on how much sky the antenna sees.
Can I use a Bluetooth GPS module instead of a wired one? Yes. The raspi-gps project uses an external GPS Bluetooth module with a Pi. That route leaves the UART alone, so you can skip the Bluetooth-disabling overlay.
How do I turn a raw NMEA log into a GPX file? Use gpsbabel with the command gpsbabel -i nmea -f file-in.nmea -o gpx -F file-out.gpx, as shown in the GPS logger project.