question

mvader (Victron Energy) avatar image
mvader (Victron Energy) asked

Victron Bluetooth BLE Protocol announcement

Hello Bluetooth-protocol-craving-developers!

Its finally here, a Victron published protocol to get data from our devices over Bluetooth Low Energy aka BLE.

By implementing this protocol, you will be able to read Victron product data such as Voltages, Currents, Power, and so forth.

Each of those values is made available as a GATT characteristic. Which is the normal way of doing that in the official Bluetooth Low Energy protocol. The advantage of doing it that way is that its relatively straight forward to use it. For example you could use a readily available app such as the nRF Connect App by Nordic (screenshot below). And also its possible to query data straight from the command line in Linux.

The details:

  • This feature adds a new BLE Service. Its a new BLE service, and its a different one than the BLE Services we use ourselves for VictronConnect communication and firmware updates.
  • The UUID for this new service is: 65970000-4bda-4c1e-af4b-551c4cf74769
  • This protocol (and its BLE service) is not the same protocol as used by VictronConnect.
  • A keep alive is required. Without that, the device will automatically disconnect after one minute.
  • For now, this new feature is available only for the SmartShunt only. It was added in SmartShunt firmware version v2.31. Also, you need VictronConnect v5.42 (or later) to enable this feature in the settings, see screenshot.

Instructions:

  1. Use a SmartShunt, other devices don't support this yet.
  2. Use VictronConnect v5.42 or newer.
  3. Update the SmartShunt to version v2.31 or later.
  4. Connect to the SmartShunt using VictronConnect, and enable this protocol (screenshot below)
  5. Power cycle the SmartShunt
  6. Refresh the services cache on your host (ie. phone/tablet/laptop/raspberrypi). This is done by removing the SmartShunt from the list of bonded devices, and then re-add it. This is necessary because Android, Bluez/Linux and so forth all cache the list of available services.


Now its up and running and available. On a phone, try the Nordic nRF Connect App and look for the service with the UUID ending at 4769 as listed above.

On linux, use the gattool. I found a nice primer about it: How to Get Started with Bluetooth Low Energy on Linux. And there must be many more to be found on the internet.

To find out which GATT characteristic is what, you can read the "Characteristic User Description" parameters. Currently I don't have a list of all UUIDs and what they mean.

Now, a bit more detail on the keep alive:

  • The default time-out is configered to 60 seconds.
  • The UUID for the Keep-alive characteristic is 6597ffff-4bda-4c1e-af4b-551c4cf74769.
  • Writing 0xFFFF to it disables the auto connection, resulting in a connection forever.
  • We strongly recommend not to use that 0xFFFF in a production environment. During VictronConnect development we learned the hard way that Bluetooth stacks can end up being in weird states, on the host as well as in our product; and one good way to make it robust it is to make the host send a keepalive; and make the device issue an internal disconnect when it no longer receives that keep-alive. This then resets all states and resets the rest of the stack, so its in a connectable state again.


Last, how to get the data? BLE supports multiple methods. First there is the obvious read command, which allows you to read a value, and the host (GATT Client) then sends the read command to the Victron product (GATT Server), after which the response including the data is returned.

The other method is to have the host (GATT Client) subscribe to notifications. Our implementation supports these notifications, and how they work is that whenever a value changes, its automatically sent by the Victron product to your host. Note that notifications are not acknowledged.

That is all for now. We are aiming to write this up in a more complete and technical document, but I can't promise when that is completed.

All the best, Matthijs


Picture one: the setting to enable this "third party implementation"-protocol:



1625169925253.png


Picture two, the Nordic nRF Connect App showing the voltage (0x2005 = 0x0520 = 13.12V). Note how the app Allows you to retrieve the data, retrieve the user description, as well as receive other information about the characteristic:


1625171683174.png


Picture three: how to enable notifications in the Nordic nRF Connect App.

1625171748346.png


Bluetooth
1625169925253.png (40.8 KiB)
1625171683174.png (531.0 KiB)
1625171748346.png (327.9 KiB)
8 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Two more pieces of information:

1. I made a mistake, the firmware version needed is not release cq. not shipped with VictronConnect at the moment. Here is a link to the file you need:

https://www.dropbox.com/s/08c5mbwdr4rdl2q/smartshunt52_ble_v2.31-gatt.bup?dl=0

Install it using the instructions here: https://www.victronenergy.com/media/pg/VictronConnect_Manual/en/firmware-updates.html#UUID-705fe0d3-30d8-e6e6-aad1-856f4ac6e3b3

2. Here is a list of the characteristics, (my apologies for the formatting).

UUID

Characteristic

Access

Type

Scale

Unit

Special values

6597ffff-4bda-4c1e-af4b-551c4cf74769

Keep-alive

Write/Read

un16

0,001

Seconds

0xFFFF

keep-alive forever

6597eeff-4bda-4c1e-af4b-551c4cf74769

Consumed Ah

Read/Notify

sn32

0,1

Ah



6597ed8e-4bda-4c1e-af4b-551c4cf74769

Power

Read/Notify

sn16

1

W

0x7FFF

not available

6597ed8d-4bda-4c1e-af4b-551c4cf74769

Voltage

Read/Notify

sn16

0,01

V

0x7FFF

not available

6597ed8c-4bda-4c1e-af4b-551c4cf74769

Current

Read/Notify

sn32

0,001

A

0x7FFFFFFF

not available

65970fff-4bda-4c1e-af4b-551c4cf74769

State of charge

Read/Notify

un16

0,01

%

0xFFFF

not available


Here is the same list, but then as a picture:

1625216203367.png


0 Likes 0 ·
1625216203367.png (27.6 KiB)
ripnc avatar image ripnc mvader (Victron Energy) ♦♦ ·

Using an Android tablet - file appeared to add to the library without issue but when I click to Update (from 2.30) I see nothing in the library. I get the "lightbilb" and the message saying I'm running the most current version. I have the option to use a laptop but I'm participating in a beta so I'd like to see if I can get the Android to work.

0 Likes 0 ·

How do you update the firmware from the file? I don't get the Firmware update option for the Bluetooth Interface if I connect via cable (I only see the "Product" one that's on v4.07), and it won't connect via Bluetooth on my Linux machine and my iOS devices I can't select a file.


0 Likes 0 ·
Hi Robbo, I added a link to my comment above, to the manual; please check that
0 Likes 0 ·
robbo avatar image robbo mvader (Victron Energy) ♦♦ ·

Cheers, now singing on v2.31.

0 Likes 0 ·
Hi and now I’m curious ;o) did it work?
0 Likes 0 ·
Hi all, a heads-up: we're currently working on broadcasting all the most relevant data. Which is for a lot of systems probably a lot easier (and more stable) to work with, rather than connecting to the GATT service. More information about it later; might still take one or two months but then at least you already know.
0 Likes 0 ·
hoechst avatar image hoechst mvader (Victron Energy) ♦♦ ·
Thanks for the feature, seems to be very helpful for our case as well. Any update on the timeline especially for other products, i.e. the SmartSolar line?
0 Likes 0 ·
15 Answers
trip-tracks avatar image
trip-tracks answered ·

Thanks, @mvader (Victron Energy).
And thanks for the detailed/informative approach.

Looks like a great start. Looking forward to getting other devices connected - the Orion-Tr Smart DC-DC Chargers would be a great target since they don't have a ve.direct interface ;)

4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

hahaha; yes. but also then you still won't see its output current; you're aware of that right?
0 Likes 0 ·
trip-tracks avatar image trip-tracks mvader (Victron Energy) ♦♦ ·

No, I wasn't. I know a SmartShunt on the output should work though ;) And with ve,direct

Sorry, not trying to undermine any of your great work!

You know it would be great to have a way to connect this into DVCC and for use with canbus BMS. The missing link to controlling all the charging,,,,,
Oh, and a 12-48V DC-DC charger, thanks! ;)

0 Likes 0 ·
no worries, no need for apologies! but its the common thing everyone wants from their Smart Orion (output current measurement) which it doesn't measure. So no matter the protocol.. its not there. Until we have redesigned the product ofcourse, but that will take a long long time.


I don't think we'll be using bluetooth soon for DVCC and such btw.


Here its time to sleep, have a good day!

0 Likes 0 ·
hjohnson avatar image hjohnson mvader (Victron Energy) ♦♦ ·
Bit of an old thread, but what I'd love to be able to do is a) do temperature compensation on the Orion, and b) adjust its voltage on the fly, based on the data from a Smart Shunt or BMV-7xx. Our plan is to use an Orion to maintain the starting battery on our boat, and it'd be nice to have a little more than on/off control via the relay input.
0 Likes 0 ·
rspott avatar image
rspott answered ·

Does this mean my Cerbo might be able to display data from my 6 Victron Energy Smart LiPo Battery 12.8V?

The phone app is neat but requires me to be physically present and click back and forth too many times to get status.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

birdie avatar image
birdie answered ·

Thanks Matthijs for this great announcement,

I have added a python script to retrieve the data to my repository with my reverse engineering from the older protocol: https://github.com/birdie1/victron

It is already working better and more stable than all the stuff before. Would be great to get more information on this way on the smart shunt. And of course if you add the new protocol to the other devices as well.

Looking forward to more changes like this!

Regards

Jonas

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi Jonas,


you're welcome! Wrt SmartShunt and more information: we don't have the intention to add anything.


Matthijs

0 Likes 0 ·
Philip Barclay avatar image
Philip Barclay answered ·

Is there a characteristic for the secondary voltage connection?

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi

At the moment, this data is not available in a characteristic.

Kind regards,

Thiemo van Engelne

0 Likes 0 ·
David avatar image
David answered ·

Hello! Will GATT be enabled for the BMV-712? I got my hopes up when I read the changelog entry for today's 5.48 release at https://www.victronenergy.com/live/victronconnect:beta

Specifically:

  • BMV-712 & SmartShunt:
    • ...
    • Show GATT switch only when connected via Bluetooth
    • Mark GATT as experimental feature
    • ...

So, I gleefully updated to 5.48 firmware on my battery banks, but found that the Victron Connect app (on both Android and macOS) does not show a "Bluetooth GATT service" switch under the Product Info page.

screenshot-20211007-114033.png

For background: I made battery bank suitcases for personal emergency preparedness, and I chose BMV-712 monitors on each Pelican case to have the display available in the field. It would be fantastic if I may also monitor the batteries wirelessly to enable more unattended operation such as with Python & BLE GATT to automate dump loads and send battery level notifications without compromising case waterproofing for VE.direct cables or having to reconnect such cables during battery bank swaps.

Thank you,

David


1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

I have the same question as David here. Is this something we could expect to see enabled on the BMV-712? Really excited to integrate this functionality into my home-brew monitor system. The change log seems to indicate it was enabled with 5.48. However this appears not to be the case (unless I'm doing something wrong). I'll swap out with the Smart Shunt if support for the BMV is not in the future plans.

Thanks!


0 Likes 0 ·
vinthewrench avatar image
vinthewrench answered ·

I posted some sample code in C that uses the Gattlib from (https://github.com/labapart/gattlib) to get some values from the smartshunt. O hardcoded the deviceID in the sample for now.

You still have to use bluetoothctl to connect and pair, I havent written that in C yet. but this might help.

my code is at https://gist.github.com/vinthewrench/4d2046c3d3cc0bae7e2fa54bdfb89dac

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

felixsteinbeis avatar image
felixsteinbeis answered ·

Hello Matthijs, hello Victron,

Any news when the new GATT service will also be available on the BMV-712?
And will the new GATT service also be available on the Phoenix Smart IP43 Charger?

I hope it will not take much longer.
Thank you very much.

Best regards
Felix

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

wolfgang-huse avatar image
wolfgang-huse answered ·

Hello! I started to create a BLE Client on ESP32, displaying Data works quite well on a M5Stack, next step will be forwarding Data as MQTT, maybe LoRa... i will share code after some additional testing...ve.jpg

Seems like in the meantime there are more Characteristics available under the Service, is there a newer documentation available ?

12:15:36.1600: discovered characteristics for service 65970000-4BDA-4C1E-AF4B-551C4CF74769: (
    "6597FFFF-4BDA-4C1E-AF4B-551C4CF74769",
    "65970FFF-4BDA-4C1E-AF4B-551C4CF74769",
    "6597ED8D-4BDA-4C1E-AF4B-551C4CF74769",
    "6597ED8E-4BDA-4C1E-AF4B-551C4CF74769",
    "6597ED8C-4BDA-4C1E-AF4B-551C4CF74769",
    "6597EEFF-4BDA-4C1E-AF4B-551C4CF74769",
    "6597ED7D-4BDA-4C1E-AF4B-551C4CF74769",
    "6597EDEC-4BDA-4C1E-AF4B-551C4CF74769",
    "65970382-4BDA-4C1E-AF4B-551C4CF74769",
    "65970383-4BDA-4C1E-AF4B-551C4CF74769",
    "65970FFE-4BDA-4C1E-AF4B-551C4CF74769"

ve.jpg (1.8 MiB)
2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

I am extremely interested in your project. I would like to set up a similar system in my RV with an M5Stack from Adafruit. Please keep us updated on your project as you progress.
0 Likes 0 ·
I would like to work with you. I work now for a long time with STM32, esp8266 and the esp32. I coded a lot for the TASMOTA (github) to communicate and for sensors like UV and Sun Power on square meter.

I use also a industrial PLC from B&R for my home automation, the cp1585 and a lot of bus hardware (PowerLink, X20) and digital and analog i/o's.

0 Likes 0 ·
muhkuhve avatar image
muhkuhve answered ·

I am still a little confused. I got a SmartSolar MPPT 75/15 pv charging controller.. is there any way to get at least voltage/current from PV or to battery using my esp32, rpi or anything else?

No advertising firmware for SmartSolar so far? Couldn't find out behind what uuid these values may wait..

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

netsrac27 avatar image
netsrac27 answered ·

Great stuff. The support for public Bluetooth address was actually the reason why I dropped my BMV-702 and replaced it with a SmartShunt.

Would actually love to see GATT services on the Smart Battery Sense. Together with the voltage and the temperature you could somehow estimate the charging status of the starter battery.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

wolfgang-huse avatar image
wolfgang-huse answered ·

@mvader (Victron Energy) I have some more questions on current implementation...

I am working on a auto-discovery based on BLE Advertised Services and i only receive a different Service UUID (cd55a389-880b-425b-b167-81ed6a15e913 )from the later used for the characteristics.

Can i rely on this UUID for Discovery? What about Manufacturer-Data (e102100289a3) is this fixed to the Smart Shunt Device ?

Regards,

Wolfgang

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @Wolfgang Huse

It would advice to rely on the Manufacturer Data. This is indeed (mostly) fixed for the SmartShunt. "e12110" is fixed and is the same for all Victron products. The following "02" might change in the future and/or between products. The "89a3" is fixed for the SmartShunt as this is the so called product id (in little endian order), which is unique for every product type.

In the future the content of the manufacturer data can be extended, but this first part will stay the same, maybe except for that "02" byte.

Kind regards,

Thiemo van Engelen

1 Like 1 ·
deadrabbit avatar image
deadrabbit answered ·

Hi,


i'm new to Bluetooth Low Energy and i want to develop a small OLED-Display which displays the battery values.


First point i'm struggeling: @mvader (Victron Energy) published a firmware version 2.31. On my smartShunt is v2.37, so i'm not able to downgrade.


But i have the GATT setting in my VictronApp and enabled it. But with nrfConnect i get different characteristics as described above.


For example i get the UUID 68c10001-b17f-4d3a-a290-34ad6499937c

screenshot-2022-05-21-15-51-17-947-nonordicsemiand.jpg

How can i access the SoC or Voltage characteristic?


Thanks!




3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @deadrabbit

When you remove the pairing of the SmartShunt in the Android Bluetooth menu (or use "Remove bond information" in nrfConnect), is it then still not showing the correct service?

Remember that you need to pair again to the SmartShunt after this, so make sure that you know the PIN code or the PUK code to be able to reset it back to "000000".

With kind regards,

Thiemo van Engelen

0 Likes 0 ·
deadrabbit avatar image deadrabbit Thiemo van Engelen (Victron Energy staff) ·
Hi @Thiemo van Engelen (Victron Energy staff)


thanks for your reply. Your hint was helpful, now i'm able to the Service UUID as described above.

BW


0 Likes 0 ·
I am interested in your progress of your project. I would very much like to do the same as you with a display that I can mount in my RV. Any progress updates?
0 Likes 0 ·
netsrac27 avatar image
netsrac27 answered ·

Will there be a chance that we see GATT services on other devices? I could also go with the new broadcasting data….if this wouldn’t be encrypted…

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

tsax6010 avatar image
tsax6010 answered ·

If had been a full year now. Any update @mvader (Victron Energy) on GATT support for the BMV-712?

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

felixsteinbeis avatar image
felixsteinbeis answered ·

Hi Matthijs,

I've been looking for a solution to read out my BMV-712 via Bluetooth for over a year now.

My hope was the new GATT service, but unfortunately it is not yet available for the BMV-712 (but I keep hoping it will come). Now my second hope is the new advertising data. These contain almost all the info I need.

However, the data are encrypted. How can I decrypt the data? I can read the advertising data and see a timestamp. But I am missing more information about encryption and encoding.

Alternatively, an option to use a configurable encryption key only for the advertising data that is independent of the six digit key and the pairing/bondig before.

I really hope Victron can provide the info so I can finally read my BMV-712 with Bluetooth.

Thank you very much.

Many greetings
Felix

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.