This Rust project is designed to read data from a USB GPS dongle in NMEA-0183 format over serial, parse the data, and publish relevant information to an MQTT broker. Please note that this implementation is not complete, and it has only been tested with a specific USB dongle. There is no guarantee that it will work with different devices.
- Reads GPS data from a USB dongle in NMEA-0183 format.
- Parses relevant sentences and dispatches them to specialized functions.
- Publishes parsed information to MQTT topics.
This project has been tested with a specific USB dongle (TOPGNSS GN800G with M8030-KT chipset). Compatibility with other devices is not guaranteed.
There is a toggle that switches the dongle to 10Hz mode, which might be dangerous on other devices. Use this feature at your own risk. Binary commands with u-blox undocumented commands are pushed to the device for this operation.
The main parsing logic is contained in the gps_data_parser
module, specifically in the process_gps_data
function. This function takes a slice of bytes representing received data, converts it to a string, and dispatches the relevant sentences to specialized parsing functions.
To build the project, follow these steps:
-
Ensure you have Rust installed on your system. If not, you can install it from https://www.rust-lang.org/tools/install.
-
Clone the repository:
git clone https://github.com/your-username/gps-to-mqtt.git
-
Change into the project directory:
cd gps-to-mqtt
-
Create an
example.settings.toml
file in the same directory as the executable. Refer toexample.settings.toml
for configuration options. -
Build the project:
cargo build --release
-
Run the executable:
./target/release/gps-to-mqtt
Copy and modify the example.settings.toml
file to configure the project. Ensure that this file is in the same directory as the executable.
- serialport - 4.3.0
- config - 0.13.4
- paho-mqtt - 0.12.3
- futures - 0.3.30
- lazy_static - 1.4.0
src/config.rs
: Module for loading project configuration.src/gps_data_parser.rs
: Module containing the main logic for parsing GPS data.src/mqtt_handler.rs
: Module for setting up MQTT and publishing messages.src/serial_port_handler.rs
: Module for setting up and reading from the serial port.src/main.rs
: Entry point for the application.
- Clone the repository and build the project using the provided build instructions.
- Ensure that the USB GPS dongle is connected to the system.
- Copy and modify the
example.settings.toml
file to configure the project. - Run the executable as described in the build instructions.
MQTT data is stored under configured topic as 3 letter codes:
- CRS - course in degrees
- TME - GMT time in HH:MM:SS format
- DTE - date in dd.mm.YYYY format
- LAT - latitude
- LNG - longitude
- SPD - speed in km/h
- ALT - altitude in m
- QTY - fix quality
There are also pre build packages, that combines three individual components: Speeduino-to-MQTT, GPS-to-MQTT, and G86 Web Dashboard in one system with predefined services.
You can quickly get started by using pre-built packages available for both x64 and Raspberry Pi 4 (ARM) architectures:
- DEB Packages for x64: Download here
- DEB Packages for Raspberry Pi 4 (ARM): Download here
- RPM Packages for x64: Download here
- RPM Packages for Raspberry Pi 4 (ARM): Download here
- All packages install the three services in the directory
/opt/g86-car-telemetry
(or/usr/opt/g86-car-telemetry
). - Configuration files for GPS and ECU processors can be found under
/etc/g86-car-telemetry
(or/usr/etc/g86-car-telemetry
). - Web project configurations are located in
/var/www/g86-car-telemetry/config
(or/usr/var/www/g86-car-telemetry/config
). - Ensure to add relevant configurations for MQTT server, TTY ports, and any extra settings.
The packages automatically install and manage the following services:
g86-car-telemetry-gps
g86-car-telemetry-speeduino
g86-car-telemetry-web
These packages have been tested on both Raspberry Pi 4 (ARM) with DEB packages and x86 systems with RPM packages. However, please note that this project is a work in progress, and more tests are needed, especially with real ECUs. Exercise caution when using, and stay tuned for updates as development continues to enhance and stabilize the functionality.
Feel free to reach out if you have any questions or encounter issues. Happy telemetry monitoring! 📊🛠️
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the license terms.