Negative modbus value

I have two Victron MPPT’s in my setup, one SmartSolar 100 | 20 48V and one SmartSolar 250 | 60 rev 2.

I am connecting via modbus TCP to a raspberry pi running Venus OS.

I can extract the data correctly for all registers except Register 790 - User Yield on the 250 | 60 MPPT.

The Victron Connect app shows the correct values and so does Venus OS but the 250 | 60 MPPT charger shows a negative modbus value.

Any idea where I can start to look to resolve the issue?

The Venus is running FW version 2.6 and both MPPT’s are running FW version 1.56

Is the field supposed to be signed? Perhaps you need to mark it as unsigned in the client app?

1 Like

Yup. Modbus just sends you a 16-bit value (sometimes you have to combine two of them if it is a 32-bit value). The interpretation thereof, whether it is signed or unsigned, is something that is up to you. Values that cannot be negative (such as the yield) will be an unsigned integer. And the moment it goes over halfway (32767) it becomes negative.

Apologies, I forgot to mention, this is using modbus in home assistant.

Google says add this to the sensor definition:

data_type: uint

Brilliant, thanks Plonkster, that got it sorted.

That wrong value was really triggering my OCD :stuck_out_tongue_winking_eye:

Mmm, I had to remove all that “data_type: unit” after the latest upgrade, HA had error on error, complained bitterly … maybe I must investigate again.

I assume you mean uint. I see in the later versions they prefer uint16, which is technically more accurate.

I can tell you a tale about this. So one day, I get a call from someone whose battery is requesting a negative maximum charge current. I investigate. I see that this is a battery with a massive capacity, around 3500Ah. The protocol says, you send this value as a signed integer, with one place sacrificed for a decimal.

This means it can handle -3276.8A to 3276.7A values. But why on earth would we ever want this value to be negative? This should have been a uint (which would allow up to 6553.5A), and the decimal could have been dropped, which would allow up to 65535A. That should be enough for anyone… at least for now. So I look at the spec sheets for the top three batteries, and every single one of them got it wrong. Probably because we all copied from the same original… :slight_smile:

To make it funnier, the charge voltage… that one is specified as unsigned. Now voltage actually CAN be negative (even though it still makes no sense), but here the spec went with uuint… and again everyone just copied it.

It’s quite hilarious really…

1 Like