Modbus TCP Gateway Recommendation

Hi *,

I want to integrate some Modbus devices (e.g. MPPT Controller) into HA.
I ordered a first test subject from waveshare (RS485 To ETH), but I cannot read any value from the device. The manuel mentions some modbus gateway mode which I cannot find in the web UI.

Maybe someone can help with the waveshare device?

Anyways, my actual question is, what modbus TCP gateway devices would you recommend for painless integration into HA?

Best
Ck

3 Likes

I have this converter working with HA for some time. Indeed it was painful to set it up initially, but now works fine.

Mind it’s not Modbus TCP, but RTU over TCP. It’s different thing. Share some screenshots and your HA config.

1 Like

The RS485 To ETH config:



My HA config:

modbus:
  name: ModbusTCPPV
  type: rtuovertcp
  host: 10.4.149.17
  port: 8888 

# Sensors
sensor:

  - platform: modbus
    registers:
      - name: Sensor1_Modbus
        hub: ModbusTCPPV
        unit_of_measurement: V
        slave: 255
        register: 3303

I can send messages but do not receive any. See screenshot 3.
The Modbus integration docs suggest 255 for slave.
register 3303 is in hex notation. I suppose I need decimal notation?

Thanks!

Yes, you need decimal notation.

For the slave number you should have it somewhere in slave documentation. In my case I can see it being called Modbus ID or Modbus address.

2 Likes

Now it is working! Thank you very much. I had the fear that this would also take for ever to set it up. But it works pretty well.

1 Like

I am trying a similar configuration with a temperature sensor, but I have a problem with the “register” value. How can I find her? Where can I read it?
I am using a TTL / RS485 converter and a RS485 converter - Ethernet - Cortex M0 - Waveshare 16529.
For the value “register” 40001 Home Assistant displays the value -1

I have the same converter but cannot make it work.

Can you please share your configuration?

Here is my modbus config in HA:

modbus:
  - name: ModbusTCPPV
    type: rtuovertcp
    host: 10.4.149.17
    port: 8888
    sensors:
      - name: Modbus_PV_Vin
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 12544
        input_type: input
      - name: Modbus_PV_Iin
        unit_of_measurement: A
        scale: 0.01
        precision: 2
        slave: 1
        address: 12545
        input_type: input
      - name: Modbus_PV_Ipow_L
        unit_of_measurement: W
        scale: 0.01
        precision: 2
        slave: 1
        address: 12546
        input_type: input
      - name: Modbus_PV_Ipow_H
        unit_of_measurement: W
        scale: 0.01
        precision: 2
        slave: 1
        address: 12547
        input_type: input
      - name: Modbus_Load_V
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 12556
        input_type: input
      - name: Modbus_Load_I
        unit_of_measurement: A
        scale: 0.01
        precision: 2
        slave: 1
        address: 12557
        input_type: input
      - name: Modbus_Loadpow_L
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 12558
        input_type: input
      - name: Modbus_Loadpow_H
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 12559
        input_type: input
      - name: Modbus_Batt_Temp
        unit_of_measurement: "°C"
        scale: 0.01
        precision: 2
        slave: 1
        address: 12560
        input_type: input
      - name: Modbus_Dev_Temp
        unit_of_measurement: "°C"
        scale: 0.01
        precision: 2
        slave: 1
        address: 12561
        input_type: input
      - name: Modbus_Batt_SOC
        unit_of_measurement: "%"
        slave: 1
        #12570
        address: 12570
        input_type: input
      - name: Modbus_Batt_real_V
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 12573
        input_type: input
      - name: Modbus_Batt_status
        slave: 1
        address: 12800
        input_type: input
      - name: Modbus_Charging_Eqpmnt_status
        slave: 1
        address: 12801
        input_type: input
      - name: Modbus_Discharging_Eqpmnt_status
        slave: 1
        address: 12802
        input_type: input
      - name: Modbus_Batt_Max_V_Today
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 13058
        input_type: input
      - name: Modbus_Batt_Min_V_Today
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 13059
        input_type: input
        #register: 3303
      #holding
      - name: Modbus_Consumed_E_Today_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13060
        input_type: input
      - name: Modbus_Consumed_E_Today_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13061
        input_type: input
      - name: Modbus_Consumed_E_Month_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13062
        input_type: input
      - name: Modbus_Consumed_E_Month_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13063
        input_type: input
      - name: Modbus_Consumed_E_Year_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13064
        input_type: input
      - name: Modbus_Consumed_E_Year_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13065
        input_type: input
      - name: Modbus_Consumed_E_Total_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13066
        input_type: input
      - name: Modbus_Consumed_E_Total_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13067
        input_type: input
      - name: Modbus_Generated_E_Today_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13068
        input_type: input
      - name: Modbus_Generated_E_Today_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13069
        input_type: input
      - name: Modbus_Generated_E_Month_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13070
        input_type: input
      - name: Modbus_Generated_E_Month_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13071
        input_type: input
      - name: Modbus_Generated_E_Year_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13072
        input_type: input
      - name: Modbus_Generated_E_Year_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13073
        input_type: input
      - name: Modbus_Generated_E_Total_L
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13074
        input_type: input
      - name: Modbus_Generated_E_Total_H
        unit_of_measurement: kWh
        scale: 0.01
        precision: 2
        slave: 1
        address: 13075
        input_type: input
      - name: Modbus_Batt_V
        unit_of_measurement: V
        scale: 0.01
        precision: 2
        slave: 1
        address: 13082
        input_type: input
      - name: Modbus_Batt_I_L
        unit_of_measurement: A
        scale: 0.01
        precision: 2
        slave: 1
        address: 13083
        input_type: input
      - name: Modbus_Batt_I_H
        unit_of_measurement: A
        scale: 0.01
        precision: 2
        slave: 1
        address: 13084
        input_type: input


sensor:

  - platform: min_max
    name: min_pv_battery_level
    type: min
    entity_ids:
      - sensor.Modbus_Batt_SOC

And here my gateway config:

Ignore the “Remote Server Addr”. It is wrong since I receive a DHCP lease and this is the default static IP.

1 Like

This config worked for me:

Converter: RS485 TO ETH (B) - Waveshare Wiki
Slave: Rs485 4-20ma Soil Temperature Humidity Moisture Conductivity Ec Ph Sensor - Iot Accessories - AliExpress

Screenshot from VirCon:


(IP is bound with a static lease)

HA:

modbus:
  - name: ModbusGW1
    type: tcp
    host: 0.0.0.0 <put your IP here
    port: 502 <your port
    sensors:
      - name: garten_hecke_sens01_feucht
        device_class: humidity
        unit_of_measurement: "%"
        scale: 0.1
        precision: 1
        slave: 1
        address: 0
        input_type: input
        scan_interval: 600
      - name: garten_hecke_sens01_temp
        device_class: temperature
        unit_of_measurement: "°C"
        scale: 0.1
        precision: 1
        slave: 1
        address: 1
        input_type: input
        scan_interval: 3600
      - name: garten_hecke_sens01_ph
        unit_of_measurement: "pH"
        scale: 0.1
        precision: 1
        slave: 1
        address: 3
        input_type: input
        scan_interval: 3600

Note I added scan_interval, else HA would poll values on a seconds basis, which is useless for my garden application.

Handy tool for checking your bus and what’s on it at what adresses before getting HA into the picture: Download

I am planning to use this to water my garden based on soil humidity instead of some weather based calculations

1 Like

Can you post a ink to the exact product you bought? Was it his one? RS485 to Ethernet Converter

I have a regulator with a RS485 (network like jack) wich I want to get data from. But I dont understand how to connect the one I linked. Do i still use the RS485 port to this gateway?

hello Chris, which MPPT controller did you integrate into HA via Modbus TCP?
SRNE controllers?

Hallo Kollege, ich mal deinen schöne Beispiel Code ĂŒbernommen und bekomme jetzt folgende Fehlermeldung:
“Konfiguration fehlerhaft!
Invalid config for [modbus]: expected int for dictionary value @ data[‘modbus’][1][‘sensors’][9][‘slave’]. Got None string value is None for dictionary value @ data[‘modbus’][1][‘sensors’][9][‘unit_of_measurement’]. Got None. (See /config/configuration.yaml, line 370).”

image

Was mache ich falsch bzw was habe ich vergessen in Zeile 370 ?

Hast Du schon ‘type: rtuovertcp’ ausproviert?

EPEver Tracer5415 and Tracer10420.

danke fĂŒr Tipp :wink:

Hallo Kollege,ich möchte die Daten eines MPPT Laderegler “SRNE ML 4860” (gibt es auch / unter in diversen Varianten / Bezeichnungen) per Modbus TCP mittels WAVESHARE - Gateway ( RS485-TO-ETH) lesen.
Habe mal die Screenshots meiner Einstellung beigefĂŒgt. Vielleicht entdeckt ihr auf Anhieb fehlerhafte Einstellungen die zum Erfolg fĂŒhren könnten
Ich danke euch schon mal ganz ganz herzlich .

I am struggling with a similar issue.

I am using the Waveshare RS232/485/422 TO POE ETH (B)

RS232-485-422_TO_POE_ETH_(B)

This is the config for the unit:

And this is the config in configuration.yaml

modbus:
  - name: modbus_wp
    type: rtuovertcp
    host: 10.7.26.187
    port: 502
    sensors:
      - name: Werkplaats 3-PHASE SYSTEM CURRENT
        unique_id: wp_output_amperage_total
        unit_of_measurement: A
        slave: 3
        address: 23310
        data_type: uint32
        scale: 10
        input_type: input

Anyone who can help me read this value?

I found the address number in the documentation of the unit (ABB M4M)

|Parameter|Unit|Details|Resolution|Data Type|Access|Register (Hex)|Reg (Dec)|
Three phase system current A 0,01 Unsigned Read 5B0E 23310
Current A L1 0,01 Unsigned Read 5B10 23312
Current A L2 0,01 Unsigned Read 5B12 23314
Current A L3 0,01 Unsigned Read 5B14 23316
Current A N 0,01 Unsigned Read 5B16 23318

The solution for the specific device is to only have the RTU framing in ONE place, not twice. This means either:

  • set the “type” in HomeAssistant to “tcp” and enable the Protocol “Modbus TCP to RTU” in the Waveshare bridge
  • OR set the “type” in HomeAssistant to “rtuovertcp” (like in most of the code snippets) and keep the Protocol “None” (Disabled) in the Waveshare bridge

Not both.

Above suggestion by @imalive worked for me as well. Thanks.