← Retour au blog
tech 4 May 2026

Broadcasting GPS Data on the Local Network

Learn how to broadcast GPS data over your local network to enhance location accuracy on Linux, using protocols like NMEA 0183 and tools such as Avahi.

Introduction

The accuracy of location services on Linux often leaves much to be desired, especially after Mozilla discontinued its GPS location service. If you're a Linux user, you've likely noticed that services like Firefox and Gnome Maps rely on Geoclue, which by default uses a GeoIP database. The problem? A mere 25 km accuracy. But there is a solution: broadcasting GPS data over your local network.

Why Broadcast GPS Data Locally?

Broadcasting GPS data on the local network can be an effective workaround to the limitations of GeoIP-based location services. For servers or fixed devices, emitting stable GPS coordinates can significantly enhance location accuracy. This can be crucial for applications that depend on precise location data.

The NMEA 0183 Protocol

The NMEA 0183 protocol is a set of specifications primarily used in marine electronics. It allows for the transmission of GPS information via a serial port or a TCP socket. For example, an NMEA message might look like this:

`` $GPRMC,204049.000,A,5308.3999,N,00601.9266,E,0.000,0.000,030526,,02 $GPGGA,204049.000,5308.3999,N,00601.9266,E,1,08,1.0,119.0,M,0.0,M,,6F ``

These messages contain data on GPS coordinates, altitude, and other relevant information.

Configuring GeoClue

GeoClue, the system responsible for location on Linux, supports the NMEA protocol by default. To enable this feature, simply modify the configuration file /etc/geoclue/geoclue.conf as follows:

`` # Network NMEA source configuration options [network-nmea] # Fetch location from NMEA sources on local network? enable=true ``

This configuration allows GeoClue to search for NMEA services on the local network via MDNS.

Setting Up a Local GPS Server

Creating a server that broadcasts these GPS data is relatively straightforward. You can use Python to write a small TCP server that emits the GPS information at regular intervals. Here’s an example script you could use:

```python import socket import time

HOST = '' # Host IP address PORT = 10110 # Port used by the NMEA service

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() conn, addr = s.accept() with conn: print('Connected by', addr) while True: conn.sendall(b'$GPRMC,204049.000,A,5308.3999,N,00601.9266,E,0.000,0.000,030526,,*02\n') time.sleep(1) ```

Using Avahi for Service Discovery

To allow GeoClue to discover your GPS service, you can use Avahi, a standard MDNS implementation on Linux. Here’s an example Avahi configuration:

``xml <?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">NMEA GPS (%h)</name> <service> <type>_nmea-0183._tcp</type> <port>10110</port> </service> </service-group> ``

Copy this file to /etc/avahi/services/ and restart the Avahi service to have the server discovered on the local network.

Conclusion

Broadcasting GPS data locally is an ingenious solution to enhance location accuracy on Linux, especially when alternative location services are limited. By using protocols like NMEA 0183 and tools like Avahi, you can create a reliable and precise location system tailored to your specific needs.

Let's discuss your project in 15 minutes.

GPS NMEA 0183 Local Network GeoClue Avahi

Tu veux automatiser tes opérations ?

Discutons de ton projet en 15 minutes.

Réserver un call