Parking Finder
The Parking Finder system is a smart parking solution designed to help drivers efficiently locate available
Loading...
Searching...
No Matches
gps-sensor-data.py File Reference

@breif Reads NMEA GPS sentences from a UART serial port and prints parsed fix data. More...

Go to the source code of this file.

Variables

 gps-sensor-data.ser
 @breif Open and configure the serial connection to the GPS module.
 gps-sensor-data.data = ser.readline().decode().strip()
 gps-sensor-data.msg = pynmea2.parse(data)

Detailed Description

@breif Reads NMEA GPS sentences from a UART serial port and prints parsed fix data.

Opens a serial connection to a GPS module wired to the jetson. Waits for GGA sentences, parses them with pynmea2 and prints timestamp, latitude, longitude, altitude, and satelite count.

Setupo

  1. Enable serial port on the jetson:
    sudo systemctl disable nvgetty
    sudo systemctl stop nvgetty
  2. Find which devide node the serial port maps to:
    ls -l /dev/serial0
    3. Install dependencies
    @code
    pip install pyserial pynmea2

Definition in file gps-sensor-data.py.

Variable Documentation

◆ data

gps-sensor-data.data = ser.readline().decode().strip()

Definition at line 53 of file gps-sensor-data.py.

◆ msg

gps-sensor-data.msg = pynmea2.parse(data)

Definition at line 58 of file gps-sensor-data.py.

◆ ser

gps-sensor-data.ser
Initial value:
1= serial.Serial(
2 port='/dev/ttyTHS1', # Adjust this for your specific setup
3 baudrate=9600,
4 parity=serial.PARITY_NONE,
5 stopbits=serial.STOPBITS_ONE,
6 bytesize=serial.EIGHTBITS,
7 timeout=1 # Timeout in seconds
8)

@breif Open and configure the serial connection to the GPS module.

Configure the serial port Replace '/dev/ttyS0' with the correct serial device name for your Pi (e.g., '/dev/ttyUSB0' for a USB-to-serial adapter) Ensure the baudrate matches the device you are communicating with.

Definition at line 35 of file gps-sensor-data.py.