Hi
I have connected 3 x EM340 modbus energy meters to my RPI4 with a CH340 usbstick.
I have the following code in my configuration.yaml
modbus:
- name: G12A_mod
type: serial
baudrate: 9600
bytesize: 8
method: rtu
retry_on_empty: true
retries: 20
close_comm_on_error: true
message_wait_milliseconds: 40
parity: N
port: /dev/ttyUSB0
stopbits: 1
sensors:
- name: test1
scan_interval: 30
slave: 1
address: 1024
- name: test1_1
scale: 0.001
precision: 3
scan_interval: 30
slave: 1
address: 1026
- name: test2
scan_interval: 30
slave: 2
address: 1024
- name: test3
scan_interval: 30
slave: 3
address: 1024
- name: test2_2
scale: 0.001
precision: 3
scan_interval: 30
slave: 2
address: 1026
- name: test3_3
scale: 0.001
precision: 3
scan_interval: 30
slave: 3
address: 1026
template:
- trigger:
- platform: time_pattern
seconds: "/30"
- sensor:
- name: "meeter2"
state: "{{ states('sensor.test2') | float + states('sensor.test2_2') | float }}"
unit_of_measurement: "kWh"
- sensor:
- name: "meeter1"
state: "{{ states('sensor.test1') | float + states('sensor.test1_1') | float }}"
unit_of_measurement: "kWh"
- sensor:
- name: "meeter3"
state: "{{ states('sensor.test3') | float + states('sensor.test3_3') | float }}"
unit_of_measurement: "kWh"
I get usage in two pices, INT part of usage, and decimal part. I combine it sensor meeter2, which contains of test2 and test2_2
Sometime I see some peaks in values:
My guess would be it take the int part and combine it with the wrong decimal part. In the screen dump my guess is it is 2970 + 0.997 and It should have been 2970 + 0.011
Any ideas to resolve so I ensure it is the correct int and decimal part there are combined ( from same batch of reading), I guess it is because decimal part was not received and the the value before are used.