This is a library that was written to work with any serial enabled gps module. I only had an option to test the Neo 8 gps, but it should work with any NMEA compliant device. It was written for a series of serial enabled extension boards available from Aliexpress.
Please leave a star if you end up using this library. It means a lot to me. ⭐
Tested hardware:
- Ublox Neo M8N. I tested this one
Probably working hardware:
All serial and Nmea compliant GPS modules
- Probably all Ublox series gps
- Contact me if you find that your device works
go get github.com/LanVukusic/RaspiGPS
Pins on the raspberry are labeled according to the diagram below, referenced with numbers from 1 to 40
- PIN 8 serial TX (gpio15) - gps RX
- PIN 10 serial RX (gpio14) - gps TX
- go serial library - github.com/jacobsa/go-serial
Here is a sample code which connects and recieves data from a gps module.
package main
import (
"fmt"
"time"
"github.com/LanVukusic/RaspiGPS/gps"
)
var a gps.Neo8
func main() {
// replace "/dev/serial0" with the serial interface you are using
a.Init("/dev/serial0")
for {
time.Sleep(1 * time.Second)
fmt.Printf("Position: %g %s, %g %s with %d satelites\n", a.Lat, a.NS, a.Lng, a.WE, a.SatTracking)
}
}
Following functions are available:
Name | DataType | Description |
---|---|---|
Lat | float64 | Latitude |
NS | string | North / South part of latitude |
Lng | float64 | Longitude |
WE | string | West / East part of Longitude |
Fix | uint64 | GPS fix type; described below |
SatTracking | uint64 | Number of satellites used in tracking |
SatInView | uint64 | Number of satellites in view |
Hdop | float64 | Horizontal dilution of precision aka accuracy on land.[meters] |
Alti | float64 | Altitude above sea level [meters] |
TrueTrack | float64 | Heading track [degrees azimuth] |
GroundSpeedKmh | float64 | Speed above ground in [Km/h] |
SNR | float64 | Signal to noise ratio |
GPS fix types: 0 = invalid 1 = GPS fix (SPS) 2 = DGPS fix 3 = PPS fix 4 = Real Time Kinematic 5 = Float RTK 6 = estimated (dead reckoning) (2.3 feature) 7 = Manual input mode 8 = Simulation mode