bs120xenet documentation

The bs120xenet library provides a fully-featured Python library for the Bloomy Controls BS120x battery simulator over Ethernet. This library is a wrapper around the native C/C++ driver for the BS120x to avoid unnecessary Python performance overhead.

Note

This driver currently supports the BS1201. If using the BS1200, contact Bloomy for assistance.

A simple example showing how to connect to a BS120x and control a single cell:

 1#!/usr/bin/env python
 2
 3"""Shows how to control and measure a single cell."""
 4
 5from bs120xenet import Bs120xEnet
 6from time import sleep
 7import sys
 8
 9def single_cell_demo(interface_ip: str, device_ip: str, udp_port: int):
10    """Demonstrates controlling and measuring a single cell.
11    
12    Args:
13        interface_ip: The IP address of the local NIC to connect on.
14        device_ip: The IP address of the BS120x unit.
15        udp_port: The UDP data port of the BS120x.
16    """
17
18    with Bs120xEnet() as client:
19        client.connect(interface_ip, device_ip, udp_port)
20
21        # command Cell 0 to 5.0V with sinking and sourcing current limits set to 0.5A.
22        client.set_cell_sink_current(0, 0.5)
23        client.set_cell_source_current(0, 0.5)
24        client.set_cell_voltage(0, 5.0)
25
26        # enable the cell
27        client.enable_cell(0, True)
28
29        # allow some time for the cell to settle
30        sleep(0.1)
31
32        # read back voltage and current for Cell 0
33        vmeas = client.get_cell_voltage(0)
34        imeas = client.get_all_cell_current(0)
35
36        print(f"Measured {vmeas:.4f}V at {imeas:.4f}A")
37
38        # disable the cell and disconnect
39        client.enable_cell(0, False)
40        client.disconnect()
41
42if __name__ == '__main__':
43    if len(sys.argv) != 4:
44        print(f"usage: {sys.argv[0]} Interface IP, Device IP, UDP Port", file=sys.stderr)
45        exit(1)
46    
47    single_cell_demo(sys.argv[1], sys.argv[2], sys.argv[3])

Known bugs

See the issue tracker on Github. Contributions welcome!

Documentation generated

Apr 28, 2026