So what software is providing the modbus server?
node-red acts as the master, making the requests and Arduino as the slave
What software are you running in the Arduino that acts as a modbus slave?
The Smarmengol library
OK i will ask the obvious question here - why Modbus ?
You are introducing complexity here for (no apparent) good reason
YOu have an RS485 connection between the Pi and the Wemos and can run whatever protocols you like across it - Modbus would definitely not be my first choice. And you are using a very old library for this - if you really must stick with Modbus then i would look for something newer
So the first question - why are you doing the comms from the Pi to the Wemos using Modbus ?
Unless you have some really whacky devices - put Tasmota onto the Wemos and use MQTT over WIFI to conrol the Wemos
Craig
Good morning, I'm starting from the assumption that I don't like the wi-fi connection, the choice of this protocol is given by the fact that I carry out readings from a heat pump, extending the protocol to 3 other devices even if the library is old it seems stable in Which alternative do you recommend? However my doubt is but with fc5 in node-red I can't write the bits independently on a word
As has been explained at the start of this thread, the definition of FC5 (Force Single Coil) is that a single address sets or clears the state of a single coil (see https://modbus.org/docs/PI_MBUS_300.pdf). You cannot use FC5 to control 16 outputs with an array of bits. It is not that node-red does not support this, it is that the definition of modbus does not allow it.
Ok Colin meanwhile thank you for your patience, so how can I change the status of the individual bits in a word, because I explain, for the heat pump I have already connected there are words divided into state bits that I can read in the node, so I assume that modbus can handle them, not being very delved into node red how can I do ? It is possible that you have to use a word to activate a relay.... Thank you Mino
Don't do it. Use a separate address for each output.
If you really want to do it then you need to research how to use node red Context to store the current state of the word and then update the relevant bit each time it should change and then write the whole word to modbus. But as I said, don't to it, change what you are doing in the modbus server and use a complete address for each output.
Ok colin, at this point I follow the advice, but out of curiosity as mentioned in the previous message for the heat pump, the word bits manage them individually for that type of cards as the operation is interpreted
Well as you control each end of the link you can do it with a single modbus coil write but it makes little sense
Assumng your Wemos sketch supports 16bit registers for Coils - then presumably it will provide you with an output from the function on the wemos - this output would usually be spat out as a single value (usually Hex) and it is up to you to interpret that in the remainder of your code
As none of us have used the library you have used we have no idea of the capabilities (and as you obviously also do not understand it then it seems stupid to continue)
The reason it works on your heatpump - it has a microprocessor that understands what to do when it receives certain values from your app through modbus - on the wemos you have to write that logic yourself.
Suggest you start here for a smarter/easier way using MQTT over serial - or just do standard serial comms between the Wemos and the PI
Craig
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.