Skip to content

How to get information from sensors and counters of tracker

Devices can be used not only to track GPS location. They can provide information about mileage, engine hours, measured from sensors like fuel level and temperature. All API calls to interact with devices can be found in tracking/tracker branch.


Counters

Odometer allows to control a vehicle’s mileage in real-time. The mileage readings can be based on the data received from a GPS tracking device or CAN bus.

Engine hours is a tool that allows owners of vehicles and special machinery to monitor engine running time and schedule maintenance works based on this data.

Counter creation

To get information from counters they should be created. To create a counter use the call value/set.

For example, we need to create odometer and engine hours counters. In this case we should use the next commands:

Odometer:

curl -X POST 'https://api.navixy.com/v2/tracker/counter/read' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "tracker_id": 311852, "type": "odometer", "value": 98342.1}'
https://api.navixy.com/v2/tracker/counter/read?hash=a6aa75587e5c59c32d347da438505fc3&tracker_id=311852&type=odometer&value=98342.1

Engine hours:

curl -X POST 'https://api.navixy.com/v2/tracker/counter/read' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "tracker_id": 311852, "type": "engine_hours", "value": 2368.2}'
https://api.navixy.com/v2/tracker/counter/read?hash=a6aa75587e5c59c32d347da438505fc3&tracker_id=311852&type=engine_hours&value=2368.2

The platform will notify you about success in reply.


Getting values from counter

Now we can get information from these counters when we need with the get_counters API call. With it the last update time and values of all counters in one call will be received. If necessary to get information from only specific counter type and one device then value/get call will be suitable. The same information can be obtained for the list of devices . In this case use value/list call.


Counter values for a history period

Sometimes necessary to get data for the specific period with timestamps. For example, it may be necessary for insurances or governments. In this case should be used data/list call. It will return JSON with the next information:

Response
{
  "success": true,
  "list": [
    {
      "value": 581321.0,
      "update_time": "2021-05-30 12:16:01"
    },
    {
      "value": 581322.0,
      "update_time": "2021-05-30 12:36:01"
    },
    {
      "value": 581323.0,
      "update_time": "2021-05-30 12:56:01"
    },
    {
      "value": 581324.0,
      "update_time": "2021-05-30 13:16:01"
    },
    {
      "value": 581325.0,
      "update_time": "2021-05-30 13:36:01"
    }
  ]
}

Counted mileage and engine hours for a period

Sometimes we need counted values for a period, for example, how many kilometers the device travelled for 10 days or how many hours the engine was on. In this case we should use stats/mileage or stats/engine_hours calls.


Sensors

The platform has two subtypes of sensors:

  • metering sensors - Discrete sensors responsible for inputs states on the platform.
  • discrete sensors - Measurement sensors will show information from variable types of sensors.

The list of all supported sensors can be found here

Sensor creation

The ability to connect sensors, as well as their number may vary depending on the device model. Some sensors automatically creates by the platform. The list of these sensors depends on device model and information received from them. Some sensors should be created manually.

Full sensor creation has several steps:

  1. Data sending from the sensor should be configured on the device's side, and it should be received by the platform. How to know - which one is received by the platform? The best way is connecting to AirConsole.
  2. We know - which sensor sends data and can choose one to create
  3. If this is an analog sensor, or it is a sensor that sends data in uncalibrated values (for example, fuel sensor that sends percents instead of liters) - it should be calibrated.

Getting values from sensors

All sensors can be found in different widgets. Discrete widgets in the inputs' widget. Measurement sensors can be found in the sensors readings, OBD & CAN and Fuel level widgets. For every widget we have its own API call to get data:

  • To get input states use get_inputs request.
  • To get data from CAN and OBD sensors get_diagnostics API action.
  • Data from the fuel sensors can be obtained using get_fuel call.
  • Readings from metering not CAN, OBD and fuel sensors mey be received with get_readings call.

Getting values from all sensors and states

Also, you are able to get the data from all sensors of the device, its states and counters. Use tracker/readings request. It will reply with the next information:

{
    "success": true,
    "inputs": [
        {
            "label": "Board voltage",
            "units": "V",
            "name": "board_voltage",
            "type": "power",
            "value": 26.13,
            "units_type": "custom",
            "converted_units_type": null,
            "converted_value": null,
            "update_time": "2021-06-01 15:23:03"
        },
        {
            "label": "Analog sensor #1",
            "units": "",
            "name": "analog_1",
            "type": "fuel",
            "min_value": 0.0,
            "max_value": 450.0,
            "value": 269.82,
            "units_type": "litre",
            "converted_units_type": null,
            "converted_value": null,
            "update_time": "2021-06-01 15:23:03"
        }
    ],
    "states": [
        {
            "field": "battery_level",
            "value": 4.01,
            "update_time": "2021-06-01 15:23:03"
        },
        {
            "field": "input_status",
            "value": 0,
            "update_time": "2021-06-01 15:23:03"
        },
        {
            "field": "movement_state",
            "value": "parked",
            "update_time": "2021-06-01 15:23:03"
        },
        {
            "field": "actual_track",
            "value": 34112,
            "update_time": "2021-06-01 12:58:03"
        },
        {
            "field": "output_status",
            "value": 3,
            "update_time": "2021-06-01 15:23:03"
        },
        {
            "field": "tcp_status",
            "value": 2,
            "update_time": "2021-06-01 15:23:05"
        }
    ]
}
  • input status and output status fields will show you binary information in decimal form. For example, output_status field shows 3 - it is 11 in binary. The example device has two outputs. That's why 11 means output 1 = On and output 2 = ON.

Getting data from multiple devices in one request

There is an API call that may optimize work with multiple devices at once. Just in case it is necessary to request the current data from a lot of devices in one account, use tracker/readings/batch_list API call. It allows getting the same information as in the previously described method for multiple trackers.


Getting historical data from sensors

It may be necessary to get historical data from measurement sensors. In this case, you can use tracker/sensor/data/read API call which allows you to get all provided values from a sensor in a period of 30 days. Choose the necessary sensor and specify its ID. The list of a device's sensors with IDs you can get with sensor/list request.


Last update: August 1, 2023