Query modbus registers for SMA Inverter without crash

Hello,
I´m trying to query my SMA Inverters.
When I query 2-4 values, the modbus server crashes always (i tried both Inverters).
the poll rate is 10s

I think the problem could be that nodered queries them all at once, can I set somehow that the values are queried one after the other ?

the data sheet from SMA says that I cound query up to 125 values !
I don´t know where the problem is :sleepy:

Which modbus node are you using? The flows site shows very many options.

Are you performing multiple small reads? When the data sheet says you can query 125 values I would expect that to be a single request for 125 values.

i use "node-red-contrib-modbustcp".

the manual from the modbus inverter:

I don´t know ! I guess NodeRED makes multiple reads so that the Inverter Modbus Server crash.
But how can I make a single request for 5-10 values ?

Hi Becker,

Uninstall modbustcp node and use 'node-red-contrib-modbus' that has more advanced features.
basically you use the modbus-flex-getter node with the following logic setup

your inject node will trigger every x amount of seconds the setup functions that will in turn send request to the Modbus Flex Getter. The request may be simultanious but this will be no problem since in the configuration of the Modbus Flex Getter you set an option to queue the commands. After the reply is then joined together based on topic with the join node.
image

test flow :

[{"id":"8fc91da6.a9e6","type":"modbus-flex-getter","z":"6af7d61.65ee9a8","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"28c906aa.79aae2","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":600,"y":1740,"wires":[["93b4c0bc.489ad"],[]]},{"id":"7012947b.acb93c","type":"function","z":"6af7d61.65ee9a8","name":"","func":"msg.payload = { \n    'fc': 4, \n    'unitid': 1, \n    'address': 0 , \n    'quantity': 2 \n}\nmsg.topic = 'myDevice1'\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":1700,"wires":[["8fc91da6.a9e6"]]},{"id":"edeb5f19.a9fc3","type":"function","z":"6af7d61.65ee9a8","name":"","func":"msg.payload = { \n    'fc': 4, 'unitid': 1, \n    'address': 2 , \n    'quantity': 2 \n} \nmsg.topic = 'myDevice2'\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":1780,"wires":[["8fc91da6.a9e6"]]},{"id":"88de8439.4ef9b8","type":"inject","z":"6af7d61.65ee9a8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1740,"wires":[["7012947b.acb93c","edeb5f19.a9fc3"]]},{"id":"d39e43fb.43c888","type":"debug","z":"6af7d61.65ee9a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":1740,"wires":[]},{"id":"93b4c0bc.489ad","type":"join","z":"6af7d61.65ee9a8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":790,"y":1740,"wires":[["d39e43fb.43c888"]]},{"id":"28c906aa.79aae2","type":"modbus-client","z":"","name":"TCP1","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.1.66","tcpPort":"502","tcpType":"TPC-RTU-BUFFERED","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":200,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true}]

ps. modify the function nodes based on your specific requirements

1 Like

thank you, it seems to work, but I don´t get the value I should get:

I am not sure about the "fc" and "unitid".

This is what I should get for 30865:
grafik

I also have to delete the value for "0", I only need the value for "1" (see my other thread).

sorry, now I got it right

In your Simulator i see Device ID 3 !!
in function you have unitid 1 .. i think you need to change to unitid 3 in function

Its working ?

yes!
Now I need a way to extract only the value "1" from all my registers (topic arrays):
grafik

Try in function address 30866 if you dont need the '0' value and quantity '1'
I dont know why it was giving error in previous modbustcp node .. but try with this new one

regarding getting the values from the message the way it is stuctured now ...
try msg.payload.Pbez[0] if the above works or
msg.payload.Pbez[1]

I doesn´t work this way.

where can I chose [1] ? after "join" a new function ?

yes exactly .. the way you did it in a function node in previous topic :wink:

I dont work:
grafik

I have to extract all the [1]-Data from the join node - but how ?

the "-" was the problem.
"Pbez" works

1 Like

You may find this article from the official documentation interesting
Multiple Outputs (from function nodes)

so you can get all your values first and with the function having multiple outputs, send the appropriate value to the output you want
image

var msg1 = { payload: msg.payload.Pbez[1]};
var msg2 = { payload: msg.payload.UL1[1]};
return [msg1, msg2];

:face_with_monocle: what advantage does it bring

seems to work:
grafik

some values need a extra treatment:

var temp = (msg.payload.UL1[1]) / 100
msg.payload = temp;
msg.payload = msg.payload.toFixed(1).replace('.', ',')
return msg;

not much really .. maybe less clutter on the flow and a few less wires :wink:

nice job .. looks good :+1:t2:

1 Like

@UnborN
there is something wrong with the Join Node:

I can´t add two values, see: Adding two values

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