Interpreting BLE Victron Data

Hi all,
my decrypted data looks like this

02E1100289A30204C617FFFF660500000000030000000080FE00

I’m struggeling with the Batterie current value of the SmartShunt (0x02) → I use this documentation:

extra-manufacturer-data-2022-12-14.pdf

I’m a bit lost how to get the correct data.
Maybe someone has a hint.

Best
Sascha

I wrote a html page to analyse the values

Hi @Saschakopp

Bits are allocated from lowest bit to highest bit. This means that the lowest two bits of the byte that contains 0x03 are used for the Aux input. The remaining bits of the byte are used for the battery current (as bits 0 … 5 of the current). This means that Aux input is 0x03 (meaning that the AUX input setting is set to “None”) and the battery current is 0.

With kind regards,
Thiemo van Engelen

1 Like

Hi Thomas,
this is not an issue - struggeling with battery current.
Battery voltage is also stored as little endian and that looks good.

Hi @Saschakopp

I was talking about the battery current. I edited my response to make this more clear.

Your image shows that the bits containing 0x03 is used in the battery current, but I am saying that the two bits that make up the 0x3 are for the Aux input.

Kind regards,
Thiemo van Engelen

Hi Thomas,
ok lets try this - my full value is 02E1100289A30204C617FFFF660500000000030000000080FE00

The part value I have to focus for Aux value + Battery Currentis is “030000”.

This in binary is 0000110000000000000000
The first 2 bit are 00 - no AUX - this is correct.

The rest 00110000000000000000 would be without little endian a decimal value 786432.
How do I need to convert this into little endian because there are only 22 bit available?

This means I have to fill up 2 more bit at the end 00110000 00000000 000000
Via little Endian would it be 000000000000000000110000 which would be 30 in decimal.

Please correct me if I’m wrong.

Hi @Saschakopp

My name is Thiemo.

Correct

03 00 00 in binary is:
Byte 0: 00000011
Byte 1: 00000000
Byte 2: 00000000
This makes the first two bits 11 = 0x03, and 0x03 means “AUX input none”.
The remaining bits are all 0, so the battery current is 0.

Kind regards,
Thiemo van Engelen

Hi Thiemo,
thanks for the fast response - my battery is not fully charged and, bacause of light is switched on, using battery

I get 02E1100289A3022DD517BA07250500000000E3DBFFDB0030F400 and we do have to focus on E3DBFF (for aux and current battery)

1 byte = 11100011 (0xE3)
2 byte = 11011011 (0xDB)
3 byte = 11111111 (0xFF)

We switch 1st two bit of the first byte it would be

1 byte = 11000111
2 byte = 11011011 (0xDB)
3 byte = 11111111 (0xFF)

The 22 bits are 0001111101101111111111 this is in decimal 515071.
The value doesn’t make much sense there must be an issue somewher…

Hi @Saschakopp

1 byte = 11100011 (0xE3)
2 byte = 11011011 (0xDB)
3 byte = 11111111 (0xFF)

This is correct. But you don’t have to do any bit swapping of any sorts. The lowest 2 bits of byte 1 are used for the Aux value and the remaining bits for the Battery Current. So when I write the complete battery current from most significant bit to least significant bit it becomes:
11111111_11011011_111000. This is a 22 bit signed number (which in this case is negative because the most significant bit is set) and the value is -2312, meaning -2.312A.

And example of how you can come to the value -2312 is by sign extending the bit to 32 bits (prefix the bit pattern with the most significant bit until it contains 32 bits) and then treat this is as 32 signed integer. So the bitmask becomes (MSB to LSB):
11111111_11111111_11110110_11111000 => 0xFFFFF6F8 => -2312

Kind regards,
Thiemo van Engelen

1 Like

Hi Thiemo,
thanks for the explanation - I tried to find some kind of document where this is defined.
Is it somewhere available?
Best regards
Sascha

Hi @Saschakopp

At the moment there is no further documentation on how to extract the bits and convert it to a usable value.

Kind regards,
Thiemo van Engelen

Here is some code that may help you:

@thiemovanengelen thanks a lot for the explanation. That works now.
It this the same for the next value Consumed Ah?

Hi @Saschakopp

The Consumed Ah consists of the next 20 bits, so this means 2 full bytes and then the lowest 4 bits of the next byte. As the value stored inside is not a signed value, there is no need for the special bit extending and it can just be extended using 0’s.

And to already answer a possible next question, the SOC takes the next 4 bits (so the upper 4 bits of the last byte of the Consumed Ah) and then lowest 6 bits of the next byte. And this is also unsigned so it can be extended using 0’s.

Regards,
Thiemo

2 Likes

@thiemovanengelen
Thumb up :+1: for having the patience to explain it in detail.
Thanks!

@thiemovanengelen thanks a lot for all your time.

As and real example I see the values 02E1100289A30204C617FFFF3E0500000000974A01500310D1

What I see from above we focus on the value (Consumed Ah)

500310 - in binary 01010000 00000011 00010000

now with the lowest bit from the 3 byte the value is
01010000 00000011 0000 + 0000

value 010100000000001100000000 in decimal 5243648

Where is the missunderstanding?
Thanks a lot

Hi @Saschakopp

The misunderstanding is that all data is little endian so the bytes need to be reversed.
byte 1 = 01010000 (0x50)
byte 2 = 00000011 (0x03)
byte 3 = 00010000 (0x10)
So Consumed Ah in bits is: 0000_00000011_01010000.
Extending this to a 32 unsigned integer becomes: 00000000_00000000_00000011_01010000, which is 848.

Kind regards,
Thiemo van Engelen

@thiemovanengelen Thanks a lot for your support - Happy to have the right product in place :slight_smile: