question

xsilvergs avatar image
xsilvergs asked

GPS modbus Lat & Lng

Trying to read gps Lat and Lng off of modbus which I believe should be on address 2800 and 2802 but the values appear wrong in Node-Red but correct on the Remote Console.

Correct Lng on Remote Console:-

screenshot-2022-12-17-153640.png

Modbus node settings

screenshot-2022-12-17-153403.png

Output in Node-Red

screenshot-2022-12-17-153037.png

Can anyone help or explain what is wrong or I'm doing wrong?

Thanks for any help.

Node-REDModbus TCPgps
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

5 Answers
Dirk-Jan Faber (Victron Energy) avatar image
Dirk-Jan Faber (Victron Energy) answered ·

The answer is given as an _int32_ contained in the 2 array values. This means that you need to convert it back to something more readable. This can be done, for example, with a function node that does something like:

msg.payload = msg.payload[0] << 16 | msg.payload[1];
if ((msg.payload & 0x8000) > 0) {
   msg.payload -= 0x10000;
}

msg.payload /= 10000000;

return msg;

The first part concatenates the two array values to a single number. Then the first bit is checked to see if the number is negative or not. Finally the result is divided by 10000000.

flows.json.zip


flowsjson.zip (679 B)
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

xsilvergs avatar image xsilvergs commented ·
Thank you, I would like to think I'd have got there on my own (eventually), sometimes I can't see the wood for the trees. Your help is much appreciated,
0 Likes 0 ·
xsilvergs avatar image
xsilvergs answered ·

@Dirk-Jan Faber

I have tried to use your example with a solar controller but failed again. The result should be 0.21999r confirmed in VictronConnect. If you explain were I've gone wrong I would appreciate it.

Thanks for your time.

screenshot-2022-12-18-190138.png

com.victronenergy.solarcharger Yield yesterday 786 uint16 10 0 to 6553.5

screenshot-2022-12-18-190032.png

screenshot-2022-12-18-185626.png

screenshot-2022-12-18-190457.png


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dirk-Jan Faber (Victron Energy) avatar image
Dirk-Jan Faber (Victron Energy) answered ·

Object id 786 is an int16, which means that you need to set the quantity to 1 instead of 2. So you can ignore the 101 in your example and focus on the 2. The scale factor is 10 for id 786, so that makes 2/10 = 0.2. I assume that the modbus reading looses some of the accuracy.

In order to easily retrieve modbus values for our equipment, you might want to take a look at the subflow I just added here: https://flows.nodered.org/flow/c54f2b4e3cb525d3232018c6144cbd12, which only requires to add the UnitID and the correct line from the attributes.csv file (more info is in the documentation of the flow). Feel free to test and provide feedback so that subflow can be further improved.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

xsilvergs avatar image xsilvergs commented ·

@Dirk-Jan Faber

Thanks for help.

At 22:00 GMT Your Link isn't working:-

screenshot-2022-12-18-220145.png


0 Likes 0 ·
xsilvergs avatar image
xsilvergs answered ·

@Dirk-Jan Faber

Thank you for your help.

At 22:23 GMT your link shows:-

screenshot-2022-12-18-220145.png

I'll try again tomorrow.


5 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dirk-Jan Faber (Victron Energy) avatar image Dirk-Jan Faber (Victron Energy) ♦ commented ·
That should be fixed now. By default GitHub sets the gist as secret. Now made it public.
0 Likes 0 ·
xsilvergs avatar image xsilvergs Dirk-Jan Faber (Victron Energy) ♦ commented ·
For info, at 09:02 GMT I get the same 'Thing not found' message.
0 Likes 0 ·
Dirk-Jan Faber (Victron Energy) avatar image Dirk-Jan Faber (Victron Energy) ♦ xsilvergs commented ·

Ah, I see that there is a comma in the above link. Let me try to edit that out. Meanwhile https://flows.nodered.org/flow/c54f2b4e3cb525d3232018c6144cbd12 is the correct one.

0 Likes 0 ·
xsilvergs avatar image xsilvergs Dirk-Jan Faber (Victron Energy) ♦ commented ·

10:13 GMT

I am still getting 404 - Thing not found

0 Likes 0 ·
xsilvergs avatar image xsilvergs xsilvergs commented ·

Even though your link doesn't show a comma at the end, one remains.

https://flows.nodered.org/flow/c54f2b4e3cb525d3232018c6144cbd12,

0 Likes 0 ·
xsilvergs avatar image
xsilvergs answered ·

@Dirk-Jan Faber

Using link https://flows.nodered.org/flow/c54f2b4e3cb525d3232018c6144cbd12 I am suitably impressed. Thanks for some great work.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.