Doing Calculations on Modbus data

I need to get data from modbus server and perform calculation on this data, been searching all day and still no closer to an answer, so im asking if anyone can help.

I have to get 3 items from solar charger controllers modbus server

Item Logical Address

V_PU Hi 1
V_PU Lo 2
Battery Voltage Filtered 25

Once I have these I have to do some calculations

V_PU Hi + (V_PU Lo / 65536) = Voltage scaller

than

(Battery Voltage Filtered x Voltage Scaller) / 32768 = Actual Battery Voltage

So what i have so far is a 1 second repeating timestamp going to 3 functions

Function 1 L_PU Hi:
msg.payload = {
value: msg.payload,
'fc': 3,
'unitid': 1,
'address': 0x0000 ,
'quantity': 1
} ;
return msg;

Function 2 L_PU Lo:
msg.payload = {
value: msg.payload,
'fc': 3,
'unitid': 1,
'address': 2 ,
'quantity': 1
} ;
return msg;

Function 3 Batt Volts Filtered:
msg.payload = {
value: msg.payload,
'fc': 3,
'unitid': 1,
'address': 0x0018 ,
'quantity': 1
} ;
return msg;

Which go into individual Modbus Flex Getter's

A 2nd Function for V_PU Lo goes to a 2nd function

msg.payload = (msg.payload / 65536);
var v_pulo = msg.payload;
return msg;

this is where i am stuck, how do i now take the output of function 3 batt volts filtered and multiply that with V_PU Lo's 2nd function output and than divide the result by 32768 to get the battery voltage which i can than feed into a home assistant sensor.

Any assistance anyone can give would be much appreciated.

Cheers

Hi, my recommendation is this...

DONT do individual reads (your code will be prone to inconsistent data as the 3 polls occur individually).

Also, messages travel down the wires NOT at the same time - (this is a fundamental aspect of nodered) - and is the reason you dont have all values from the 3 separate read nodes in your function

As your data is in addresses very close to one another (address 0, 2, 24) I would strongly recommend you get all in one hit & thus all values will be in the same message.

I would also recommend using the buffer-parser node to coarse the values you need in to nice types e.g.

image

demo flow...

[{"id":"49e1c7a.657d738","type":"inject","z":"56a2925d.72edac","name":"click me","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":900,"y":60,"wires":[["f51f0101.a590f"]]},{"id":"f51f0101.a590f","type":"function","z":"56a2925d.72edac","name":"faking modbus data","func":"msg={\"topic\":\"312979ea.14b816\",\"messageId\":\"5f8714b17903fbeddd2c36d2\",\"payload\":\"\",\"unitId\":1,\"modbusRequest\":{\"unitid\":1,\"fc\":3,\"address\":99,\"quantity\":96,\"emptyMsgOnFail\":true,\"keepMsgProperties\":false,\"messageId\":\"5f8714b17903fbeddd2c36d2\"},\"responseBuffer\":{\"data\":[4299,15815,5348,15773,38588,15632,4299,15815,5348,15773,38588,15632,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16256,0,16256,0,16256,0,16256,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49366,15957,58876,17331,0,0,0,0,32008,15788,0,16928,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\n\"buffer\":Buffer.from(\n    [\n        0xf6,0x42, //0,1\n        0x66,0xe6, //2,3\n        1,1, //4,5\n        1,1, //6,7\n        150,188, //8,9\n        61,16, //10,11\n        16,203, //12,13\n        61,199, //14,15\n        20,228, //16,17\n        61,157, //18,19\n        150,188,//20,21\n        61,16,//22,23\n        16,203,//24,25\n        61,199,//26,27\n        1,228,//28,29\n        61,157,//30,31\n        61,157,//32,33\n        61,157,//34,35\n        157,1,//36,37\n        157,61,//38,39\n    ])},\"_msgid\":\"f2794381.55066\",\"originalPayload\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,4299,15815,5348,15773,38588,15632,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16256,0,16256,0,16256,0,16256,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49366,15957,58876,17331,0,0,0,0,32008,15788,0,16928,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":120,"wires":[["5666b369.94b85c"]]},{"id":"5666b369.94b85c","type":"buffer-parser","z":"56a2925d.72edac","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"L_PU","offset":0,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"uint16be","name":"BattVolts","offset":36,"length":1,"offsetbit":0,"scale":0.01,"mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":920,"y":180,"wires":[["5d76f097.95812"]]},{"id":"5d76f097.95812","type":"debug","z":"56a2925d.72edac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":950,"y":240,"wires":[]}]

PS please always post code between backticks

```
like this
```

Hi and thanks for your reply.

Thats what i want to do but being new to node red I am having trouble working out how to do things, completely different to anything i have done in the past with arduino and php coding etc..

So how do i collect just the 3 modbus data fields in one function???

I know it pulls them into an array, i can get the 1st two easily as there one after the other so i can just put quantity as 2 with the start address at the 1st one but how do i than add the 25th address to that array.

Im guessing that that buffer-parser takes each item out of the array one at a time and adds them to variables with preset attributes

This is what i have for my other battery monitor modbus flow...
I'm sure it needs cleaning up to so i can get all the modbus data in one function as well, but this is working and the other one is not so would like to get that working than i can take what i learn from that to fix this one to..

[{"id":"77af4c8e.014144","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":680,"wires":[["4128978b.6bcca8"],[]]},{"id":"41132e4e.dbb4d","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 0 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":680,"wires":[["77af4c8e.014144"]]},{"id":"26e0aa6.9c04b56","type":"inject","z":"51f463cd.dae60c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":940,"wires":[["41132e4e.dbb4d","193e83da.cdb15c","773d3683.12c2f8","238b48c6.659b58","20318a9a.d47b66","d9e755b4.e14518","a7064a17.4072e8","c7642e2c.1a8c5","4f22da5f.31f9e4","a3f18c57.ca869"]]},{"id":"4128978b.6bcca8","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":680,"wires":[["beb8af51.1812c"]]},{"id":"fb7a95d2.38ad88","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":740,"wires":[["d6f5ea48.54daf8"]]},{"id":"193e83da.cdb15c","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 1 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":740,"wires":[["5b416eed.7b6f6"]]},{"id":"5b416eed.7b6f6","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":740,"wires":[["fb7a95d2.38ad88"],[]]},{"id":"773d3683.12c2f8","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 2 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":800,"wires":[["f597cb9d.7b1cd8"]]},{"id":"f597cb9d.7b1cd8","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":800,"wires":[["dc5bc9ed.0ad008"],[]]},{"id":"dc5bc9ed.0ad008","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":800,"wires":[["28fc3d5e.f81552"]]},{"id":"beb8af51.1812c","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-volts","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-volts"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"v"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":970,"y":680,"wires":[[]]},{"id":"d6f5ea48.54daf8","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-volts_filtered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-volts"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"v"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":990,"y":740,"wires":[[]]},{"id":"28fc3d5e.f81552","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-volts2","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-volts2"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"v"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":970,"y":800,"wires":[[]]},{"id":"238b48c6.659b58","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 3 , \n    'quantity': 1 \n    \n} ;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":860,"wires":[["6284c13f.5f9ce"]]},{"id":"20318a9a.d47b66","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 4 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":920,"wires":[["99535ea.73f31a"]]},{"id":"d9e755b4.e14518","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 5 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":980,"wires":[["4225f1a8.fd5c3"]]},{"id":"a7064a17.4072e8","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 6 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":1040,"wires":[["3f5178ea.83e148"]]},{"id":"c7642e2c.1a8c5","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 7 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":1100,"wires":[["bd2b7d81.02696"]]},{"id":"4f22da5f.31f9e4","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 8 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":1160,"wires":[["8f29261b.179b98"]]},{"id":"a3f18c57.ca869","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 9 , \n    'quantity': 1 \n    \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":290,"y":1220,"wires":[["1b26a053.2e9f3"]]},{"id":"6284c13f.5f9ce","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":860,"wires":[["26fd1806.c7ab18"],[]]},{"id":"99535ea.73f31a","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":920,"wires":[["7f1e1187.47a03"],[]]},{"id":"4225f1a8.fd5c3","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":980,"wires":[["227e0370.75cd6c"],[]]},{"id":"3f5178ea.83e148","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":1040,"wires":[["912d2dc2.34ad5"],[]]},{"id":"bd2b7d81.02696","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":1100,"wires":[["8773509f.bb20f"],[]]},{"id":"8f29261b.179b98","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":1160,"wires":[["a7d2356e.6293d8"],[]]},{"id":"1b26a053.2e9f3","type":"modbus-flex-getter","z":"51f463cd.dae60c","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"6776ec8d.5260e4","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":470,"y":1220,"wires":[["83d1c5d.21f6a38"],[]]},{"id":"912d2dc2.34ad5","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":1040,"wires":[["dcb9cf7c.74e4d"]]},{"id":"a7d2356e.6293d8","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":1160,"wires":[["62095edc.cf2ef"]]},{"id":"83d1c5d.21f6a38","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":650,"y":1220,"wires":[["cb761cf3.e2ab8"]]},{"id":"2213bd5e.802ef2","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-amps","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-amps"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":970,"y":860,"wires":[[]]},{"id":"b74bdfd3.05f35","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-amps_filtered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-amps_filtered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1000,"y":920,"wires":[[]]},{"id":"d5daee81.2fb22","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-amp_hours","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-amp_hours"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"AH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":990,"y":980,"wires":[[]]},{"id":"dcb9cf7c.74e4d","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-soc","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-soc"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":960,"y":1040,"wires":[[]]},{"id":"d0a80bb3.c5b588","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-watts","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-watts"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"w"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":970,"y":1100,"wires":[[]]},{"id":"62095edc.cf2ef","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-days_since_charged","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-days_since_charged"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"days"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1020,"y":1160,"wires":[[]]},{"id":"cb761cf3.e2ab8","type":"ha-entity","z":"51f463cd.dae60c","name":"tristar-days_since_equalised","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"tristar-days_since_equalised"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"days"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1020,"y":1220,"wires":[[]]},{"id":"26fd1806.c7ab18","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = (msg.payload << 16) >> 16;\nreturn msg;\n","outputs":1,"noerr":0,"x":650,"y":860,"wires":[["2e63cd04.2dcb52"]]},{"id":"7f1e1187.47a03","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = (msg.payload << 16) >> 16;\nreturn msg;\n","outputs":1,"noerr":0,"x":650,"y":920,"wires":[["bd9b7c4f.7c7f"]]},{"id":"227e0370.75cd6c","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = (msg.payload << 16) >> 16;\nreturn msg;\n","outputs":1,"noerr":0,"x":650,"y":980,"wires":[["9bbaabba.af4b48"]]},{"id":"8773509f.bb20f","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.payload = (msg.payload << 16) >> 16;\nreturn msg;\n","outputs":1,"noerr":0,"x":650,"y":1100,"wires":[["76b6042c.9b1d1c"]]},{"id":"2e63cd04.2dcb52","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":790,"y":860,"wires":[["2213bd5e.802ef2"]]},{"id":"bd9b7c4f.7c7f","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":790,"y":920,"wires":[["b74bdfd3.05f35"]]},{"id":"9bbaabba.af4b48","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":790,"y":980,"wires":[["d5daee81.2fb22"]]},{"id":"76b6042c.9b1d1c","type":"calculator","z":"51f463cd.dae60c","name":"","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"10","round":false,"decimals":0,"x":790,"y":1100,"wires":[["d0a80bb3.c5b588"]]},{"id":"6776ec8d.5260e4","type":"modbus-client","z":"","name":"TriStar","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.88.178","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"e4aac543.d77058","type":"server","z":"","name":"Home Assistant","addon":true}]

This flow doesnt try to combine results - you do 10 reads and use the 10 values - i.e. you are not trying to use values from individual polls - thats why this one works.

Again though, a strong recommendation is to read all data in one hit (10 times more eficient and data is consistent) if you read all registers in one go. So that ^ flow would be greatly simplified to ....

this is what you get out of the buffer parser...
image
^ all data is in one message (obviously i used fake data)

benefits ...

  • one modbus node - one read - all registers - consistent data
  • more manageable 30 nodes reduced to 3
  • no function nodes
  • no "calculator" nodes
  • all results in one message permitting you to do math on items with each other (if required)

Back to your original problem...

You never posted a flow for the original issue but I imagine it looks something like...

As I said in my first reply - messages DO NOT arrive at the last function block at the same time. But if you use the buffer parser (like I demoed on my first reply and above) you WILL have all values in the same message permitting you to do something like (for example) msg.calc = msg.payload.V_PU * msg.payload.BatVolts - because the values all arrive in the function at the same time (in the same message)

I dont know how you do that formatting but looks much better...

Ok so i have done this, this gets all the data i need from the Solar Charger Controller and parses it into named variables. Now i just need to work out how to manipulate the data..

[{"id":"81d6661c.13e578","type":"buffer-parser","z":"51f463cd.dae60c","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"V_PU_Hi","offset":0,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"V_PU_Lo","offset":2,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Hi","offset":4,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Lo","offset":6,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ver_sw","offset":8,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved1","offset":10,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved2","offset":12,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved3","offset":14,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved4","offset":16,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved5","offset":18,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved6","offset":20,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved7","offset":22,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved8","offset":24,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved9","offset":26,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved10","offset":28,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved11","offset":30,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved12","offset":32,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved13","offset":34,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved14","offset":36,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved15","offset":38,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved16","offset":40,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved17","offset":42,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved18","offset":44,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved19","offset":46,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattVoltsFiltered","offset":48,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattTermVoltFiltered","offset":50,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattSenseVolts","offset":52,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayVolts","offset":54,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattCurrentFiltered","offset":56,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayCurrentFiltered","offset":58,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item31","offset":60,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item32","offset":62,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item33","offset":64,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item34","offset":66,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item35","offset":68,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"HeatsinkTemp","offset":70,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"RTS_Temp","offset":72,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattRegulationTemp","offset":74,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item39","offset":76,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeCurrentFiltered","offset":78,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_min","offset":80,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_max","offset":82,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_HI","offset":84,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_LO","offset":86,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Controller_faults ","offset":88,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item46","offset":90,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_HI","offset":92,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_LO","offset":94,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"DIP_switch_positions ","offset":96,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"led_state","offset":98,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeState","offset":100,"length":1,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":310,"y":1780,"wires":[["9297cc9a.f75c9"]]},{"id":"3d7647de.37baf8","type":"modbus-read","z":"51f463cd.dae60c","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"HoldingRegister","adr":"0","quantity":"51","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"fc5193e2.1655d","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":1780,"wires":[["81d6661c.13e578"],[]]},{"id":"9297cc9a.f75c9","type":"function","z":"51f463cd.dae60c","name":"","func":"msg.V_PU_LO_CALC = msg.payload.V_PU_Lo * 65536;\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":1780,"wires":[["161d2477.92bbbc","eccf6c5c.1d1e3"]]},{"id":"161d2477.92bbbc","type":"modbus-response","z":"51f463cd.dae60c","name":"","registerShowMax":20,"x":790,"y":1700,"wires":[]},{"id":"eccf6c5c.1d1e3","type":"debug","z":"51f463cd.dae60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":770,"y":1820,"wires":[]},{"id":"fc5193e2.1655d","type":"modbus-client","z":"","name":"SolarChargeController","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.88.253","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

on the output of this parser i put a function

msg.V_PU_Lo_CALC = msg.payload.V_PU_Lo * 65536;
return msg;

but it returns all the data

That's ok. You just use what you need in the next nodes.

For example, connect the output of the last node (with all the data) to multiple dashboard nodes & set each one to show one data item.

Tbh, you seem a bit green. You would do well to learn a bit more. In particular, how to use the debug panel to find the right path to any data item.

https://nodered.org/docs/user-guide/messages

Additionally, I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.


Ps, in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

Sweet thanks for the links, i have been looking for some good videos on how to do things but haven't been able to find any good ones that are relevant to what im doing. I will have a watch.

1 Like

Thanks for all your help, starting to get my head round this stuff now.

[{"id":"81d6661c.13e578","type":"buffer-parser","z":"51f463cd.dae60c","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"V_PU_Hi","offset":0,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"V_PU_Lo","offset":2,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Hi","offset":4,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Lo","offset":6,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ver_sw","offset":8,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved1","offset":10,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved2","offset":12,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved3","offset":14,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved4","offset":16,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved5","offset":18,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved6","offset":20,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved7","offset":22,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved8","offset":24,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved9","offset":26,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved10","offset":28,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved11","offset":30,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved12","offset":32,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved13","offset":34,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved14","offset":36,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved15","offset":38,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved16","offset":40,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved17","offset":42,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved18","offset":44,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved19","offset":46,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattVoltsFiltered","offset":48,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattTermVoltFiltered","offset":50,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattSenseVolts","offset":52,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayVolts","offset":54,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattCurrentFiltered","offset":56,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayCurrentFiltered","offset":58,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item31","offset":60,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item32","offset":62,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item33","offset":64,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item34","offset":66,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item35","offset":68,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"HeatsinkTemp","offset":70,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"RTS_Temp","offset":72,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattRegulationTemp","offset":74,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item39","offset":76,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeCurrentFiltered","offset":78,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_min","offset":80,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_max","offset":82,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_HI","offset":84,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_LO","offset":86,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Controller_faults ","offset":88,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item46","offset":90,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_HI","offset":92,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_LO","offset":94,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"DIP_switch_positions ","offset":96,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"led_state","offset":98,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeState","offset":100,"length":1,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":310,"y":1780,"wires":[["9297cc9a.f75c9"]]},{"id":"3d7647de.37baf8","type":"modbus-read","z":"51f463cd.dae60c","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"HoldingRegister","adr":"0","quantity":"51","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"fc5193e2.1655d","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":1780,"wires":[["81d6661c.13e578"],[]]},{"id":"9297cc9a.f75c9","type":"function","z":"51f463cd.dae60c","name":"","func":"var voltscaller = msg.payload.V_PU_Hi + (msg.payload.V_PU_Lo / 65536);\nvar currentscaller = msg.payload.I_PU_Hi + (msg.payload.I_PU_Lo / 65536);\n\nvar battvolts1 = (msg.payload.BattVoltsFiltered * voltscaller)/32768;\nvar batttermvolts1 = (msg.payload.BattTermVoltFiltered * voltscaller)/32768;\nvar battsensevolts1 = (msg.payload.BattSenseVolts * voltscaller)/32768;\nvar arrayvolts = (msg.payload.ArrayVolts * voltscaller)/32768;\n\nmsg.payload.BattVoltsFiltered = battvolts1;\nmsg.payload.BattTermVoltFiltered = batttermvolts1;\nmsg.payload.BattSenseVolts = battsensevolts1;\nmsg.payload.ArrayVolts = arrayvolts;\n\n\nvar battcurrent = (msg.payload.BattCurrentFiltered * currentscaller)/32768;\nvar arraycurrent = (msg.payload.ArrayCurrentFiltered * currentscaller)/32768;\nvar chargecurrent = (msg.payload.ChargeCurrentFiltered * currentscaller)/32768;\n\nmsg.payload.BattCurrentFiltered = battcurrent;\nmsg.payload.ArrayCurrentFiltered = arraycurrent;\nmsg.payload.ChargeCurrentFiltered = chargecurrent;\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":1780,"wires":[["161d2477.92bbbc","eccf6c5c.1d1e3"]]},{"id":"161d2477.92bbbc","type":"modbus-response","z":"51f463cd.dae60c","name":"","registerShowMax":20,"x":790,"y":1700,"wires":[]},{"id":"eccf6c5c.1d1e3","type":"debug","z":"51f463cd.dae60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":770,"y":1820,"wires":[]},{"id":"fc5193e2.1655d","type":"modbus-client","z":"","name":"SolarChargeController","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.88.253","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]
```

Definitely - much better however I suspect you can do even better.

Firstly, there is no need to insert all the reserved items in the buffer-parser - you can simply leave them out & add them back later if you need values from the other modbus data. It just unnecessary data parsing.

Secondly, looking in your function node, it looks like you are manually changing the 16 bit WORD data into 32bit unsigned and 32bit signed data - the buffer parser can do al that for you too.

Would you capture debug data from the modbus node and the output of your function & I will show you.

then use the copy value button that appears under your mouse when you hover an item in the debug window) ...
image
... then paste the 2 debug datas into a reply (between backticks)

Ive made quite a few changes since than...

I was thinking that it could do the type conversion as well, im just not sure what to select.

[{"id":"81d6661c.13e578","type":"buffer-parser","z":"51f463cd.dae60c","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"V_PU_Hi","offset":0,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"V_PU_Lo","offset":2,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Hi","offset":4,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"I_PU_Lo","offset":6,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ver_sw","offset":8,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved1","offset":10,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved2","offset":12,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved3","offset":14,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved4","offset":16,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved5","offset":18,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved6","offset":20,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved7","offset":22,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved8","offset":24,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved9","offset":26,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved10","offset":28,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved11","offset":30,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved12","offset":32,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved13","offset":34,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved14","offset":36,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved15","offset":38,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved16","offset":40,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved17","offset":42,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved18","offset":44,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved19","offset":46,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattVoltsFiltered","offset":48,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattTermVoltFiltered","offset":50,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattSenseVolts","offset":52,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayVolts","offset":54,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattCurrentFiltered","offset":56,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ArrayCurrentFiltered","offset":58,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item31","offset":60,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item32","offset":62,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item33","offset":64,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item34","offset":66,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item35","offset":68,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"HeatsinkTemp","offset":70,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"RTS_Temp","offset":72,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"BattRegulationTemp","offset":74,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item39","offset":76,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeCurrentFiltered","offset":78,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_min","offset":80,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"vb_max","offset":82,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_HI","offset":84,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"hourmeter_LO","offset":86,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Controller_faults ","offset":88,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item46","offset":90,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_HI","offset":92,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"alarm_LO","offset":94,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"DIP_switch_positions ","offset":96,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"led_state","offset":98,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"ChargeState","offset":100,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Target_regulation_voltage","offset":102,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Ah_charge–resetable","offset":104,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item54","offset":106,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Ah_charge–total","offset":108,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"item56","offset":110,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"kWhr_charge_resetable","offset":112,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"kWhr_charge_total","offset":114,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Output_Power","offset":116,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Input_Power","offset":118,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Max_Power_of_last_sweep","offset":120,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Vmp_of_last_sweep","offset":122,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Voc_of_last_sweep","offset":124,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Reserved20","offset":126,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Min_daily_battery_voltage","offset":128,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Max_daily_battery_voltage","offset":130,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Max_daily_input_voltage","offset":132,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Total_Ah_charge_daily","offset":134,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"int16be","name":"Total_Wh_charge_daily","offset":136,"length":1,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":310,"y":1480,"wires":[["9297cc9a.f75c9"]]},{"id":"3d7647de.37baf8","type":"modbus-read","z":"51f463cd.dae60c","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"HoldingRegister","adr":"0","quantity":"69","rate":"30","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"fc5193e2.1655d","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":1480,"wires":[["81d6661c.13e578","85d8ac21.1d341"],[]]},{"id":"9297cc9a.f75c9","type":"function","z":"51f463cd.dae60c","name":"Data Scalling","func":"var voltscaller = msg.payload.V_PU_Hi + (msg.payload.V_PU_Lo / 65536);\nvar currentscaller = msg.payload.I_PU_Hi + (msg.payload.I_PU_Lo / 65536);\n\nvar battvolts1 = (msg.payload.BattVoltsFiltered * voltscaller)/32768;\nvar batttermvolts1 = (msg.payload.BattTermVoltFiltered * voltscaller)/32768;\nvar battsensevolts1 = (msg.payload.BattSenseVolts * voltscaller)/32768;\nvar arrayvolts = (msg.payload.ArrayVolts * voltscaller)/32768;\n\nmsg.payload.BattVoltsFiltered = battvolts1;\nmsg.payload.BattTermVoltFiltered = batttermvolts1;\nmsg.payload.BattSenseVolts = battsensevolts1;\nmsg.payload.ArrayVolts = arrayvolts;\n\n\nvar battcurrent = (msg.payload.BattCurrentFiltered * currentscaller)/32768;\nvar arraycurrent = (msg.payload.ArrayCurrentFiltered * currentscaller)/32768;\nvar chargecurrent = (msg.payload.ChargeCurrentFiltered * currentscaller)/32768;\n\nmsg.payload.BattCurrentFiltered = battcurrent;\nmsg.payload.ArrayCurrentFiltered = arraycurrent;\nmsg.payload.ChargeCurrentFiltered = chargecurrent;\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":1480,"wires":[["47c51624.504738","d7524c2.93517b","d24cd6de.87ec78","f2bacb48.acc298","5c42c2fa.0d5b8c","792a81b0.2c946","7abeeec0.32bf9","5c66b91f.58a9b8","26f3a08f.170fb","4048bee4.01644","ca1355b9.d94da8"]]},{"id":"47c51624.504738","type":"function","z":"51f463cd.dae60c","name":"BattVoltsFiltered","func":"var payload = Number(msg.payload.BattVoltsFiltered.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":1240,"wires":[["3b4e2844.23a308"]]},{"id":"d7524c2.93517b","type":"function","z":"51f463cd.dae60c","name":"BattTermVoltFiltered","func":"var payload = Number(msg.payload.BattTermVoltFiltered.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":1300,"wires":[["e8393818.7337f8"]]},{"id":"d24cd6de.87ec78","type":"function","z":"51f463cd.dae60c","name":"BattSenseVolts","func":"var payload = Number(msg.payload.BattSenseVolts.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":1360,"wires":[["e8f12877.23b228"]]},{"id":"f2bacb48.acc298","type":"function","z":"51f463cd.dae60c","name":"ArrayVolts","func":"var payload = Number(msg.payload.ArrayVolts.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":1420,"wires":[["2ab2d055.cacdf"]]},{"id":"5c42c2fa.0d5b8c","type":"function","z":"51f463cd.dae60c","name":"BattCurrentFiltered","func":"var payload = Number(msg.payload.BattCurrentFiltered.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":1480,"wires":[["b474d0ec.ba1ef"]]},{"id":"792a81b0.2c946","type":"function","z":"51f463cd.dae60c","name":"ArrayCurrentFiltered","func":"var payload = Number(msg.payload.ArrayCurrentFiltered.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":1540,"wires":[["7fdb21c2.bb014"]]},{"id":"7abeeec0.32bf9","type":"function","z":"51f463cd.dae60c","name":"HeatsinkTem","func":"var payload = msg.payload.HeatsinkTemp;\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":1600,"wires":[["66b3e532.8976dc"]]},{"id":"5c66b91f.58a9b8","type":"function","z":"51f463cd.dae60c","name":"RTS_Temp","func":"var payload = msg.payload.RTS_Temp;\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":1660,"wires":[["9d2a60f4.75875"]]},{"id":"26f3a08f.170fb","type":"function","z":"51f463cd.dae60c","name":"ChargeCurrentFiltered","func":"var payload = Number(msg.payload.ChargeCurrentFiltered.toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":1720,"wires":[["f4b2321e.62e23"]]},{"id":"3b4e2844.23a308","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-BattVoltsFiltered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-BattVoltsFiltered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1000,"y":1240,"wires":[[]]},{"id":"e8393818.7337f8","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-BattTermVoltFiltered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-BattTermVoltFiltered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1010,"y":1300,"wires":[[]]},{"id":"e8f12877.23b228","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-BattSenseVolts","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-BattSenseVolts"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1000,"y":1360,"wires":[[]]},{"id":"2ab2d055.cacdf","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-ArrayVolts","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-ArrayVolts"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"V"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":980,"y":1420,"wires":[[]]},{"id":"b474d0ec.ba1ef","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-BattCurrentFiltered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-BattCurrentFiltered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1010,"y":1480,"wires":[[]]},{"id":"7fdb21c2.bb014","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-ArrayCurrentFiltered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-ArrayCurrentFiltered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1010,"y":1540,"wires":[[]]},{"id":"66b3e532.8976dc","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-HeatsinkTem","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-HeatsinkTem"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"C"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":990,"y":1600,"wires":[[]]},{"id":"9d2a60f4.75875","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-RTS_Temp","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-RTS_Temp"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"C"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":990,"y":1660,"wires":[[]]},{"id":"f4b2321e.62e23","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-ChargeCurrentFiltered","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"SCC-ChargeCurrentFiltered"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"A"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1020,"y":1720,"wires":[[]]},{"id":"4048bee4.01644","type":"function","z":"51f463cd.dae60c","name":"Total_Ah_charge_daily","func":"var payload = Number((msg.payload.Total_Ah_charge_daily*0.1).toFixed(2));\nmsg.payload = payload\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":1840,"wires":[["41b46cc5.0992c4"]]},{"id":"41b46cc5.0992c4","type":"ha-entity","z":"51f463cd.dae60c","name":"SCC-Total_Ah_charge_daily","server":"e4aac543.d77058","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Total_Ah_charge_daily"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"AH"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1020,"y":1840,"wires":[[]]},{"id":"85d8ac21.1d341","type":"debug","z":"51f463cd.dae60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":1420,"wires":[]},{"id":"ca1355b9.d94da8","type":"debug","z":"51f463cd.dae60c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":1180,"wires":[]},{"id":"fc5193e2.1655d","type":"modbus-client","z":"","name":"SolarChargeController","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.88.253","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"e4aac543.d77058","type":"server","z":"","name":"Home Assistant","addon":true}]
[180,0,80,0,18,0,0,0,4858,4862,4902,1898,65506,65498,65499,23264,18056,22592,19392,21952,34416,22312,1,29349,4860,4867,4859,4897,7,65531,23263,18056,22587,19397,22309,26,22,22,4860,14,65535,16206,0,56273,0,0,0,0,250,6,5,5098,29,1451,29,1451,2576,2576,4,0,0,3589,4786,0,4844,4907,7391,99,270]
{"V_PU_Hi":180,"V_PU_Lo":0,"I_PU_Hi":80,"I_PU_Lo":0,"ver_sw":18,"Reserved1":0,"Reserved2":0,"Reserved3":0,"Reserved4":4858,"Reserved5":4862,"Reserved6":4902,"Reserved7":1898,"Reserved8":-30,"Reserved9":-38,"Reserved10":-37,"Reserved11":23264,"Reserved12":18056,"Reserved13":22592,"Reserved14":19392,"Reserved15":21952,"Reserved16":-31120,"Reserved17":22312,"Reserved18":1,"Reserved19":29349,"BattVoltsFiltered":26.69677734375,"BattTermVoltFiltered":26.7352294921875,"BattSenseVolts":26.6912841796875,"ArrayVolts":26.9000244140625,"BattCurrentFiltered":0.01708984375,"ArrayCurrentFiltered":-0.01220703125,"item31":23263,"item32":18056,"item33":22587,"item34":19397,"item35":22309,"HeatsinkTemp":26,"RTS_Temp":22,"BattRegulationTemp":22,"item39":4860,"ChargeCurrentFiltered":0.0341796875,"vb_min":-1,"vb_max":16206,"hourmeter_HI":0,"hourmeter_LO":-9263,"Controller_faults ":0,"item46":0,"alarm_HI":0,"alarm_LO":0,"DIP_switch_positions ":250,"led_state":6,"ChargeState":5,"Target_regulation_voltage":5098,"Ah_charge–resetable":29,"item54":1451,"Ah_charge–total":29,"item56":1451,"kWhr_charge_resetable":2576,"kWhr_charge_total":2576,"Output_Power":4,"Input_Power":0,"Max_Power_of_last_sweep":0,"Vmp_of_last_sweep":3589,"Voc_of_last_sweep":4786,"Reserved20":0,"Min_daily_battery_voltage":4844,"Max_daily_battery_voltage":4907,"Max_daily_input_voltage":7391,"Total_Ah_charge_daily":99,"Total_Wh_charge_daily":270}

Hi I need the FULL msg from the modbus node - not just the payload.

Set the debug coming out of the MODBUS node to "show complete message" then capture data & paste again please.

image

Please do copy debug datas again - as I need to be able to take the raw data out of the MODBUS and the data out of your function at the same poll (so the values match).

Then I will set it up to re-produce your values without all the function nodes.

{"payload":[180,0,80,0,18,0,0,0,4871,4857,49,9,5,6,3,23256,18056,22576,19424,22368,34640,22312,0,29349,4855,4869,4855,34,0,0,23264,18054,22578,19413,22307,25,22,22,4855,14,65535,16206,0,56274,0,0,0,0,250,6,3,0,29,1451,29,1451,2576,2576,0,0,0,3588,4784,0,4844,4907,7391,99,270],"responseBuffer":{"data":[180,0,80,0,18,0,0,0,4871,4857,49,9,5,6,3,23256,18056,22576,19424,22368,34640,22312,0,29349,4855,4869,4855,34,0,0,23264,18054,22578,19413,22307,25,22,22,4855,14,65535,16206,0,56274,0,0,0,0,250,6,3,0,29,1451,29,1451,2576,2576,0,0,0,3588,4784,0,4844,4907,7391,99,270],"buffer":[0,180,0,0,0,80,0,0,0,18,0,0,0,0,0,0,19,7,18,249,0,49,0,9,0,5,0,6,0,3,90,216,70,136,88,48,75,224,87,96,135,80,87,40,0,0,114,165,18,247,19,5,18,247,0,34,0,0,0,0,90,224,70,134,88,50,75,213,87,35,0,25,0,22,0,22,18,247,0,14,255,255,63,78,0,0,219,210,0,0,0,0,0,0,0,0,0,250,0,6,0,3,0,0,0,29,5,171,0,29,5,171,10,16,10,16,0,0,0,0,0,0,14,4,18,176,0,0,18,236,19,43,28,223,0,99,1,14]},"input":{"topic":"polling","from":"","payload":{"unitid":"","fc":3,"address":"0","quantity":"69","messageId":"5f8c00d1f8e1ccf88cf10570"},"queueNumber":0,"queueUnit":1,"queueUnitId":1},"_msgid":"ea94ef7a.79dd1"}
1 Like

You didnt give me both - please read what I write.

I need both debug datas taken from the same poll so I can verify the modifications I do matches your current manual conversions.

Apologies this is the data from the same pole of the function output.

I havent done all the conversions yet, only the ones i am currently using in home assistant.

Going to have to learn how to do the dashboard of that to one day, been spending all my time on functionality, just getting things to work. Been an over 5 year project so far..


{"V_PU_Hi":180,"V_PU_Lo":0,"I_PU_Hi":80,"I_PU_Lo":0,"ver_sw":18,"Reserved1":0,"Reserved2":0,"Reserved3":0,"Reserved4":4871,"Reserved5":4857,"Reserved6":49,"Reserved7":9,"Reserved8":5,"Reserved9":6,"Reserved10":3,"Reserved11":23256,"Reserved12":18056,"Reserved13":22576,"Reserved14":19424,"Reserved15":22368,"Reserved16":-30896,"Reserved17":22312,"Reserved18":0,"Reserved19":29349,"BattVoltsFiltered":26.6693115234375,"BattTermVoltFiltered":26.7462158203125,"BattSenseVolts":26.6693115234375,"ArrayVolts":0.186767578125,"BattCurrentFiltered":0,"ArrayCurrentFiltered":0,"item31":23264,"item32":18054,"item33":22578,"item34":19413,"item35":22307,"HeatsinkTemp":25,"RTS_Temp":22,"BattRegulationTemp":22,"item39":4855,"ChargeCurrentFiltered":0.0341796875,"vb_min":-1,"vb_max":16206,"hourmeter_HI":0,"hourmeter_LO":-9262,"Controller_faults ":0,"item46":0,"alarm_HI":0,"alarm_LO":0,"DIP_switch_positions ":250,"led_state":6,"ChargeState":3,"Target_regulation_voltage":0,"Ah_charge–resetable":29,"item54":1451,"Ah_charge–total":29,"item56":1451,"kWhr_charge_resetable":2576,"kWhr_charge_total":2576,"Output_Power":0,"Input_Power":0,"Max_Power_of_last_sweep":0,"Vmp_of_last_sweep":3588,"Voc_of_last_sweep":4784,"Reserved20":0,"Min_daily_battery_voltage":4844,"Max_daily_battery_voltage":4907,"Max_daily_input_voltage":7391,"Total_Ah_charge_daily":99,"Total_Wh_charge_daily":270}

So some examples of improvements...

Why get HI and LO WORDs separately when you can get a 32bit value


then instead of a function doing this...

var voltscaller = msg.payload.V_PU_Hi + (msg.payload.V_PU_Lo / 65536);
var currentscaller = msg.payload.I_PU_Hi + (msg.payload.I_PU_Lo / 65536);

var battvolts1 = (msg.payload.BattVoltsFiltered * voltscaller)/32768;
var batttermvolts1 = (msg.payload.BattTermVoltFiltered * voltscaller)/32768;
var battsensevolts1 = (msg.payload.BattSenseVolts * voltscaller)/32768;
var arrayvolts = (msg.payload.ArrayVolts * voltscaller)/32768;

msg.payload.BattVoltsFiltered = battvolts1;
msg.payload.BattTermVoltFiltered = batttermvolts1;
msg.payload.BattSenseVolts = battsensevolts1;
msg.payload.ArrayVolts = arrayvolts;


var battcurrent = (msg.payload.BattCurrentFiltered * currentscaller)/32768;
var arraycurrent = (msg.payload.ArrayCurrentFiltered * currentscaller)/32768;
var chargecurrent = (msg.payload.ChargeCurrentFiltered * currentscaller)/32768;

msg.payload.BattCurrentFiltered = battcurrent;
msg.payload.ArrayCurrentFiltered = arraycurrent;
msg.payload.ChargeCurrentFiltered = chargecurrent;

return msg;

you can do this instead...

msg.payload.BattVoltsScaled = (msg.payload.BattVoltsFiltered * msg.payload.voltscaller)/32768;
msg.payload.BattTermVoltScaled = (msg.payload.BattTermVoltFiltered * msg.payload.voltscaller)/32768;
msg.payload.BattSenseVoltsScaled = (msg.payload.BattSenseVolts * msg.payload.voltscaller)/32768;
msg.payload.ArrayVoltScalled = (msg.payload.ArrayVolts * msg.payload.voltscaller)/32768;

msg.payload.BattCurrentFilteredScaled = (msg.payload.BattCurrentFiltered * msg.payload.currentscaller)/32768;
msg.payload.ArrayCurrentFilteredScaled = (msg.payload.ArrayCurrentFiltered * msg.payload.currentscaller)/32768;
msg.payload.chargecurrent = (msg.payload.ChargeCurrentFiltered * msg.payload.currentscaller)/32768;
return msg;


Selecting the correct types for ALL your data entries - check the manual for your device (it should say something like

  • U32 or UINT32 or unsigned integer 32bit or 32bit unsigned number == UINT32
  • or
  • i16 or INT or INT16 or WORD or 16bit number == INT16
    (the (be) part means big endian and (le) means little endian & should be documented in the manual - (just try them both till the data looks correct)
    image


Making use of the features...


Any how, that is enough for now - you seem to be doing fairly well now.

Yes time to get some sleep, work tomorrow.

Any how's, thanks for all your help today, im very happy with the progress made today on the system.

All the best..

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