Function to add L and H registers in Modbus

Hi all. I have seen various you tube videos on how it works but I cant figure out how to do it.
I have my EP Solar controller and I want to get the values from Charging equipment input power L (3102) and Charging equipment input power H (3103) but I am getting confused on how to combine them together to give me one reading

Can anybody guide me to on how to get the correct values please?

Did you solve this?

I suspect you need to read them in one read node (length 2) and you will get a single buffer containing both values. Then you can simply combine them to make the final number.

I did. I found a code somebody else made, and took that apart to see how it works. I use a function to read the registers into a modbus Flex Getter and send them to a switch and pull the individual values from there.
Then put them into a join

Glad you got it solved - though TBH, it sounds like you are polling 2 addresses in 2 separate reads then joining them together

You know you could (and should) read those 2 resisters in one go?

Reading multiple registers in one hit has the following benefits...

  • halves the amount of comms (or speeds things up by 2x if you look at it from another perspective)
  • ensures consistency (e.g. if the PLC/modbus device updates register 3103 as you are reading 3102, you end up with inconsistent data - trust me on this - it happens! ).

If you want an elegant way of handling this type of issue - let me know and I will help out.

Thanks Steve
This is my testing I am looking at the battery power
flows(3).json (13.0 KB)

Hi @swanside I think there is a fair bit of consolidation can be made & as a test i would like to try.

could you post the output of the flexgetter in a reply like this...

Add a debug set to "Show complete Message"...

copy the value...

the paste copied msg in a reply
like this - between backticks


Hi sorry for delay but got there eventualy. Thanks {"topic":"livestats","messageId":"5f005a731cef5be24124c372","payload":[3127,277,8690,0,2750,316,8690,0,2750,8,0,0,0,0,0,0,2500,2173],"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1,"modbusRequest":{"unitid":1,"fc":4,"address":12544,"quantity":18,"emptyMsgOnFail":false,"keepMsgProperties":false,"messageId":"5f005a731cef5be24124c372"},"responseBuffer":{"data":[3127,277,8690,0,2750,316,8690,0,2750,8,0,0,0,0,0,0,2500,2173],"buffer":[12,55,1,21,33,242,0,0,10,190,1,60,33,242,0,0,10,190,0,8,0,0,0,0,0,0,0,0,0,0,0,0,9,196,8,125]},"_msgid":"b74981da.d6c04"}

Hi so, I took a look at what you had and it seems you already get everything in one hit from the modbus node (good) - so no issue with consistency. Anyhow, I did say i would provide an elegant way of handling this - so, here you go.

Your flow...

My adaption of your flow...

The what and the why...

  • no join nodes
  • reduced duplication (only one scaling node)
  • data is converted to individual objects with topic & payload in one node (the buffer-parser)
  • more extensible / maintainable (i.e. if you add add another item, you dont need to modify the switch and add another change node for applying the topic & config is centralised)

NOTE: You will need node-red-contrib-buffer-parser node to use this

Hope its of some use.

Thanks Steve. WiIl take a closer look into that. Still have lots to learn and google

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