A user-friendly, cross-platform Python script to connect to, stream, and log data from u-blox GPS modules. This tool is designed to work with various connection types, including built-in modules (e.g., in Dell Laptops) and external USB-to-UART devices (e.g., u-blox M8N, Radiolink SE100).
- Simple Menu Interface: An interactive command-line menu for easy connection setup.
- Device Presets: Pre-configured settings for common devices and a custom option for flexibility.
- Live Data Streaming: Displays real-time GPS information (coordinates, status, altitude, speed, etc.) directly in your console.
- Organized Data Logging: Automatically saves different data streams into separate, timestamped text files for easy analysis.
- Cross-Platform: Works on Windows, macOS, and Linux.
- Lightweight: Depends only on pyserialandpynmea2.
- Python 3.x
- pyseriallibrary
- pynmea2library
- 
Clone or download the repository: git clone <your-repo-url> cd <your-repo-directory> 
- 
Install the required Python libraries using pip: pip install pyserial pynmea2 
- 
Connect Your GPS Device: - USB Devices (M8N, SE100, etc.): Plug the device into a USB port. Your operating system should automatically assign it a serial (COM) port.
- Built-in Devices (Dell Latitude): Ensure the GPS/GNSS device is enabled in your system's BIOS/UEFI settings and that the necessary drivers are installed.
 
- 
Find the Serial Port Name: - Windows: Open Device Manager, look under "Ports (COM & LPT)". Your device will be listed as COMfollowed by a number (e.g.,COM3).
- Linux: The device will likely appear as /dev/ttyUSB0or/dev/ttyACM0. You can rundmesg | grep ttyafter plugging in the device to see the assigned name.
- macOS: The device will likely appear as /dev/cu.usbserial-XXXX. You can list available ports withls /dev/cu.*.
 
- Windows: Open Device Manager, look under "Ports (COM & LPT)". Your device will be listed as 
- 
Run the Script: - Open your terminal or command prompt and navigate to the directory containing the script.
- Execute the script using Python:
python ublox_gps_tool.py 
 
- 
Follow the Menu: - The script will prompt you to select a connection type. Enter the number corresponding to your setup.
- If prompted, enter the serial port name you identified in the previous step.
 
- 
Stop the Script: - To stop the data stream and exit the program, press Ctrl+C. The script will safely close the serial port and terminate.
 
- To stop the data stream and exit the program, press 
Once connected, your terminal will display a continuously updating screen with the latest GPS data:
\--- u-blox GPS Live Data Stream ---
Press Ctrl+C to stop.
## Timestamp:     2025-09-22 20:12:07 UTC Status:          GPS Fix
## Latitude:        43.3095° Longitude:       -73.6427° Altitude:        102.1 meters
Satellites Used: 8
HDOP:            1.1
Speed (knots):   0.50
Course (true):   125.0°
Logging data to 'gps\_logs' directory.
```
### Log Files
The script will create a `gps_logs` directory and populate it with the following files:
**`latitude_longitude.txt`**
```
2025-09-22T20:12:07.123456+00:00, Latitude: 43.309510, Longitude: -73.642700
2025-09-22T20:12:08.123456+00:00, Latitude: 43.309512, Longitude: -73.642702
```
**`gps_status.txt`**
```
2025-09-22T20:12:07.123456+00:00, Status: GPS Fix, Satellites: 8, HDOP: 1.1
2025-09-22T20:12:08.123456+00:00, Status: GPS Fix, Satellites: 8, HDOP: 1.1
```
**`altitude.txt`**
```
2025-09-22T20:12:07.123456+00:00, Altitude: 102.1 meters
2025-09-22T20:12:08.123456+00:00, Altitude: 102.2 meters
```
**`raw_nmea.txt`**
```
2025-09-22T20:12:07.123456+00:00: $GPGGA,201207.00,4318.5706,N,07338.5620,W,1,08,1.1,102.1,M,-34.2,M,,*5C
2025-09-22T20:12:07.123456+00:00: $GPRMC,201207.00,A,4318.5706,N,07338.5620,W,0.5,125.0,220925,,,A*7B
```
## Troubleshooting
-   **"Error: Could not open port..."**:
    -   Verify that you have selected the correct port name.
    -   Ensure the GPS device is powered on and securely connected.
    -   On Linux/macOS, you may need permissions to access the port. Add your user to the `dialout` group: `sudo usermod -a -G dialout $USER`. Log out and back in for the change to take effect.
    -   Confirm that no other application (e.g., u-blox u-center, Arduino IDE) is currently using the same port.
-   **No Data is Displayed ("Waiting for GPS data..."):**
    -   Your GPS may be using a different baud rate. Try the "Custom Connection" option with other common rates like 4800, 38400, or 115200.
    -   The GPS receiver needs a clear view of the sky to get a satellite fix. If you are indoors, it may not be able to acquire a signal. The `Status` will change from "No Fix" to "GPS Fix" once it has a lock.
```