Read GPS Data

This section describes how to use VisionFive 2 or VisionFive 2 Lite's UART to read GPS data through an example program with Python.

Hardware Setup

Connect NEO-6M GPS to the 40-pin header of VisionFive 2 or VisionFive 2 Lite as follows.

Figure 1. Connect NEO-6M GPS to 40-Pin GPIO Header
s
NEO-6M 40-Pin GPIO Header
Pin Number Pin Name
VCC 4 5V Power
GND 6 GND
TXD 10 GPIO6 (UART RX)
RXD 8 GPIO5 (UART TX)

Run Demo Code

Perform the following steps on Debian of VisionFive 2 or VisionFive 2 Lite.

  1. Locate the directory where the test code, uart_gps_demo.py, exists.

    1. Source into the PYthon3 Virtual Environment.
      source ./myvenv/bin/activate
    2. Install the dependency.
      python3 -m pip install pillow
    3. Get the directory where VisionFive.gpio exists.

      python3 -m pip show VisionFive.gpio
      Note: The output depends on how the application is installed.
    4. Enter the VisionFive.gpio directory.

      cd <VisionFive.gpio directory>
    5. Enter the sample-code directory.

      cd ./VisionFive/sample-code/
  2. Execute the following before running the demo code:
    sudo systemctl stop serial-getty@ttyS0.service
  3. Under the sample-code directory, execute the following command to run the demo code.

    sudo python uart_gps_demo.py
    Alternatively, you can also run the following command.
    sudo python3 uart_gps_demo.py
    If the GPS signal is weak, the terminal output is like the following:
    *****The GGA info is as follows: *****
     msg_id: $GPGGA
     NorS:
     EorW:
     pos_indi: 0
     total_Satellite: 00
    
    !!!!!!Positioning is invalid!!!!!!
    
    If the GPS signal is strong, the terminal output is like the following, generated in a few seconds:
    *****The GGA info is as follows: *****
     msg_id: $GPGGA
     utc time: 2:54:47.0
     utc time: 025447.00 (format: hhmmss.sss)
     latitude: 30 degree 33.29251 minute
     latitude: 3033.29251 (format: dddmm.mmmmm)
     NorS: N
     longitude: 104 degree 3.45523 minute
     longitude: 10403.45523 (format: dddmm.mmmmm)
     EorW: E
     pos_indi: 1
     total_Satellite: 08
    
    *****The positioning type is 3D *****
    The Satellite ID of channel {} : {}
                               ch1 : 14
                               ch2 : 01
                               ch3 : 03
                               ch4 : 06
                               ch5 : 30
                               ch6 : 21
                               ch7 : 19
                               ch8 : 17
    
    Note: For details about the source code, see uart_gps_demo.py Source Code.
  4. (Optional) Exit the Python3 Virtual Environment.

    deactivate