Settings Modbus TCP USR-DR302

Hello all ,

I am trying to move from serial connection of Modbus to Modbus , TCP,

need some help with the settings:
Using:
USR-DR302

I did the following settings in the module

and the following in HA:

modbus:
  - type: tcp
    host: 192.168.1.7
    port: 501
    switches:
      - name: Switch1
        slave: 3
        address: 1
        write_type: coil
      - name: Switch2
        slave: 3
        address: 2
        write_type: coil
        verify:
      - name: Register1
        address: 11
        command_on: 1
        command_off: 0
        verify:
            input_type: holding
            address: 127
            state_on: 25
            state_off: 1  
  1. how do i know the exact holding register numbers?
  2. Settings seem simply not to work, anyone with experience can assist?
    Cannot make initial connection
modbus modbus_hub communication closed
2:08:16 PM – (WARNING) Modbus
Connection to (192.168.1.7, 501) failed: [Errno 111] Connection refused
2:08:14 PM – (ERROR) /srv/homeassistant/lib/python3.9/site-packages/pymodbus/client/sync.py - message first occurred at 2:05:27 PM and shows up 25 times
Pymodbus: modbus_hub: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.7:501)]
2:05:30 PM – (ERROR) Modbus


I am using a similar USR-TCP232 device. This connects to an ethernet port on my router, and offers two serial ports - RS232 and RS485. It is an ethernet to serial adaptor.

I use the RS485 port to connect to my solar pv inverter RS485 Modbus port. I connect between my HA device to the USR device using Modbus over TCP, and this converts that to Modbus over serial to the inverter. I don’t know about HA Modbus as I am using Node-Red Modbus, which works very well thank you!

OK. So Modbus has ONE master allowed and one to many slaves. Your computer is the master, and whatever it talks to will be the slave, whether this is the end device or an intermediary adaptor. In computer speak, a master is a client (it does the requesting), and a slave is a server (it responds to the requesting).

I think you have your USR device set up for TCP client, so you trying to connect one master to another, which will not work.

My serial adaptor has an IP address (static) and the socket is setup to port 26 as you can see, so my Modbus config node in Node-Red is set to talk to the ip-address of the adaptor, port 26. You have both the HA and your adaptor trying to talk to a (probably mythical) 192.168.1.7:501 that does not exist.

Set the adaptor to IP 192.168.1.7, set the work mode to TCP server, and set a server port 501 then try.

Being the sort of person who reads the manual (cover to cover - dull I know but I find it very useful)
I Goggled DR302 manual, and on page 30 it tells you how to set up a Modbus gateway.

TCP Server - and don’t forget to tick the Modbus TCP (to RTU) option too if that is required. You may have to experiment a bit, which I why I like using Node Red. It is easy to set up a config node, and then a Modbus client node, and the nodes indicate if the connection is alive and working. Makes debugging easier.

thanks I managed to get it to work…
however still stuck with the same problem i had before colis status is not updated online is coil is changed not from HA

Do you have the correct addresses for the slave/unit and the coil/resgister?

Sorry but I can’t help you further. My solar inverter does not have any coil registers. I did try using HA modbus platform but decided that I wanted more control over debugging and Modbus polling rates, so I use Node-Red.

I can only suggest setting up Node-Red (either as an HA add-on or on something else like a Raspberry Pi) and setting up a connection and modbus-getter node. https://community.home-assistant.io/t/modbus-tcp-which-hardware/441823 You can then easily test that the Modbus TCP connection works and then check that you have the right slave/coil address. Error messages in Node-Red are easily visible and quite informative for failed read/write attempts. That would, I think, only leave you with HA yaml configuration as the issue.

The connection is working …now i am using RTUOVERTCP…

But still have the issue where the status is not being updated…
regard node red…

did not try to use it for the modbus…
I am trying to keep system simple as can…
every update cycle things are not working as expected…

now the issue is that my current working version cannot support some other items i want to connect this why i want to resolve the basic status function of the system

Any idea how to understand which register is holding the status of the coil and how to combine it into the coil?

I got input that mention i need to verify section per each coil… not sure if this is the syntax…

assuming

      - name: Switch1
        slave: 3
        address: 0

what would be the right settings for it?

        verify:
      - name: Register1
        address: 11
        command_on: 1
        command_off: 0
        verify:
            input_type: holding
            address: 127
            state_on: 1
            state_off: 0