Hi, this is my code with EspHome. I hope it helps you. Let me know if it’s right for you.
esphome:
name: "chint-meter"
friendly_name: Esp32
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: verbose
baud_rate: 0
#web_server:
#port: 80
# Enable Home Assistant API
api:
encryption:
key: "xxxx"
ota:
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#manual_ip:
#static_ip: 192.168.1.234
#gateway: 192.168.1.254
#subnet: 255.255.255.0
#dns1: 192.168.1.254
#dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32 Fallback Hotspot"
password: "xxxx"
captive_portal:
###
uart:
id: mod_bus
tx_pin: 03
rx_pin: 01
baud_rate: 9600
stop_bits: 1
modbus:
flow_control_pin: 5
id: modbus1
modbus_controller:
address: 0x001
modbus_id: modbus1
update_interval: 1s
setup_priority: -10
sensor:
- platform: modbus_controller
id: chint_voltage
name: "Chint Tensione"
address: 0x2000
unit_of_measurement: "V" ## for any other unit the value is returned in minutes
register_type: holding
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_current
name: "Chint Corrente"
address: 0x2002
unit_of_measurement: "A" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_power
name: "Chint Potenza istantanea"
address: 0x2004
unit_of_measurement: "W" ## for any other unit the value is returned in minutes
state_class: "measurement"
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1000
- platform: modbus_controller
id: chint_frequency
name: "Chint Frequenza Rete"
address: 0x200E
unit_of_measurement: "Hz" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_energy_sold
name: "Chint Energia ceduta"
address: 0x4000
unit_of_measurement: "KWh" ## for any other unit the value is returned in minutes
state_class: total_increasing
device_class: "energy"
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_energy_purchased
name: "Chint Energia acquistata"
address: 0x400A
unit_of_measurement: "KWh" ## for any other unit the value is returned in minutes
state_class: total_increasing
device_class: "energy"
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1
- platform: modbus_controller
id: chint_reactive_power
name: "Chint Potenza reattiva"
address: 0x2004
unit_of_measurement: "Var" ## for any other unit the value is returned in minutes
register_type: read
value_type: FP32
accuracy_decimals: 2
filters:
- multiply: 1000