The Adafruit Ultimate GPS HAT is an add-on for the Raspberry Pi that provides high-quality GPS functionality. It is designed to make GPS projects with the Raspberry Pi easy and straightforward. With its high-sensitivity receiver and built-in antenna, it is capable of providing precise positioning, speed, and time data. This GPS module is ideal for a wide range of applications, including but not limited to, geocaching, vehicle tracking, and time synchronization.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (3.3V input) |
2 | RX | UART Receive pin |
3 | TX | UART Transmit pin |
4 | GND | Ground connection |
5 | PPS | Pulse Per Second output |
6 | EN | Enable pin for GPS module |
Q: Can I use the GPS HAT indoors?
Q: What is the battery for?
Q: How do I change the baud rate?
Below is a simple Python script to read data from the Adafruit Ultimate GPS HAT using the Raspberry Pi. This script assumes that you have already configured the UART on the Raspberry Pi and installed the necessary Python libraries.
import serial
import time
ser = serial.Serial('/dev/serial0', 9600, timeout=1)
def read_gps_data(): try: while True: data = ser.readline().decode('ascii', errors='replace') if data.startswith('$GPGGA'): # GPGGA sentence contains position data print(data) time.sleep(0.1) except KeyboardInterrupt: ser.close() # Close serial port when done
read_gps_data()
Remember to install the `pyserial` library if you haven't already, using the following command:
```shell
pip install pyserial
This script continuously reads data from the GPS module and prints out the GPGGA sentences, which contain the position information. You can parse these sentences to extract the latitude, longitude, and other relevant data for your application.