- 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.
- 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.