Skip to content
PekawayPekaway
JBD BMD - e.g. integrate into Liontron

JBD BMD - e.g. integrate into Liontron

Easy going in the VAN PI system

Do you want to integrate your Liontron battery into our system? No problem, all the tools and software you need are included in our SD image. Simply go to the web interface for config and select Liontron under Bluetooth. The system will now search for a nearby battery. If it is found, the process is complete and you will receive all the relevant data directly on your mobile phone or our touchscreen.

Tutorial for manual integration

1. Search for BLE devices

First, we need to check whether we can even find the battery via the Raspberry PI. At the same time, we use this search to find out the MAC address of the battery's Bluetooth module.

For this we use the tool HCITOOL . We have to call this via the command line. If you are not using our image and the required tools are not yet on board, you can find here (click) are instructions.

So we connect via Putty or another SSH program and start with the command:

 sudo hcitool -i hci0 readscan 

the Bluetooth search process.

We cancel this command after a few seconds with Ctrl+C, otherwise the search will take an infinite amount of time. We see all the devices found that send a BLE identifier in the area. In the example, this is also the battery name or battery number. This is the same one that is shown to you in the Liontron battery app. Next to it is the battery's MAC address, which is important for the next step.

Incidentally, all Apple devices perform this BLE device search all the time in order to find an Apple ibeacon, for example. What tracking options arise from this...

You can also search using the NRF-Connect app. This app is an all-rounder for BLE applications. It is provided by Nordic Semiconductor, a common manufacturer of the most well-known BLE chips. With it, you can not only search for devices, but also access various services of the device. In the case of the Liontron battery, under the service 0xFF01 you will find a buffer of HEX values, which is structured according to the same pattern as the Xiaoxiang/JBD BMS protocol. We therefore assume that an adapted JBD-BMS version is installed in the LIONTRON batteries...

2. Python Reading APP

To read the data from the battery, GemZ I wrote a Python script that connects to the battery and outputs a JSON. The script uses the GATT tool to read the values. There may be another tutorial on this.

https://github.com/GemZ/LiontronBmsInfo

To use the script, Python must be installed. You also need the Pexpect extension.


sudo aptupdate sudo apt install python3 idle3

We copy the script from Github into a new folder "Liontron" using the following commands in the command line/Putty.

 cd /home/pi/
sudo mkdir liontron
sudo cd liontron
sudo git clone https://github.com/GemZ/LiontronBmsInfo/blob/master/liontronBmsInfo.py

and now we install the Pexpect extension via the Python package manager.

 sudo pip3 install pexpect 

The script can now be started. The MAC address of the battery is passed with -d. On our VAN-PI image, the file is located under /home/pi/ble_py/.

 sudo python3 /home/pi/ble_py/liontronBmsInfo.py -d A4:C1:38:85:3C:75

or.

 sudo python3 liontronBmsInfo.py -d "mac" 


You will then receive a JSON with all the battery parameters.

3. Integration into Node-Red

We collect most of our functions and all of our data in Node-Red. For the Liontron battery, we added a small flow that searches for the battery and then queries the battery data every 20 seconds using the Python script. This flow has a few more functions, as we always have to adapt our system to multiple devices and products.


We provide the flow here and you can adapt it as you wish. Simply import the content into your Node-Red using the flow import:

https://share.12-s.de/s/Eomx4f2MjtfB4YR

4. Conclusion

The Liontron batteries are very easy and quick to integrate. The workmanship also makes a very solid impression. The idea of ​​not gluing a battery and thus having the option of repairing it is great. After all, all hobbyists who build their own LIfepo4 battery have been able to do so for a long time. And here is the crux of the matter: the battery is very expensive compared to other systems or self-made solutions. For the same price and with a little patience and spit, you can build a battery with three times the capacity and almost the same space requirement. (55ah to 150ah self-made).

Leave a comment

Your email address will not be published..

more tutorials

Open Source needs support

become Patron now

More projects, more tutorials and more supported devices. Our community is growing and would appreciate your support. So become a patron now to always receive the latest content and support the VAN PI project at the same time.

Become a Patron
Cart 0

Your cart is currently empty.

Start Shopping