One for the modbus experts

So i’ve been fighting with the Power Meter now which give me RS485 modbus out, or so they say.

For ages I could get NOTHING from this meter, I scanned the entire bus and all device addresses etc, NOTHING.

So, I called the supplied and they supplied me with a tool to test the bus to make sure that it was sending and responding to data, to rule out a faulty meter. And it worked! So its not a faulty meter.

The device address is 1, the registrar im trying to read is 40001, something about a 32bit registrar.

The documentation state a BAUD rate of 9600 so I have to assume that the BAUD is 9600.

Im trying to connect with this method.

image

Connected to a ESP32 TX2 and RX2 pins. Still, I get nothing from it. - RX and TX reversed.

The meter is a DDS-1Y-36L-80A-M and more info can be found here! Please can someone help me with this, ive been going at this for 1 month now.

[23:24:34][C][ota:093]: Over-The-Air Updates:
[23:24:34][C][ota:094]:   Address: modbus.local:3232
[23:24:34][C][ota:097]:   Using Password.
[23:24:34][C][api:138]: API Server:
[23:24:34][C][api:139]:   Address: modbus.local:6053
[23:24:34][C][api:141]:   Using noise encryption: YES
[23:24:34][C][modbus_controller:275]: ModbusController:
[23:24:34][C][modbus_controller:276]:   Address: 0x01
[23:24:34][C][modbus_controller:278]: sensormap
[23:24:34][C][modbus_controller:282]:  Sensor type=4 start=0x1 offset=0x0 count=1 size=2
[23:24:34][C][modbus_controller:282]:  Sensor type=4 start=0x9C41 offset=0x0 count=1 size=2
[23:24:34][C][modbus_controller:284]: ranges
[23:24:34][C][modbus_controller:287]:   Range type=4 start=0x1 count=1 skip_updates=0
[23:24:34][C][modbus_controller:287]:   Range type=4 start=0x9C41 count=1 skip_updates=0
[23:24:53][VV][api.service:512]: on_ping_request: PingRequest {}
[23:24:53][VV][api.service:043]: send_ping_response: PingResponse {}
[23:25:05][VV][scheduler:226]: Running interval 'update' with interval=60000 last_execution=701072 (now=761073)
[23:25:05][V][modbus_controller:158]: Updating modbus component
[23:25:05][VV][modbus_controller:162]: Updating range 0x1
[23:25:05][V][modbus_controller:125]: Range : 1 Size: 1 (4) skip: 0
[23:25:05][VV][modbus_controller:162]: Updating range 0x9C41
[23:25:05][V][modbus_controller:125]: Range : 9C41 Size: 1 (4) skip: 0
[23:25:05][V][modbus_controller:036]: Sending next modbus command to device 1 register 0x01 count 1
[23:25:05][VV][uart.arduino_esp32:151]:     Flushing...
[23:25:05][V][modbus:199]: Modbus write: 01.04.00.01.00.01.60.0A (8)
[23:25:05][V][modbus_controller:486]: Command sent 4 0x1 1
[23:25:05][V][modbus_controller:036]: Sending next modbus command to device 1 register 0x01 count 1
[23:25:05][VV][uart.arduino_esp32:151]:     Flushing...
[23:25:05][V][modbus:199]: Modbus write: 01.04.00.01.00.01.60.0A (8)
[23:25:05][V][modbus_controller:486]: Command sent 4 0x1 1
[23:25:06][V][modbus_controller:036]: Sending next modbus command to device 1 register 0x01 count 1
[23:25:06][VV][uart.arduino_esp32:151]:     Flushing...
[23:25:06][V][modbus:199]: Modbus write: 01.04.00.01.00.01.60.0A (8)
[23:25:06][V][modbus_controller:486]: Command sent 4 0x1 1
[23:25:06][V][modbus_controller:036]: Sending next modbus command to device 1 register 0x01 count 1
[23:25:06][VV][uart.arduino_esp32:151]:     Flushing...
[23:25:06][V][modbus:199]: Modbus write: 01.04.00.01.00.01.60.0A (8)
[23:25:06][V][modbus_controller:486]: Command sent 4 0x1 1
[23:25:06][V][modbus_controller:036]: Sending next modbus command to device 1 register 0x01 count 1
[23:25:06][VV][uart.arduino_esp32:151]:     Flushing...
[23:25:06][V][modbus:199]: Modbus write: 01.04.00.01.00.01.60.0A (8)
[23:25:06][V][modbus_controller:486]: Command sent 4 0x1 1
[23:25:06][D][modbus_controller:032]: Modbus command to device=1 register=0x01 countdown=0 no response received - removed from send queue

Here is the YAML on ESP32

esphome:
  name: modbus
  friendly_name: modbus

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  level: VERY_VERBOSE

uart:
  id: mod_bus
  tx_pin: 17
  rx_pin: 16
  baud_rate: 9600
  stop_bits: 1

modbus:
  flow_control_pin: 5
  id: modbus1

modbus_controller:
  - id: epever
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10

captive_portal:
    
sensor:
  - platform: modbus_controller
    id: power_meter
    name: "power_meter"
    address: 1
    unit_of_measurement: "kWh"
    register_type: read
    value_type: U_DWORD
    filters:
      - multiply: 0.1

Modbus RTU default format:
9600 Baud, 8 bit no parity 1 stop bit.
First word high in 32 bit data types.
Registers
Register address Register name Unit Data type
40001-40002 Total active energy
7 digits max. 9999999
0.1kWh Unsigned 32 bit
40007 (write only) Node address (1 to 247) Address Unsigned 16 bi

sensor:
  - platform: modbus_controller
    id: power_meter
    name: "power_meter"
    address: 1 # or 0
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_DWORD
    register_count: 2
    filters:
      - multiply: 0.1

Thanks, but I still get

[22:33:40][D][uart_debug:114]: >>> 01:03:00:01:00:02:95:CB
[22:33:40][D][modbus_controller:032]: Modbus command to device=1 register=0x01 countdown=0 no response received - removed from send queue
uart:
  id: mod_bus
  tx_pin: 17
  rx_pin: 16
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  debug:
    direction: BOTH
modbus:
 # flow_control_pin: 5
  id: modbus1

modbus_controller:
  - id: epever
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10
sensor:
  - platform: modbus_controller
    id: power_meter
    name: "power_meter"
    address: 1 # or 0
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_DWORD
    register_count: 2
    filters:
      - multiply: 0.1
sensor:
  - platform: modbus_controller
    id: power_meter
    name: "power_meter"
    address: 0x0000
    unit_of_measurement: "kWh"
    register_type: holding
    value_type: U_DWORD
    register_count: 2
    filters:
      - multiply: 0.1

Connected to a ESP32 TX2 and RX2 pins. Still, I get nothing from it. - RX and TX reversed.

Tx - Tx
Rx - Rx
A - A
B - B

So don’t reverse RX and TX? :roll_eyes:

So don’t reverse RX and TX? :roll_eyes:

No

You dont need flow control pin

modbus:
  #flow_control_pin: 5
  id: modbus1
1 Like

how in earth does that work?

It’s how ttl-rs485 work

Ok bugger, swapped and same thing.

[23:16:40][D][uart_debug:114]: >>> 01:03:00:01:00:02:95:CB
[23:16:41][D][modbus_controller:032]: Modbus command to device=1 register=0x01 countdown=0 no response received - removed from send queue

Tx led in rs485 blinks?

Yes it does blink

You need found the correct address:

0x0000
0x0001

0x9C40
0x9C41

read or holding

4xxxx it’s holding but…

So 40001 and 40002 according to the manual

I believe that 40001 & 40002 is the standard Modicon addressing


So the registers should be 1 & 2 but as the image above states, the Modicon numbering convention is offset from Mobus protocol by 1 so the address is 0 & 1.

I agree with Nikito7 here. This should work if all connections are correct.

They do mention BTW that it is a 32bit value

You need test to find correct first register

@nikito7 I have been working through this with Dean and he got some help from the supplier.
With a 485 to USB stick and a python script, he got it to work with the Modbus power meter and was getting power readings.

Modbus address is confirmed as 1 for the unit and the register is 40001 (Modicon PLC addressing).
I have not had any experience with the ESPhome Modbus integration but your suggested code looks correct with 0 as the register address and U_DWORD to catch the 32 bit reply.

He has tried swapping the A & B ports on the 485 converter as well as the RX & TX ports on the ESP board in both combinations with no luck.

Any other suggestions that Dean could try?

Try with gpio 18 and 19

What is your current yaml?

uart:

# esp32 19/18
# esp8266 3/1

  id: modbus_serial
  rx_pin: 3
  tx_pin: 1
  baud_rate: 9600
  stop_bits: 1

modbus:

  #flow_control_pin: 5
  id: modbus1
  uart_id: modbus_serial

modbus_controller:

  - id: edpbox
    update_interval: 10s
    address: 0x1
    command_throttle: 150ms
    setup_priority: -10

voltage drop?.. try powering the transceiver with 5v and level shifting the TX/RX ( or use heavier gauge signal wires ) down to 3.3, (or just a divider on RX)