UPDATE 2023-2-18: make sure to also read here https://community.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html
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:
- Use a SmartShunt, other devices don't support this yet.
- Use VictronConnect v5.42 or newer.
- Update the SmartShunt to version v2.31 or later.
- Connect to the SmartShunt using VictronConnect, and enable this protocol (screenshot below)
- Power cycle the SmartShunt
- 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:
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:
Picture three: how to enable notifications in the Nordic nRF Connect App.