Drivetech / meitrack-parser

Parse raw data from Meitrack devices
MIT License
4 stars 2 forks source link

Battery calculation #87

Closed Meshalaw closed 6 years ago

Meshalaw commented 6 years ago

Thank you for your efforts. How did you calculate the battery in your code?

lgaticaq commented 6 years ago

Hello i get formula from official documentation. Check point 8.2.5 (pag 14) in MEITRACK_MVT380_User_Guide.pdf

Meshalaw commented 6 years ago

But when I applied the value I get for AD4 from the device (After converting it from hexa to decimal then to voltage), the formula gives me a negative number. I'm not sure what I'm doing wrong.

lgaticaq commented 6 years ago

Paste your raw data for debugging

Meshalaw commented 6 years ago
{
  "_index": "logstash-2018.11",
  "_type": "logs",
  "_id": "AWIZcBxBIXjdt0iwPXaF",
  "_score": null,
  "_source": {
    "altitude": "538",
    "latitude": "24.500020",
    "SLA": "5",
    "ignitionON": "true",
    "portStatus": "xxxxxx",
    "feedStatus": "valid",
    "battery": 95,
    "speed": 87,
    "protocol": "TCP_xxx",
    "datetime": "20180312085958",
    "Runtime": "13364922",
    "CommandType": "AAA",
    "checksum": "E9",
    "longitude": "46.938750",
    "direction": "317",
    "mileage": "573564",
    "satellites": "9",
    "imeiStatus": "1",
    "unique_id": "xxxxxxxxxx",
    "functionName": "Time Interval Tracking",
    "BaseStationInfo": "420|1|0C95|00919F18",
    "gsm_signal": "17",
    "AnalogInputValue": "0000|0000|0000|01A0|0558",
    "EventName": "Time Interval Tracking",
    "panicButon": "false",
    "PositioningStatus": "Valid",
    "imei": "xxxxxxx",
    "deviceModel": "MVT600",
    "HDOP": "1.0",
    "device": "MEITRACK",
    "@version": "1",
    "@timestamp": "2018-03-12T08:59:59.777Z",
    "kafka": {
      "msg_size": 734,
      "topic": "golive",
      "consumer_group": "logstash",
      "partition": 0,
      "offset": 801393792,
      "key": null
    },
    "geoip": {
      "location": [
        46.93875,
        24.50002,
        46.93875,
        24.50002,
        46.93875,
        24.50002,
        46.93875,
        24.50002
      ]
    }
  },
  "fields": {
    "@timestamp": [
      1520845199777
    ]
  },
  "highlight": {
    "device": [
      "@kibana-highlighted-field@MEITRACK@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1520845199777
  ]
}
lgaticaq commented 6 years ago

Check battery calculation in https://runkit.com/lgatica/meitrack-mvt380-battery

Meshalaw commented 6 years ago

Meitrack devices behave strange, the battery percentage equation they provide doesn't make sense to me. It contradicts with the actual data the device sends. We made our own equation and it is kind of working, I have to keep debugging.

Meitrack equation 0000|0000|0000|01A0|0558 01A0 = 416 Vmax = 4.2 (416 3 2) / 1024 = 2.43V 2.43/4.2 = 0.58 0.65 * 100% = 58% Doesn't make sense to me, because the device is fully charged at this moment, it can't be 58%.

Our equation 416/100 = 4.16V Vmin = 3.4 4.16 - 3.4 / (4.2-3.4) =0.95 Now 0.95 * 100% = 95%

Thanks for your support.

lgaticaq commented 6 years ago

:+1: