Red Node and modbus

Hello everyone
I am new to this world and would like to learn
I have 2 questions for those who have the patience to teach me

1 has anyone already integrated some device with modbus? Do you have any advice for starting?

2 who can explain or tell me what Red node is and how it works? I think that is what I need to program and interpret the modbus data that I would like to receive from the air conditioner.
If I am wrong, tell me the best way that you consider

Thank you very much

  1. Yes, I use Node-RED with Modbus to read my solar inverter settings.

My advice, for what it is worth, is to break the project into parts and to get “all your ducks in a line” first.

  • you need the Modbus register map and physical connection details for your air conditioner, so check out the manufacture’s information first
  • you need a physical connection between the device to your computer, so decide if you are using serial (RS485) and what adapter and wiring you require to make the connection
  • finally you need some code in Node-RED (the easy part)

On the connection - most devices still use just a serial port offering RS485 connection. If you are lucky, your air conditioner will offer Modbus over TCP (ethernet as wired or wireless) so you can connect directly over TCP. Otherwise, you will need either an RS485 to USB adaptor (goes directly into the computer) or an RS485 to ethernet adapter, which converts Modbus over serial into Modbus over TCP (but make sure the adapter can actually work with Modbus packets and is not just a serial-ethernet adapter).

The hard part is getting the wiring connected between device and adapter and in getting the serial communication settings correct.

  1. Node-RED. Well, there are loads of resources on the internet for learning and starting with Node-RED.

For simplicity, you just need to get Node-RED installed and working. If you have Home Assistant supervised, then NR (Node-RED) is available as an add-on, can be easily installed, and should work ‘out of the box’.

NR is a visual programming language. It works by passing a message between wired-together nodes, each node performing a function (doing something) on the message. NR was designed as a rapid prototyping tool for the IOT world, and is now used industrially, so it is indeed the perfect tool for working with Modbus. Home Assistant can tackle Modbus and pass data into sensors, however NR is (in my opinion) much easier to use and offers greater flexibility.

To read registers (once you have your physical adapter and connection working)

  • Install Node-RED and check it is working
  • Install the node-red-contib-modbus extra nodes you need using the ‘manage palette > install’ option
  • create a new flow, adding the input, modbus, and debug nodes

  • input node, you will use the button to manually trigger the flow
  • modbus flex sequencer node
    • use the + button next to the Server UI field to create a new Modbus Client (you only need to do this once as this is the server that connects NR to your TCP or serial adapter)
    • setup the server for TCP and the IP address and port, or for a serial connection depending on how you are connecting

  • go back to the main sequencer page (with the modbus server now set up) and enter a read sequence of the Modbus register type (function), register address, and count to read
  • add a debug node, wire these together, and deploy

When you press the inject node button, the Modbus server will be used to read the Modbus registers. The output will be either a data array, or array and buffer. You can either use the raw buffer and parse this directly, or just use the data array - each array entry will be the value held in one register. Usually it is now just a task of working out what this number means, eg if decimal degrees, then 589 would be 58.9 degrees C. It is a bit more complicated to deal with signed numbers and double-registers, but you will only need to worry about that when you get this far. You will see from my example above, the data array from 22 to 27 is the date and time.

If (big if) your a/c unit already has Modbus available over TCP and you already have it connected to your home network, once you have Node-RED installed, getting a successful readout should take no time at all.

I hope that this helps you to get started on your project.

1 Like

What can I say? You could not answer better to my request

Hope I don’t bother you if in the future I will ask you more

If you pass trough Italy I will buy you a beer!!