Yesterday my colleague Lucian asked me if I could help him out with controlling a frequency converter via Node-RED. It was a BDI50 that could talk Modbus over an USB to serial cable. Lucian already managed to talk to the device when connecting it to his windows pc. So we were sure that the setup ought to work.
Getting this to work from a Cerbo GX running Node-RED proved a bit more difficult then expected. And describing where we bumped into and how we managed to solve the issues might help others. Hence this article.
For too long time we overlooked the fact that any serial device that gets plugged into a GX device gets claimed by the serial-starter process. Normally Venus OS wants to talk to any devices that get plugged into it, so first and most important task was to make sure that the device was not claimed. How to do that is described on https://github.com/victronenergy/venus/wiki/howto-add-a-driver-to-Venus#howto-make-serial-starter-ignore-certain-usb-types.
After reading those instructions, it turned out that the cable is just another ftdi cable and therefor cannot be easily uniquely identified. This was solved by using the FTProg utility that allows changing the product description. When that was done, the device model became FreqencyConverter, which is definitely unique because of the typo. :)
Then the following line could to be added to /etc/udev/rules.d/serial-starter.rules:
ACTION==“add”, ENV{ID_BUS}==“usb”, ENV{ID_MODEL}==“FreqencyConverter”, ENV{VE_SERVICE}=“ignore”
Note that adjusting the file does require ssh access to the device, which is described here: https://www.victronenergy.com/live/ccgx:root_access.
After that had been done, reading and writing to the device from Node-RED was not that hard anymore. From the palette manager, the node-red-contrib-modbus nodes needed to be installed.
Then the Modbus client connection needed to be configured. It is important to get all of these settings correct. In this case they could be configured on the BDI50 device. In other cases the settings should be in the manual of the device.
Reading the correct register could then be done with the Modbus read node:
Resulting in the following flow:
The filter is just there to pass through only changed values.
4 files