serkri / SmartEVSE-3

Smart Electric Vehicle Charging Station (EVSE)
MIT License
68 stars 28 forks source link

Feature request, read all modbus meters and also log voltage, cos phi etc #132

Open fluppie opened 1 year ago

fluppie commented 1 year ago

Currently I have a ESP32 with modbus shield from enri.nl to read all parameters / all modbusmeters. This gives 2 modbus masters which is far from ideal. I don't know if it's a lot of work to read out more registers than current and power as well as kWh import / export.

Screenshot of the ESP32 with ESPEasy software: afbeelding

The Nan values are because of modbus collisions. I think the SmartEVSE is requesting every 2 seconds data on the modbus. My mainsmeter is at 15s intervals and the PV and EV meter are at 60s intervals. To limit the number of collisions.

List with all available registers: https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h

afbeelding

Just a question, if not I keep using it like this. On the other hand I can save a ESP32, a 5V power supply and modbus collisions :).

Ferforfaen commented 1 year ago

I would love that!

I have tried to do readouts with two masters, but failed.

dingo35 commented 1 year ago

I am thinking about a sort of configurable gateway from modbus to REST API....

fluppie commented 1 year ago

Or an implementation of Modbus TCP, so all Modbus RTU devices can also be read/controlled over Modbus TCP. But I think it would be enough to go full read-out with SmartEVSE v3 and then using the REST API to send Modbus meter data to Home Assistant or other HA systems. I do like the fact that inter SmartEVSE communication is RTU RS485, so Sensorbox can be far away of the SmartEVSE or for example one electrical cabinet with 4 SmartEVSE's talking to another board with 4 EVSE's 20-30m away. Same story for the sensorbox. In large industrial sites the main board where power from the netdistributor or own local transformator can be quite far away from the electrical cabinets with SmartEVSE's.

dingo35 commented 1 year ago

modbus-tcp-bridge.zip

In this version your MainsMeter, EVMeter and PVMeter present themselves at port 502 of your SmartEVSE, with the modbus-tcp protocol; so this makes it possible for you to use whatever modbus function you want on whatever modbus register you want. E.g. my MainsMeter is at slave address 0x0a, so this command reads register 70decimal and following: mbpoll -a10 -t 3:hex -r 70 -c 10 10.0.0.76

Please test, have fun!

fluppie commented 1 year ago

Looks like it's working can it interfere with the SmartEVSE RTU modbus polling? I mean can the TCP requests from HA happen on the same time as the SmartEVSE is polling this data from the RTU modbus? afbeelding

Because sometimes I see this: afbeelding

Home Assistant yaml config

modbus: 
  - type: tcp
    host: 192.168.1.119 # ip van smartevse v3
    port: 502
    name: "smartevsev3modbustcp"
    close_comm_on_error: true
    delay: 3
    timeout: 5
    sensors:
      - name: sdm230_phase_1_line_to_neutral_volts
        slave: 101
        address: 0
        input_type: input
        count: 2
        precision: 2
        data_type: float32
        unit_of_measurement: V
        device_class: voltage
        scan_interval: 10
      - name: sdm230_phase_1_current
        slave: 101
        address: 6
        input_type: input
        count: 2
        precision: 2
        data_type: float32
        unit_of_measurement: A
        device_class: current
        scan_interval: 10
      - name: sdm230_phase_1_power
        slave: 101
        address: 12
        input_type: input
        count: 2
        precision: 3
        data_type: float32
        unit_of_measurement: W
        device_class: power
      - name: sdm230_phase_1_va
        slave: 101
        address: 18
        input_type: input
        count: 2
        precision: 2
        data_type: float32
        unit_of_measurement: VA
        device_class: power
dingo35 commented 1 year ago

Thats why I ask you to test it thoroughly: it uses the same client (=modbus server) as the rest of the firmware, so I would expect no collisions. But I enabled modbus lowlevel error routine, so if you have telnet log running you should see no timeout or other modbus errors...

fluppie commented 1 year ago

Without disconnecting the second ESP32 module with ESPEasy firmware, CRC errors 99% sure coming from the second modbusmaster trying to fetch data:

(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -9.6 A L2: 0.0 A L3: 0.0 A Isum: -9.6 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -9.6 A L2: 0.0 A L3: 0.0 A Isum: -9.6 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -9.6 A L2: 0.0 A L3: 0.0 A Isum: -9.6 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E2 - CRC check error
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E4 - Server ID mismatch
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -9.6 A L2: 0.0 A L3: 0.0 A Isum: -9.6 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout

After disconnecting the second ESP32 modbus device:

(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.5 A L2: 0.0 A L3: 0.0 A Isum: -6.5 A
(MBhandleError)(C0) Error response: E0 - Timeout
(loop)(C1) 0 clients running.
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.5 A L2: 0.0 A L3: 0.0 A Isum: -6.5 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.4 A L2: 0.0 A L3: 0.0 A Isum: -6.4 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.5 A L2: 0.0 A L3: 0.0 A Isum: -6.5 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.6 A L2: 0.0 A L3: 0.0 A Isum: -6.6 A
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(MBhandleError)(C0) Error response: E0 - Timeout
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -6.5 A L2: 0.0 A L3: 0.0 A Isum: -6.5 A
(MBhandleError)(C0) Error response: E0 - Timeout

afbeelding

dingo35 commented 1 year ago

Ok going to try second setup... stay tuned!

dingo35 commented 1 year ago

modbus-tcp-bridge2.zip This any better?

fluppie commented 1 year ago

No, E0 Time out remains. I also have the impression I see more "niet beschikbaar" when monitoring the sensors. What parameter(s) did you change? afbeelding

dingo35 commented 1 year ago

I did add another, separate client for the TCP bridge.

Now are you polling the extra registers you requested or are you also polling the registers that are already available through the REST API? Because that would definitely mess up traffic on the bus....

dingo35 commented 1 year ago

When I try to copy your setup, I get this error in HomeAssistant: WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.sdm230_phase_1_va (<class 'homeassistant.components.modbus.sensor.ModbusRegisterSensor'>) is using native unit of measurement 'VA' which is not a valid unit for the device class ('power') it is using; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+modbus%22

And also, every 30 seconds I get this: May 2 07:28:24 backupserver hass[30207]: 2023-05-02 07:28:24.716 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: smartevsev3modbustcp: Exception Response(132, 4, None)

When I comment out the device_class: power of this sensor, both messages are gone. I still get an occasional timeout in telnet but not as many as you do .... would this change anything in your setup?

EDIT: Testing with the FIRST firmware file modbus-tcp-bridge.zip since this makes more sense.

dingo35 commented 1 year ago

I cannot get the timeouts reproduced in my setup; I get an occasional timeout, but this is not often enough to do some decent testing.

I can see the following test scenarios: 1) I can compile a 1.6.1 version (without the modbus TCP bridge) that has the Modbus error messages enabled (for some reason they were disabled until now), to make sure you didn't have timeout messages all the time (without the bridge component) 2) You can add some statements to your configuration.yaml to see if this has any influence:

This represents your setup, if you use the commented parameters this might improve the behaviour of HomeAssistant.

Let me know which way you want to go....

dingo35 commented 1 year ago

For test scenario 1 you can use https://github.com/serkri/SmartEVSE-3/releases/tag/v1.6.2

since it has no modbus TCP bridge, but it does have the extended log messages for modbus errors.

fluppie commented 1 year ago

OK great, will look into this. Possible that the current 1.6.2 release has Telnet disabled?

dingo35 commented 1 year ago

You've got to rename firmware.debug.bin to firmware.bin

deekoowee commented 1 year ago

This is interesting. Modbus TCP could be also a solution to my #121

Could it be possible to have modbus TCP addressing for the meters ?

I have tested the Elfin EW11 devices to convert modbus RTU to modbus TCP. EW11 is modbus bridge and can serve the data to several TCP ports.

dingo35 commented 1 year ago

It would not solve the problem that your MainsMeter is fixed as slave at address 1, and SmartEVSE is fixed as master at address 1.

fluppie commented 1 year ago

Finally had some time to flash the debug version (from the now pulled 1.6.2) , stupid me, not checking the whole folder contents...

(D) (CalcBalancedCurrent)(C0) Balance: EVSE0:A(0.0A),EVSE1:A(0.0A),EVSE2:A(0.0A),EVSE3:A(0.0A),EVSE4:A(0.0A),EVSE5:A(0.0A),EVSE6:A(0.0A),EVSE7:A(0.0A),
(D) (ModbusWriteMultipleRequest)(C0) Sent packet(ModbusWriteMultipleRequest)(C0) address: 09, function: 0x10, reg: 0020, count: 8, values: 0000 0000 0000 0000 0000 0000 0000 0000 019c 0021 0000 0021 0000 0000 014a 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 .
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.3 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.3 A L2: 0.0 A L3: 0.0 A Isum: 3.3 A
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (Timer100ms)(C0) ModbusRequest 3: Request MainsMeter Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 65, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 65 04 18 40 56 e6 f5 00 00 00 00 00 00 00 00 44 17 a1 9f 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 65 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 5: Request Energy Node 0
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0048, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 45 98 0d 3f
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0048(ModbusDecode)(C0)  Response
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 000c, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 000c(ModbusDecode)(C0)  Response
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 02, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 03, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 04, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 05, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 06, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 07, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 08, function: 04, reg: 0000, data: 0008.
(MBhandleError)(C0) Error response: E0 - Timeout
(D) (Timer100ms)(C0) ModbusRequest 21: Request EVMeter Current Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 66 04 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(V) (CalcBalancedCurrent)(C0) Checkpoint 1 Isetbalanced=41.2 A Imeasured=3.3 A MaxCircuit=33 Imeasured_EV=0.0 A, Battery Current = 0.0 A, mode=1.
(V) (CalcBalancedCurrent)(C0) Checkpoint 2 Isetbalanced=41.2 A, Idifference=33.0, mod=0.
(V) (CalcBalancedCurrent)(C0) Checkpoint 4 Isetbalanced=41.2 A.
(V) (CalcBalancedCurrent)(C0) Checkpoint 5 Isetbalanced=41.2 A.
(D) (CalcBalancedCurrent)(C0) Balance: EVSE0:A(0.0A),EVSE1:A(0.0A),EVSE2:A(0.0A),EVSE3:A(0.0A),EVSE4:A(0.0A),EVSE5:A(0.0A),EVSE6:A(0.0A),EVSE7:A(0.0A),
(D) (ModbusWriteMultipleRequest)(C0) Sent packet(ModbusWriteMultipleRequest)(C0) address: 09, function: 0x10, reg: 0020, count: 8, values: 0000 0000 0000 0000 0000 0000 0000 0000 019c 0021 0000 0021 0000 0000 014a 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 .
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.3 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.3 A L2: 0.0 A L3: 0.0 A Isum: 3.3 A

Second ESP32 modbus module is disconnected. So don't really get why I get the timeouts. My meters have 101, 102, 103 and 104 as modbus address.

fluppie commented 1 year ago

Got it, it's because Load balancing is set to master and no slaves are connected. In the past we had to this to get the Circuit menu option. In newer releases this is not needed anymore, disabling this fixed the timeouts :).

dingo35 commented 1 year ago

Ok thx for discovering this. So does this also solve your timeout problems for modbus-tcp-bridge.zip?

fluppie commented 1 year ago

Yes exactly. I used your first tcp build. These time-outs are just 7 messages to send to all 7 slaves. And since there are none, these don’t get received/acked. With verbose on my “euro” fell… This weekend I’ll add more meters and see what happens. Good stuff!

dingo35 commented 1 year ago

I have a nice weekend present for you, this version has the problems in 1.6.2 fixed, and also has added detailed logging to the timeout/other modbus error messages; thanks to your trick to put LoadBl = 1 I could test this now!

In normal logging the timeout-messages to the slaves are suppressed, in verbose logging they are still shown... Also a broadcast message that times out will show up if you have loadbalancing enabled without extra EVSE's connected, this one is not suppressed since it is not that annoying...

Let me know what happens if you add more meters! modbus-tcp-bridge3.zip

fluppie commented 1 year ago

afbeelding This is fun, so address 101 and 102 are known by the SmartEVSE. Modbus address 103 (solar kWh meter) and 104 (EV2 kWh meter) are not used/known by SmartEVSE. Is it a pure coincidence that these addresses are not read? Or is the SmartEVSE actively blocking all modbus traffic except messages coming from known addresses? Load balancing is disabled.

dingo35 commented 1 year ago

Currently only traffic for the MainsMeter address, the EVmeter address and the PVmeter address is forwarded.

The forwarding has to be configured per address at the RTU modbus, so if you want more addresses to be read a config routine has to be built...

fluppie commented 1 year ago

Yes, would be nice if we could add addresses to the list. I also think PV_Meter / PVmeter is not used anymore. I'm not able to find the menu option for it, I can remember with a v2 or v3 with original firmware this menu item was somewhere. Only MainsM and EVM show up.

dingo35 commented 1 year ago

I think it depends on the setting MainsMeterMeasure...

fluppie commented 1 year ago

Indeed, you can enable it by changing in the menu what the mains meter measures. afbeelding

Would you need to add menu's like "Extra kWh meter 1" "Extra kWh meter 2" etc? So you can also put more modbus devices in. I have a second SmartEVSE with also an EV meter for the second (future) EV. How will that work out when they are in master/slave, for now they're not linked/used. Does the master SmartEVSE fetch the modbus data of EV Meter 2 or will the slave do that on his own? Or should I just wire up everything and see what happens :).

fluppie commented 1 year ago

Looks like I can't use the mainsmeter setting with PV :). Purple is sensorbox data to my second SmartEVSE (for now a separate modbus network) and blue the data from the first SmartEVSE with several SDM230's. afbeelding

Yesterday was with the old working settings, then the data is very similar.

Can I see anywhere what kind of code you added to make the TCP Modbus server?

dingo35 commented 1 year ago

I pushed the code to master, Im thinking of detecting TCP requests that are not yet forwarded and opening a forward for them dynamically; not sure if it can be done simply in the emodbus library...

fluppie commented 1 year ago

Ok cool. So maybe something like could be enough to get it working?


MBbridge.attachServer(Extra1MeterAddress, Extra1MeterAddress, ANY_FUNCTION_CODE, &MBclient);
MBbridge.attachServer(Extra2MeterAddress, Extra2MeterAddress, ANY_FUNCTION_CODE, &MBclient);
dingo35 commented 1 year ago

Yes that would to it, but I dont want to clutter the user interface with this stuff. Any normal user would not understand, it would generate a lot of unnecessary questions...

fluppie commented 1 year ago

Yes that works indeed, changed the mainsmeter back to "all" so PV meter doesn't work anymore.

uint8_t Extra1MeterAddress = 103;
uint8_t Extra2MeterAddress = 104;
MBbridge.attachServer(Extra1MeterAddress, Extra1MeterAddress, ANY_FUNCTION_CODE, &MBclient);
MBbridge.attachServer(Extra2MeterAddress, Extra2MeterAddress, ANY_FUNCTION_CODE, &MBclient)

afbeelding

Any way we can make this configurable via HTTP commands? Some advanced functionality for users who want more :-D.

dingo35 commented 1 year ago

That might be one way to go. Cannot test myself right now, but if you put logging at verbose, and you request a non-existing slave address through the TCP interface, does that generate an error message on the telnet interface on that address?

dingo35 commented 1 year ago

Or perhaps make an auto-discover routine that discovers all the devices on the modbus...

fluppie commented 1 year ago

How to build the firmware.debug.bin version? I just did, project tasks, release, build.

fluppie commented 1 year ago

Got it, DBG 1 in evse.h

I commented one Extrameter1 67/103 out but keep requesting via HomeAssistant. Extrameter2 = 68/104 Looks like the working Extrameter2 is not showing up in the logs. Address 65 = 101 (Mains Meter) and 66 = 102 (EV Meter) Same for the not working Extrameter1, no signs of this in the logs.

(D) (Timer100ms)(C0) ModbusRequest 3: Request MainsMeter Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 65, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 65 04 18 40 3f 58 a1 00 00 00 00 00 00 00 00 c3 fd e9 02 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 65 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 5: Request Energy Node 0
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0048, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 45 98 0d 3f
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0048(ModbusDecode)(C0)  Response
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 000c, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 000c(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 21: Request EVMeter Current Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 66 04 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(V) (CalcBalancedCurrent)(C0) Checkpoint 1 Isetbalanced=41.2 A Imeasured=0.0 A MaxCircuit=33 Imeasured_EV=0.0 A, Battery Current = 0.0 A, mode=1.
(V) (CalcBalancedCurrent)(C0) Checkpoint 2 Isetbalanced=41.2 A, Idifference=33.0, mod=0.
(V) (CalcBalancedCurrent)(C0) Checkpoint 4 Isetbalanced=41.2 A.
(V) (CalcBalancedCurrent)(C0) Checkpoint 5 Isetbalanced=41.2 A.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -2.9 A L2: 0.0 A L3: 0.0 A Isum: -2.9 A
(D) (Timer100ms)(C0) ModbusRequest 3: Request MainsMeter Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 65, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 65 04 18 40 3f ef c7 00 00 00 00 00 00 00 00 c3 ff 2a 62 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 65 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 5: Request Energy Node 0
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0048, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 45 98 0d 3f
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0048(ModbusDecode)(C0)  Response
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 000c, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 000c(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 21: Request EVMeter Current Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 66 04 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(V) (CalcBalancedCurrent)(C0) Checkpoint 1 Isetbalanced=41.2 A Imeasured=0.0 A MaxCircuit=33 Imeasured_EV=0.0 A, Battery Current = 0.0 A, mode=1.
(V) (CalcBalancedCurrent)(C0) Checkpoint 2 Isetbalanced=41.2 A, Idifference=33.0, mod=0.
(V) (CalcBalancedCurrent)(C0) Checkpoint 4 Isetbalanced=41.2 A.
(V) (CalcBalancedCurrent)(C0) Checkpoint 5 Isetbalanced=41.2 A.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -2.9 A L2: 0.0 A L3: 0.0 A Isum: -2.9 A
(D) (Timer100ms)(C0) ModbusRequest 3: Request MainsMeter Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 65, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 65 04 18 40 48 a8 e0 00 00 00 00 00 00 00 00 c4 0a ab 34 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 65 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 5: Request Energy Node 0
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0048, data: 0002.
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0048, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 45 98 0d 3f
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 000c, data: 0002.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (7 bytes) 66 04 04 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 000c(ModbusDecode)(C0)  Response
(D) (Timer100ms)(C0) ModbusRequest 21: Request EVMeter Current Measurement
(D) (ModbusSend8)(C0) Sent packet(ModbusSend8)(C0) address: 66, function: 04, reg: 0006, data: 000c.
(D) (ModbusDecode)(C0) Received packet(ModbusDecode)(C0)  (27 bytes) 66 04 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
(V) (ModbusDecode)(C0)  valid Modbus packet: Address 66 Function 04
(V) (ModbusDecode)(C0)  Register 0006(ModbusDecode)(C0)  Response
(V) (CalcBalancedCurrent)(C0) Checkpoint 1 Isetbalanced=41.2 A Imeasured=0.0 A MaxCircuit=33 Imeasured_EV=0.0 A, Battery Current = 0.0 A, mode=1.
(V) (CalcBalancedCurrent)(C0) Checkpoint 2 Isetbalanced=41.2 A, Idifference=33.0, mod=0.
(V) (CalcBalancedCurrent)(C0) Checkpoint 4 Isetbalanced=41.2 A.
(V) (CalcBalancedCurrent)(C0) Checkpoint 5 Isetbalanced=41.2 A.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 0.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: -3.1 A L2: 0.0 A L3: 0.0 A Isum: -3.1 A
dingo35 commented 1 year ago

Ok thx! So that way won't work, will look at the auto discover option....

fluppie commented 1 year ago

Quite some data in a "stupid" SDM230 afbeelding

fluppie commented 1 year ago

From time to time I see this "garbage" data on the screen. Could this be because I poll so much extra modbus data and the SmartEVSE is requesting every 2 seconds an update?

afbeelding

fluppie commented 1 year ago

Could these weird charging currents (underlined blue section) be related to the scrambled data? afbeelding Was more than enough capacity on the 40A mono with 30.5A charging current (BMW claims it can do 7.4kW, 7.0kW is the max...)

afbeelding Towards the end is normal, that's the battery getting to 100%

dingo35 commented 1 year ago

It looks like your EVmeter data is disturbed; why dont you put logging on verbose then you can see exactly whats going on on the modbus...

fluppie commented 1 year ago

Addr 65 = MainsMeter Addr 66 = EVMeter

reg 0006 = current reg 000C = power reg 0048 = import active kwh

So it happens the most with EV meter, as you saw from the display. Disconnecting my second ESP32 with ESPEasy and modbus shield doesn't make any difference in the logs.

(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(MBhandleError)(C0) Error response: E0 - Timeout, address: 65, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 66, function: 04, reg: 0048.
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 66, function: 04, reg: 000c.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(loop)(C1) 1 clients running.
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 66, function: 04, reg: 0048.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 000c.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 000c.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 66, function: 04, reg: 0048.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 000c.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
fluppie commented 1 year ago

Commenting out MainsM register 0006 and EVM registers 0006, 000C and 0048 heavily reduces the errors. So looks like it's double fetching it when Home Assistant requests through Modbus TCP? Also now it are timeouts E0 and with HA requesting we get E2's CRC and E4's Server ID mismatch

(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.8 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.8 A L2: 0.0 A L3: 0.0 A Isum: 2.8 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(loop)(C1) 1 clients running.
(MBhandleError)(C0) Error response: E0 - Timeout, address: 65, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.8 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.8 A L2: 0.0 A L3: 0.0 A Isum: 2.8 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.8 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.8 A L2: 0.0 A L3: 0.0 A Isum: 2.8 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.2 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.2 A L2: 0.0 A L3: 0.0 A Isum: 3.2 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(MBhandleError)(C0) Error response: E0 - Timeout, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.2 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.2 A L2: 0.0 A L3: 0.0 A Isum: 3.2 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.3 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.3 A L2: 0.0 A L3: 0.0 A Isum: 3.3 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.2 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.2 A L2: 0.0 A L3: 0.0 A Isum: 3.2 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.1 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.1 A L2: 0.0 A L3: 0.0 A Isum: 3.1 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 2.9 A IsetBalanced: 41.2 A
(I) (printStatus)(C0) L1: 2.9 A L2: 0.0 A L3: 0.0 A Isum: 2.9 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: A Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 41.2 A
dingo35 commented 1 year ago

Ok are you running latest v1.6.4 with Loadbalancing off? If so I can make another version that uses a second client datastruct, that might reduce the collisions....

fluppie commented 1 year ago

Yes, it's a self compiled version based on the current repo status, only difference are the extra meters. With DBG 1. afbeelding

dingo35 commented 1 year ago

fluppie.zip Try applying this patch, adapter your Extra?MeterAddress - Attachservers too, and see if there are more or less timeouts/crc errors....

fluppie commented 1 year ago

For some reason it didn't want to:

C:\SmartEVSE3serkri\SmartEVSE-3>git apply fluppie.diff
error: patch failed: SmartEVSE-3/src/evse.cpp:2670
error: SmartEVSE-3/src/evse.cpp: patch does not apply

Applies it manually but introduce more errors E0 E2 E4 E5. Without the patch only timeouts E0.

(I) (printStatus)(C0) STATE: B1 Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 40.0 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(loop)(C1) 1 clients running.
(MBhandleError)(C0) Error response: E5 - Packet length error, address: 66, function: 04, reg: 000c.
(I) (printStatus)(C0) STATE: B1 Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 40.0 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(MBhandleError)(C0) Error response: E5 - Packet length error, address: 65, function: 04, reg: 0006.
(MBhandleError)(C0) Error response: E0 - Timeout, address: 66, function: 04, reg: 0048.
(I) (printStatus)(C0) STATE: B1 Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 40.0 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A
(MBhandleError)(C0) Error response: E0 - Timeout, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: B1 Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 3.0 A IsetBalanced: 40.0 A
(I) (printStatus)(C0) L1: 3.0 A L2: 0.0 A L3: 0.0 A Isum: 3.0 A

(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 31.1 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 31.1 A L2: 0.0 A L3: 0.0 A Isum: 31.1 A
(loop)(C1) 1 clients running.
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.8 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 32.8 A L2: 0.0 A L3: 0.0 A Isum: 32.8 A
(MBhandleError)(C0) Error response: E0 - Timeout, address: 65, function: 04, reg: 0006.
(MBhandleError)(C0) Error response: E5 - Packet length error, address: 66, function: 04, reg: 0048.
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 66, function: 04, reg: 000c.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.8 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 32.8 A L2: 0.0 A L3: 0.0 A Isum: 32.8 A

(I) (printStatus)(C0) L1: 32.7 A L2: 0.0 A L3: 0.0 A Isum: 32.7 A
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.8 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 32.8 A L2: 0.0 A L3: 0.0 A Isum: 32.8 A
(loop)(C1) 1 clients running.
(MBhandleError)(C0) Error response: E4 - Server ID mismatch, address: 65, function: 04, reg: 0006.
(MBhandleError)(C0) Error response: E0 - Timeout, address: 66, function: 04, reg: 000c.
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.8 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 32.8 A L2: 0.0 A L3: 0.0 A Isum: 32.8 A

I) (printStatus)(C0) L1: 32.7 A L2: 0.0 A L3: 0.0 A Isum: 32.7 A
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.7 A IsetBalanced: 32.0 A
(I) (printStatus)(C0) L1: 32.7 A L2: 0.0 A L3: 0.0 A Isum: 32.7 A
(loop)(C1) 1 clients running.
(MBhandleError)(C0) Error response: E0 - Timeout, address: 65, function: 04, reg: 0006.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 000c.
(MBhandleError)(C0) Error response: E2 - CRC check error, address: 66, function: 04, reg: 0006.
(I) (printStatus)(C0) STATE: C Error: 0 StartCurrent: -4 ChargeDelay: 0 SolarStopTimer: 0 NoCurrent: 0 Imeasured: 32.7 A IsetBalanced: 32.0 A
fluppie commented 1 year ago

In the current history I can see that power data is sometimes received as current data :). You can hardly see the regular currents 6 to 32A. afbeelding

dingo35 commented 1 year ago

Ok the library should handle all those request async, since I cannot reproduce your timeouts I'm kind of stuck here; not sure if you are overloading the modbus or you hit a bug in the library.

Perhaps you can investigate more by the internal logging of the library: https://emodbus.github.io/logging

and/or asking around on the library discussion forum: https://github.com/eModbus/eModbus/discussions