# Extract GPS data from payload

**URL:** <https://discourse.nodered.org/t/extract-gps-data-from-payload/94652>\
**Category:** General\
**Created:** [15 January 2025 18:20 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652 "2025-01-15T18:20:03Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [15 January 2025 18:20 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/1 "2025-01-15T18:20:03Z")

</div>

I'm stuck getting the right data from the payload of a gps tracker.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b79257f0d9b74fc5ffae23f9c0c2788aaab498c4.png)

- Is the payload (see red arrow) a Hex string? How can I get GPS data from it?
- Why do I see the battery value (99% charged) but no Latitude Longitude etc?

This is the [payload format info](https://wiki.seeedstudio.com/T1000_payload/) of the tracker

Any help is appreciated

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 January 2025 18:43 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/2 "2025-01-15T18:43:42Z")

</div>

Hi @maru

With the link you posted, what event are we actually looking at?  
I can't identify it in the provided list of possible types

if you can show us the **exact** layout description on the website of the payload, we can hopefully decipher it - but currently, it doesn't look like a single event

You might also look at [node-red-contrib-buffer-parser (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-buffer-parser)

---

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [15 January 2025 19:22 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/3 "2025-01-15T19:22:48Z")

</div>

Hi @marcus-j-davies,  
Thank you for reading.

This GPS is connected to The Things Network where I use a payload formatter.  
Bellow is a part of that formatter(it exceeds the number of characters that can be used in this forum, therefore not posted in its entirety)

```auto
            measurementArray = [
                {measurementId: '3940', type: 'Work Mode', measurementValue: workMode},
                {measurementId: '3942', type: 'Heartbeat Interval', measurementValue: heartbeatInterval},
                {measurementId: '3943', type: 'Periodic Interval', measurementValue: periodicInterval},
                {measurementId: '3944', type: 'Event Interval', measurementValue: eventInterval},
                {measurementId: '3941', type: 'SOS Mode', measurementValue: getSOSMode(dataValue.substring(16, 18))},
                {measurementId: '3900', type: 'Uplink Interval', measurementValue: interval}
            ]
            break;
        case '05':
            measurementArray = [
                {measurementId: '3000', type: 'Battery', measurementValue: getBattery(dataValue.substring(0, 2))},
                {measurementId: '3940', type: 'Work Mode', measurementValue: getWorkingMode(dataValue.substring(2, 4))},
                {measurementId: '3965', type: 'Positioning Strategy', measurementValue: getPositioningStrategy(dataValue.substring(4, 6))},
                {measurementId: '3941', type: 'SOS Mode', measurementValue: getSOSMode(dataValue.substring(6, 8))}
            ]
            break
        case '06':
            collectTime = getUTCTimestamp(dataValue.substring(8, 16))
            measurementArray = [
                {measurementId: '4200', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Event Status', measurementValue: getEventStatus(dataValue.substring(0, 6))},
                {measurementId: '4197', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Longitude', measurementValue: parseFloat(getSensorValue(dataValue.substring(16, 24), 1000000))},
                {measurementId: '4198', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Latitude', measurementValue: parseFloat(getSensorValue(dataValue.substring(24, 32), 1000000))},
                {measurementId: '4097', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Air Temperature', measurementValue: getSensorValue(dataValue.substring(32, 36), 10)},
                {measurementId: '4199', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Light', measurementValue: getSensorValue(dataValue.substring(36, 40))},
                {measurementId: '3000', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Battery', measurementValue: getBattery(dataValue.substring(40, 42))}

```

So I think the keyi part for me is measurementId '41971 and '4198'

```auto
               {measurementId: '4197', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Longitude', measurementValue: parseFloat(getSensorValue(dataValue.substring(16, 24), 1000000))},
                {measurementId: '4198', timestamp: collectTime, motionId: getMotionId(dataValue.substring(6, 8)), type: 'Latitude', measurementValue: parseFloat(getSensorValue(dataValue.substring(24, 32), 1000000))},

```

Is this useful?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 January 2025 20:07 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/4 "2025-01-15T20:07:23Z")

</div>

Mmm when I try to decode it - I end up at the Atlantic?  
can you pass the whole data buffer that you get?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 January 2025 21:31 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/5 "2025-01-15T21:31:15Z")

</div>

If you search for packet type 0x11 (the first byte in the payload you show as an example) - in that document you shared - you can see that it is a Positioning Status and Sensor Packet-0x11  
ID 0x11 is used to upload the positioning status, sensor data and battery.  
So there is no GPS info in that packet... you need to share one of the types that does contain location info - packet type 0x06 or 0x09 I think - which then corresponds to the later code snippet you show (case 06) .

(Finally the packet you show starts 1101 so type 0x11 - second byte 01 means The GNSS scan timed out and failed to obtain the location. - so you may not see any packets of type 0x06 until you get a valid location detected. (ie 0x1100... ))

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [15 January 2025 22:26 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/6 "2025-01-15T22:26:50Z")

</div>

I’m glad there is people like you around @dceejay.  
I’m just happy I wasn’t going mad.

---

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [15 January 2025 22:51 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/7 "2025-01-15T22:51:29Z")

</div>

Thanks you for this explanation, it's getting clearer to me now.  
I already suspected that there was no GPS data in the data obtained.  
Perhaps the tracker can't see a satellite because it's in the house?  
I'll take it outside and try to get more data.

---

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [16 January 2025 10:05 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/8 "2025-01-16T10:05:09Z")

</div>

@ [dceejay](https://discourse.nodered.org/u/dceejay) and @ [marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies) thank you both for your input!

I think I got it:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2aae88797c471f6ae379a47a1b037c9315e5322.png)

According to this [payload format info](https://wiki.seeedstudio.com/T1000_payload/):

```auto
Byte:
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
09 00 00 00 00 67 88 ca 37 00 54 00 5c 03 10 b8 84 61

Byte 1 0x09 GNSS Location Only Packet
Byte 2~4 0x000000 event status: : no event
Byte 5 0X00 motion segmentnumber: ) no motion 
Byte 6~9	0X6788ca37 = 1737017911 (DEC) seconds??  
Byte 10~13	0X0054005c = 5505116 Longitude 
Byte 14~17	0X0310b884 = 51427460 Latitude
Byte 18 0X61 = 97 (DEC) Battery level 97%

```

Next step is try to plot this on Worldmap

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 January 2025 12:02 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/9 "2025-01-16T12:02:34Z")

</div>

> [@maru](#):
>
> `09 00 00 00 00 67 88 ca 37 00 54 00 5c 03 10 b8 84 61`

you can parse this into friendly data using buffer parser:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b622e9acf2651992e37e21b8c636c8bc64eb53e.png)

demo flow

```auto
[{"id":"7a69fe6e9bc79cc2","type":"inject","z":"dc4d66c20e03fcbd","name":"09000000006788ca370054005c0310b88461","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"09000000006788ca370054005c0310b88461","payloadType":"str","x":590,"y":100,"wires":[["7d28dc01345eeda2"]]},{"id":"7d28dc01345eeda2","type":"buffer-parser","z":"dc4d66c20e03fcbd","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint8","name":"FrameId","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"EventStatus=>start","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"EventStatus=>end","offset":1,"length":1,"offsetbit":1,"scale":"1","mask":""},{"type":"bool","name":"EventStatus=>motionless","offset":1,"length":1,"offsetbit":2,"scale":"1","mask":""},{"type":"uint8","name":"MotionSegmentNumber","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"UTCTime","offset":5,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"Longitude","offset":9,"length":1,"offsetbit":0,"scale":"/ 1000000","mask":""},{"type":"uint32be","name":"Latitude","offset":13,"length":1,"offsetbit":0,"scale":"/ 1000000","mask":""},{"type":"uint8","name":"BatteryLevel","offset":17,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":510,"y":160,"wires":[["76ec65852effe6dd"]]},{"id":"76ec65852effe6dd","type":"debug","z":"dc4d66c20e03fcbd","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":160,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [16 January 2025 13:56 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/10 "2025-01-16T13:56:01Z")

</div>

Just move Latitude to lat and Longitude to lon, and add a name property and should just appear

---

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [17 January 2025 10:57 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/11 "2025-01-17T10:57:07Z")

</div>

It's trial and error but below I post my flow and node screenshots

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/4991b95f7a7dfe618561fd7907ec3255e2b9dd7b.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/9/d9d72620822bc92240396082580499def3bf8753.png)  
I used a Change node and moved Longitude to lon and another node for Latiude to lat

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e924e4fd9a130068de21b2019ba7aaf4c442c7df.png)  
also added a Change node for the name.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0479976547dfdce17f32c557bf1df390f91a2eb.png)  
The Worldmap node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9bedc1875951159ba1f3f81fcff01050e423f44.png)  
...and this is the output

I use Ctrl-Shft-m to switch to the Worldmap but I don't see a point/marker.  
What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [17 January 2025 11:12 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/12 "2025-01-17T11:12:29Z")

</div>

If you look at the examples on the information page for web-workmap you will see the properties need to be in the same payload.  
[node-red-contrib-web-worldmap (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-web-worldmap)

The minimum **msg.payload** must contain `name`, `lat` and `lon` properties, for example

```auto
    msg.payload = { "name":"Jason", "lat":51.05, "lon":-1.35 }

```

In the flow you posted, the properties are in separte payloads - so you need to combine them.

---

<div class="post-metadata">

**Author:** ![maru](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maru/32/99601_2.png) [@maru](https://discourse.nodered.org/u/maru)\
**Post date:** [17 January 2025 11:13 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/13 "2025-01-17T11:13:40Z")

</div>

Tha's it! 😀

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/941f89adc9e9ce39fb1fb64aaa50851c712650c0.png)

This is a working flow, with a combined Cnage node for lon and lat

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3756090f66b7823db73ec72c715ea41f94866dda.png)  
with a combined Change node for lon and lat

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/dfb3281e95f78a2266c75b441f93bce0f79fdb30.png)

Thank you all for reading and advice 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 January 2025 11:14 UTC](https://discourse.nodered.org/t/extract-gps-data-from-payload/94652/14 "2025-01-31T11:14:38Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
