JDB / XiaoXiang BMS tool

graham

New member
Joined
Jan 5, 2018
Messages
25
If compiled with MQTT support (needs paho mqqt library), jbdtool outputs mqtt data. You can specify the info on the comand line with the -m option, for example:


Code:
jbdtool -m host:clientid:topic[:user[ass]]

jbdtool -t ip:pack_01 -m localhost:pack_01:/Battery/pack_01

(pack_01 is the dns name of my wifi module #1)

In another window, I can subscribe to /Battery/# to see the JSON output:

# mosquitto_sub -h localhost -t '/Battery/#'
{"Voltage":53.330001831054688,"Current":0,"DesignCapacity":100,"RemainingCapacity":64.339996337890625,"PercentCapacity":64,"CycleCount":0,"Probes":2,"Temps":[17,15.300000000000001],"Strings":14,"Cells":[3.79,3.7850000000000001,3.7919999999999998,3.7909999999999999,3.819,3.8290000000000002,3.831,3.8300000000000001,3.8250000000000002,3.8130000000000002,3.8239999999999998,3.8039999999999998,3.794,3.7999999999999998],"CellTotal":53.326999664306641,"CellMin":3.7850000858306885,"CellMax":3.8310000896453857,"CellDiff":0.046000003814697266,"CellAvg":3.8090713024139404,"DeviceName":"15350019-SP15S008C-P14S-100A","ManufactureDate":"20210116","Version":2.5,"FET":"Charge,Discharge"}


I have a node-red server running on the same host which injects the info into an influx DB. It should look something like this:

View attachment 23789

Reads from /Battery topic, converts JSON to javascript obect, then flattens the Cells array into cell01,02,03,04 as seperate fields, does the same for temps, then removes arrays for the remainder of the data.

From there, its easy to make a dash for it in Grafana. Something like this maybe (could use some work):

View attachment 23790

After that you could get fancy and maybe do some linking if you have multiple packs so you can click on each pack to get the info


NOTE: I just updated the github repo ... it wasnt setting the name field in the JSON output with the mqtt clientid.

EDIT: no way to remove those stupid emojis ... they are colon p
Wow thats something to work towards,

I have alot of questions but i will try an keep it short,

I am currently running the static version for pi that you put together, do i need to switch to the github repo?
 

chuckp

Active member
Joined
Jul 29, 2018
Messages
376
This looks great I have a couple of Pi’s kicking around that the Mrs got me as part of my Christmas present.
Have you managed to get the batt off and on buttons and the config page to work remotely also.
Would be great to also be able to access the BMS remotely when away from home.

My nephew who in my eyes is a programming wizard is building a custom system for me at the moment that will integrate all my equipment into one interactive user dashboard. I’ll have access to data from my micro inverters, (wind turbine inverter once I’ve installed it) battery charger inverter and my BMS. He is also looking at linking my BMS to the coms on my charge controller (SOFAR ME300SP). Then I can use the proper default Lithium charge settings rather than the custom settings I’m using at the moment.

In the meantime though this looks to be a great option.
 
Last edited:

sshoecraft

New member
Joined
Jan 23, 2021
Messages
25
This looks great I have a couple of Pi’s kicking around that the Mrs got me as part of my Christmas present.
Have you managed to get the batt off and on buttons and the config page to work remotely also.
Would be great to also be able to access the BMS remotely when away from home.

My nephew who in my eyes is a programming wizard is building a custom system for me at the moment that will integrate all my equipment into one interactive user dashboard. I’ll have access to data from my micro inverters, (wind turbine inverter once I’ve installed it) battery charger inverter and my BMS. He is also looking at linking my BMS to the coms on my charge controller (SOFAR ME300SP). Then I can use the proper default Lithium charge settings rather than the custom settings I’m using at the moment.

In the meantime though this looks to be a great option.

Yes, you can turn charging and discharging off/on by using the -g (charging) and -G (discharging) options

All of the config parameters can be set. Use the -l (ell) option to list them. Use the -r option to read specific ones, or -r -a to list them all. Then, if you want to set a parameter, use the -w option with key/value pairs. For instance, to set the Balance start voltage to 3800 and the Balance window to 15mv, you would use this command:

jbdtool -t <transport opts> -w BalanceStartVoltage 3800 BalanceWindow 15

The only thing I didnt implement was the voltage/current calibration and balance control modes (odd/even/etc).

Since I have so many packs, I set all my BMSs to the same values by using a JSON file like so:

jbdtool -t <transport opts> -w -f jbd_settings.json


You can capture the current settings into a JSON file using the -r and -a options with -o (output):

jbdtool -t <transport opts> -r -a -n -J -o my_settings.json


Your transport opts are going to specific to your BMS, (like bt:01:02:03:04:05:06 or serial:/dev/ttyS0)

Also, I tried the read the settings command into a json file and realized it was sending the batteryconfig and ntc output to stdout (instead of redirecting to a file if it was asked to). I attached an updated copy here, but your copy should work fine with the commands above.
 

Attachments

  • jbdtool_pi_static.zip
    1.3 MB · Views: 12

graham

New member
Joined
Jan 5, 2018
Messages
25
@sshoecraft thank for all your help,

So Far
I have connected to the BMS using Jbdtool through serial port.

$ jbdtool -t serial:/dev/ttyUSB0,9600 Battery

gives me a full read out of BMS,, all good

Mqtt

I have read a couple of tutorials and followed these instructions

$ sudo nano /etc/mosquitto/mosquitto.conf

replaced the last line. $ include_dir /etc/mosquitto/conf.d

with $ listener 1883

exit/saved/ rebooted.

Now i can subscribe and publish using

$ mosquitto_sub -d -t Test
$ mosquitto_pub -d -t Test -m "Hello' World!"

But when i try this,

$ jbdtool -t serial:/dev/ttyUSB0,9600 -m localhost:Test:/Battery/

nothing,,, I guess im not addressing the jbdtool correctly, or i have set up Mosquitto incorrectly?

any advice would be gratefully recieved.

Thank you
 

chuckp

Active member
Joined
Jul 29, 2018
Messages
376
Thanks

As soon as I have some free time I’ll dig out the Pi’s and set it up.
 

bwolten

New member
Joined
Sep 13, 2020
Messages
8
I used the current download from your github page... I see the others are PI, I do have a PI so maybe I will try on the PI
In the JBD directory where I have the JBDTools and MYBMM: I am using ubuntu 20.4, at the command line i type: sudo make throws the below error
Not sure if I did something wrong which likely the case.. I see in the JBDtools folder the gattlib.h file..
Any thoughts???

../mybmm/bt.c:18:10: fatal error: gattlib.h: No such file or directory
18 | #include "gattlib.h"
| ^~~~~~~~~~~
compilation terminated.
 

sshoecraft

New member
Joined
Jan 23, 2021
Messages
25
Y
I used the current download from your github page... I see the others are PI, I do have a PI so maybe I will try on the PI
In the JBD directory where I have the JBDTools and MYBMM: I am using ubuntu 20.4, at the command line i type: sudo make throws the below error
Not sure if I did something wrong which likely the case.. I see in the JBDtools folder the gattlib.h file..
Any thoughts???

../mybmm/bt.c:18:10: fatal error: gattlib.h: No such file or directory
18 | #include "gattlib.h"
| ^~~~~~~~~~~
compilation terminated.

If you're not using a PI you'll need to compile and install gattlib from github: https://github.com/labapart/gattlib
 

sshoecraft

New member
Joined
Jan 23, 2021
Messages
25
@sshoecraft thank for all your help,

So Far
I have connected to the BMS using Jbdtool through serial port.

$ jbdtool -t serial:/dev/ttyUSB0,9600 Battery

gives me a full read out of BMS,, all good

Mqtt

I have read a couple of tutorials and followed these instructions

$ sudo nano /etc/mosquitto/mosquitto.conf

replaced the last line. $ include_dir /etc/mosquitto/conf.d

with $ listener 1883

exit/saved/ rebooted.

Now i can subscribe and publish using

$ mosquitto_sub -d -t Test
$ mosquitto_pub -d -t Test -m "Hello' World!"

But when i try this,

$ jbdtool -t serial:/dev/ttyUSB0,9600 -m localhost:Test:/Battery/

nothing,,, I guess im not addressing the jbdtool correctly, or i have set up Mosquitto incorrectly?

any advice would be gratefully recieved.

Thank you

You might try subscribing to any topic on your mosquitto server and see if you see anything

mosquitto_sub -h localhost -t '#' -v

and then turn on debugging in jbdtool with the -d # option

jbdtool -t serial:/dev/ttyUSB0,9600 -m localhost:Test:/Battery/ -d 2

(each increase of the debugging level increases the verbosity, 5 or 7 will show you the packet data sent back/forth to the bms, 9 is pretty much everything)
 
Top