Device Location Data
Overview
Golain's IoT platform provides a specialized mechanism for handling device location data. This feature allows for efficient tracking and management of device geographical information, which is crucial for many IoT applications such as fleet management, asset tracking, and location-based services.
Topic Structure
Location data is transmitted and received using a dedicated MQTT topic format:
/<slug>/<device-name>/device-data/location
Where:
<slug>
is your project or organization identifier (Find this under device details on the platform.)<device-name>
is the unique identifier for the device
Data Format
Location data is structured using Protocol Buffers (protobuf), which offers efficient serialization and deserialization. The proto3 syntax is used for defining the message structure.
Proto3 Definition
syntax = "proto3";
option go_package = "github.com/golain-io/protos/wkt";
message location {
double latitude = 1;
double longitude = 2;
float altitude = 3;
float speed = 4;
float heading = 5;
float accuracy = 6;
string timestamp = 7;
int32 timeEpoch = 8;
}
Field Descriptions
latitude
(double): The latitude coordinate in degreeslongitude
(double): The longitude coordinate in degreesaltitude
(float): The altitude in meters above sea level (optional)speed
(float): The speed of the device in meters per second (optional)heading
(float): The heading or direction of movement in degrees (0-360, where 0 is North) (optional)accuracy
(float): The accuracy of the location data in meters (optional)timestamp
(string): A human-readable timestamp of when the location was recorded (optional)timeEpoch
(int32): The Unix epoch time (in seconds) when the location was recorded (optional)
You only need to send timestamp
or timeEpoch
when there is a mis-match between time of recording the data and time of sending. Golain uses the time of insertion as the timestamp of the data if none of these values are provided.
Usage
Sending Location Data
Devices should publish their location data to the specified topic using the protobuf-encoded message format. Ensure that your device is capable of encoding the location data according to the provided proto definition.
Best Practices
Update Frequency: Choose an appropriate update frequency based on your application needs and device capabilities. High-frequency updates provide more accurate tracking but consume more power and bandwidth.
Data Accuracy: Use the
accuracy
field to filter out potentially unreliable location data in your applications.Time Synchronization: Ensure that devices have accurate time synchronization to provide meaningful
timestamp
andtimeEpoch
values.Power Management: For battery-powered devices, optimize location update frequency to balance between accuracy and power consumption.
Data Retention: Implement appropriate data retention policies for historical location data, considering both storage constraints and potential analytical needs.
Integration with Golain Features
Location data can be leveraged across various Golain platform features:
- Dashboards: Create geospatial visualizations using the Geo Map panel type.
- Rule Engine: Trigger actions based on device location (e.g., geofencing alerts).
- Analytics: Perform spatial analysis on historical location data.
By utilizing this standardized approach to location data, you can easily implement location-aware features in your IoT solutions, ensuring consistency and interoperability across your devices and applications.