This Python library allows connection to Lithium BMS with a UART to USB adapter and read the battery information. Those BMS modules are commonly soled under the brands Jiabaida or Xiaoxiang
The information on how the protocol works was taken from a more or less official excel file I found online (included in the resources folder)
It's currently under development and may still deliver incorrect data. At the moment, only reading of information is supported. Maybe I will add some functionality to edit the settings of the BMS in the future, collaboration is welcome :)
bms = BMS("/path/to/serial")
an optional debug=True parameter can be included to load some sample data instead of reading fromt he serial port. In this case, the first Parameter will be ignored.
query_basic_info() queries everything but single cell voltages (as it's one call to the BMS)
query_cell_voltages() queries onlt the single cell voltages (one call, too)
query_all() queries both of the above
The readings can be accessed directly on the instance:
active_protection_statesprotection modes currently active (enum list)balance_stateWhether a single cell is currently balanced (bool list)cell_voltagesSingle cell voltages in volts (V) (float list)currentCurrent flowing. Negative for discharge, positive for charging (float)cycle_times(int)discharge_status(bool)manufacturing_date(datetime)nominal_capacityin ampere hours (Ah) (float)number_of_cells(int)residual_capacityin ampere hours (Ah) (float)rsocremaining state of charge in percent (int)software_version(bytearray / not sure how to interpret this...)temperaturesof all connected sensors, mostly BMS internal and external cell probe (float list)toal_voltagein volts (V)
- Balance state is the wrong way around, not sure how to interpret those 32 bit at the moment... Needs further research.
- Include energy saver mode to only query important data (my system is driven by that battery, so every µA counts :D)