Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RS485 modbus energy meter integrate to ESPHome yaml file for home assistant
#1
   
   

esphome:
  name: a8s
  platform: ESP32
  board: esp32dev
 
wifi:
  ssid: "KinCony"
  password: "a12345678"

captive_portal:


uart:
  id: mod_bus
  tx_pin: 33
  rx_pin: 32
  baud_rate: 9600
  stop_bits: 1
  parity: EVEN

modbus:
  id: modbus1
  uart_id: mod_bus

modbus_controller:
  - id: a8s
    address: 0x01
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 5s


sensor:
  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Voltage"
    id: modbus_voltage
    register_type: holding
    address: 0x64
    unit_of_measurement: "V"
    value_type: FP32
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Current"
    id: modbus_current
    register_type: holding
    address: 0x6A
    unit_of_measurement: "A"
    value_type: FP32
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Active Power"
    id: modbus_Active_Power
    register_type: holding
    address: 0x76
    unit_of_measurement: "kW"
    value_type: FP32
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Power Factor"
    id: modbus_Power_Factor
    register_type: holding
    address: 0x8E
    unit_of_measurement: ""
    value_type: FP32
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Grid Frequency"
    id: modbus_Grid_Frequency
    register_type: holding
    address: 0x90
    unit_of_measurement: "hz"
    value_type: FP32
    accuracy_decimals: 2

  - platform: modbus_controller
    modbus_controller_id: a8s
    name: "Total Energy"
    id: modbus_Total_Energy
    register_type: holding
    address: 0x0
    unit_of_measurement: "kWh"
    value_type: FP32
    accuracy_decimals: 2

# Enable logging
logger:

# Enable Home Assistant API
api:

yaml file for KC868-A8S download:

.txt   HA_modbus_energy-meter.txt (Size: 1.91 KB / Downloads: 654)

KinCony energy meter RS485 modbus protocol document:

.pdf   KinCony-energy-meter-rs485-modbus-protocol.pdf (Size: 117.75 KB / Downloads: 762)
Reply
#2
Hello,

Is it possible to use RS485 on the KC868-A8S to read data according to IEC 62056-21, mod C , 7E1 via ESPHome? It is not Modbus RTU.

Thank you
Reply
#3
i am not sure whether ESPHome support that protocol, i think it's not easy, suggest use by modbus.
Reply
#4
Hi!

Do you have ESPHome sample configuration for Kincony 3-phase RS485 energy meter? Model KC868-Meter-7P-RTU
Reply
#5
you can see this video:
 
Reply
#6
Hi, trying to set this up  to work in a KC868-Server. I'm having a few issues:

Error:
[09:17:47][D][modbus_controller:043]: Modbus command to device=1 register=0x76 countdown=0 no response received - removed from send queue
[09:17:48][W][modbus_controller:136]: Duplicate modbus command found: type=0x3 address=142 count=4

Config attached: config_modbus.txt

Photo attached of wiring. 

Thank you


Attached Files Image(s)
   

.txt   config_modbus.txt (Size: 1.84 KB / Downloads: 89)
Reply
#7
because now will begin China new year holidays soon, when we have free time, will test it. maybe can make a YouTube video tour for you.
Reply
#8
(01-27-2024, 06:50 AM)admin Wrote: because now will begin China new year holidays soon, when we have free time, will test it. maybe can make a YouTube video tour for you.

Tried re-setting the address to 222 (0xDE) but and also inverting tx with rx pins but got the same results ... any help will be much appreciated.
Reply
#9
here is my KC868-Server config yaml for KinCony's modbus energy meter:

.txt   KinCony_modbus_meter.txt (Size: 1.43 KB / Downloads: 110)

modbus:
  - name: hub1
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: E
    port: /dev/ttyS0
    stopbits: 1

    sensors:
    - name: meter-voltage
      slave: 1
      address: 100
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: V
      device_class: voltage

    - name: meter-current
      slave: 1
      address: 106
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: A
      device_class: current

    - name: meter-power
      slave: 1
      address: 118
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: kW
      device_class: power
     
    - name: meter-factor
      slave: 1
      address: 142
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
    #  unit_of_measurement:
      device_class: power_factor

    - name: meter-frequency
      slave: 1
      address: 144
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: Hz
      device_class: frequency

    - name: meter-consumption
      slave: 1
      address: 0
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: kWh
      device_class: energy_storage
Reply
#10
(02-02-2024, 11:45 AM)admin Wrote: here is my KC868-Server config yaml for KinCony's modbus energy meter:


modbus:
  - name: hub1
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: E
    port: /dev/ttyS0
    stopbits: 1

    sensors:
    - name: meter-voltage
      slave: 1
      address: 100
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: V
      device_class: voltage

    - name: meter-current
      slave: 1
      address: 106
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: A
      device_class: current

    - name: meter-power
      slave: 1
      address: 118
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: kW
      device_class: power
     
    - name: meter-factor
      slave: 1
      address: 142
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
    #  unit_of_measurement:
      device_class: power_factor

    - name: meter-frequency
      slave: 1
      address: 144
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: Hz
      device_class: frequency

    - name: meter-consumption
      slave: 1
      address: 0
      input_type: holding
      data_type: float32
      count: 2
      precision: 2
      unit_of_measurement: kWh
      device_class: energy_storage

I had to remove lines including count: 2 for config to work.

Once valid config I don't see values displayed, see attachment please.

After enabling DEBUG for modbus I see:
2024-02-02 14:06:39.383 ERROR (SyncWorker_10) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 100 -> Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 4 bytes (0 received)
2024-02-02 14:07:14.617 DEBUG (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 106 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response
2024-02-02 14:07:49.853 DEBUG (SyncWorker_12) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 118 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response
2024-02-02 14:08:25.093 DEBUG (SyncWorker_11) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 142 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response
2024-02-02 14:09:00.336 DEBUG (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 144 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response
2024-02-02 14:09:35.573 DEBUG (SyncWorker_10) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 0 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response
2024-02-02 14:10:10.813 DEBUG (SyncWorker_12) [homeassistant.components.modbus.modbus] Pymodbus: hub1: Error: device: 1 address: 100 -> Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response


Attached Files Image(s)
   
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)