Xiaoxiang bms

First thing is that Batmon-HA integration is working FANTASTIC for my TEMGOT 100ah Smart Version with JBD BMS built into the battery. Ordered a inexpensive Bluetooth dongle, added home assistant Bluetooth integration, MQTT setup, added - address: XX:XX:XX:XX:XX:XX with type JBD and MQTT creds to Batmon configuration and instantly data has been flowing flawlessly into HA ever since. The problem that I am having is now distance. Move the battery away from the Bluetooth dongle more then 6 feet and of course no more data. Then I thought well that should be an easy fix by using these esphome BT proxies everybody is talking about. WOW was I wrong! I have been able to wrap my head around ESPHOME in HA and get 3 proxies up and running with the integration functioning properly with BLE sensors like the MiFlora plant sensors but have been banging my head into the wall several times trying to figure out how to get Batmon to function over one of the proxies. I can not find anywhere in the Batmon add on to force the connection to use the proxy instead of the Bluetooth Dongle. Any help would be greatly appreciated!

I’m not sure how to setup Batmon for bluetooth proxies, but you could get a long usb extension cable and a BT dongle and move it close to the battery.

Unfortunately the battery is located about 400 feet away in the solar shed from the HA server. But I do appreciate the suggestion!

1 Like

Can you get Wifi out there? I’m using the BT Proxy on an esp32. Pretty easy to setup and works like a champ. I mean, I’m assuming the data is coming through the proxy because anything Bluetooth direct seems like horrible range but I’m also using a long range BT adapter on my HA box. You’re not forcing anything, it just automatically creates a mesh/bridge.

Wifi is solid in the solar shed. I think this is where I am stuck. I do know the proxy is working because my miflora bluetooth plant sensor is connected and working on that same proxy. I am under the impression that the BT proxies would be just like Zigbee and Zwave and it would just repeat the data as you build up a mesh network. But when I look at the logs of Batmon it will only try to connect using the BT dongle on the HA server. I was hoping I could just find where to edit how Batmon connects to Bluetooth.

And the miflora are out there too? I have an esp32 w/ proxy enabled about 4 feet from the BMS. I’m also using a long range (EDUP) Bluetooth adapter and disabled the internal Bluetooth on my HA box. Sadly my greenhouse is only about 50 feet from the adapter through a couple walls. I wish I had 400 feet of property :wink: If you’re using the app it’s worth trying to head out to the shed, start the Batmon instance then unplug the BT adapter from the BMS and plug it back in. See if that helps at all. I do find that Batmon occasionally stops but they may be from loss of comms here and there.

Unable to unplug the BT adapter from the BMS. It is a sealed 100ah smart battery. battery

I am curious what steps you took to install/compile your esp32’s?

Oh! Haha. I’m used to the external with DIY packs and the BT is a dongle on a cable. As long as your ESP32 has Bluetooth then below is all I have at the end of my yaml file. IIRC only bluetooth_proxy: is needed but I cut and paste from everywhere so who knows where I ended up with ble_tracker part.

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
1 Like

SUCCESS! I was not able to get Batmon to work but penquinponics post led me down the correct rabbit hole! Ended up finding syssi/esphome-jbd-bms I re-compiled one of my proxies and VOILÀ. I have added my esphome yaml below for anybody that needs it. Thank you every one for the suggestions.

substitutions:
name: jbd-bms-ble-proxy
device_description: “Monitor and control a Xiaoxiang Battery Management System (JBD-BMS) via BLE”
external_components_source: github://syssi/esphome-jbd-bms@main
mac_address: XX:XX:XX:XX:XX:XX < MAC ADDRESS OF BATTERY HERE

esphome:
name: ${name}
comment: ${device_description}
project:
name: “syssi.esphome-jbd-bms”
version: 1.4.0

esp32:
board: wemos_d1_mini32
framework:
type: esp-idf
version: latest

external_components:

  • source: ${external_components_source}
    refresh: 0s

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

manual_ip:
static_ip: xxx.xxx.xxx.xxx < Assign static IP address of proxy
gateway: xxx.xxx.xxx.xxx
subnet: 255.255.255.0

ota:
logger:

api:
encryption:
key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx < HA API encryption key

esp32_ble_tracker:
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind(“xiaoxiang”, 0) == 0) {
ESP_LOGI(“ble_adv”, “New JBD-BMS found”);
ESP_LOGI(“ble_adv”, " Name: %s", x.get_name().c_str());
ESP_LOGI(“ble_adv”, " MAC address: %s", x.address_str().c_str());
ESP_LOGD(“ble_adv”, " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD(“ble_adv”, " - %s", uuid.to_string().c_str());
}
}
ble_client:

  • id: client0
    mac_address: ${mac_address}

jbd_bms_ble:

  • id: bms0
    ble_client_id: client0
    update_interval: 2s

binary_sensor:

  • platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    balancing:
    name: “${name} balancing”
    charging:
    name: “${name} charging”
    discharging:
    name: “${name} discharging”

sensor:

  • platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    battery_strings:
    name: “${name} battery strings”
    current:
    name: “${name} current”
    power:
    name: “${name} power”
    charging_power:
    name: “${name} charging power”
    discharging_power:
    name: “${name} discharging power”
    state_of_charge:
    name: “${name} state of charge”
    nominal_capacity:
    name: “${name} nominal capacity”
    charging_cycles:
    name: “${name} charging cycles”
    capacity_remaining:
    name: “${name} capacity remaining”
    battery_cycle_capacity:
    name: “${name} battery cycle capacity”
    total_voltage:
    name: “${name} total voltage”
    average_cell_voltage:
    name: “${name} average cell voltage”
    delta_cell_voltage:
    name: “${name} delta cell voltage”
    min_cell_voltage:
    name: “${name} min cell voltage”
    max_cell_voltage:
    name: “${name} max cell voltage”
    min_voltage_cell:
    name: “${name} min voltage cell”
    max_voltage_cell:
    name: “${name} max voltage cell”
    temperature_1:
    name: “${name} temperature 1”
    temperature_2:
    name: “${name} temperature 2”
    temperature_3:
    name: “${name} temperature 3”
    temperature_4:
    name: “${name} temperature 4”
    temperature_5:
    name: “${name} temperature 5”
    temperature_6:
    name: “${name} temperature 6”
    cell_voltage_1:
    name: “${name} cell voltage 1”
    cell_voltage_2:
    name: “${name} cell voltage 2”
    cell_voltage_3:
    name: “${name} cell voltage 3”
    cell_voltage_4:
    name: “${name} cell voltage 4”
    cell_voltage_5:
    name: “${name} cell voltage 5”
    cell_voltage_6:
    name: “${name} cell voltage 6”
    cell_voltage_7:
    name: “${name} cell voltage 7”
    cell_voltage_8:
    name: “${name} cell voltage 8”
    cell_voltage_9:
    name: “${name} cell voltage 9”
    cell_voltage_10:
    name: “${name} cell voltage 10”
    cell_voltage_11:
    name: “${name} cell voltage 11”
    cell_voltage_12:
    name: “${name} cell voltage 12”
    cell_voltage_13:
    name: “${name} cell voltage 13”
    cell_voltage_14:
    name: “${name} cell voltage 14”
    cell_voltage_15:
    name: “${name} cell voltage 15”
    cell_voltage_16:
    name: “${name} cell voltage 16”
    cell_voltage_17:
    name: “${name} cell voltage 17”
    cell_voltage_18:
    name: “${name} cell voltage 18”
    cell_voltage_19:
    name: “${name} cell voltage 19”
    cell_voltage_20:
    name: “${name} cell voltage 20”
    cell_voltage_21:
    name: “${name} cell voltage 21”
    cell_voltage_22:
    name: “${name} cell voltage 22”
    cell_voltage_23:
    name: “${name} cell voltage 23”
    cell_voltage_24:
    name: “${name} cell voltage 24”
    cell_voltage_25:
    name: “${name} cell voltage 25”
    cell_voltage_26:
    name: “${name} cell voltage 26”
    cell_voltage_27:
    name: “${name} cell voltage 27”
    cell_voltage_28:
    name: “${name} cell voltage 28”
    cell_voltage_29:
    name: “${name} cell voltage 29”
    cell_voltage_30:
    name: “${name} cell voltage 30”
    cell_voltage_31:
    name: “${name} cell voltage 31”
    cell_voltage_32:
    name: “${name} cell voltage 32”
    operation_status_bitmask:
    name: “${name} operation status bitmask”
    errors_bitmask:
    name: “${name} errors bitmask”
    balancer_status_bitmask:
    name: “${name} balancer status bitmask”
    software_version:
    name: “${name} software version”

text_sensor:

  • platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    errors:
    name: “${name} errors”
    operation_status:
    name: “${name} operation status”
    device_model:
    name: “${name} device model”

switch:

  • platform: ble_client
    ble_client_id: client0
    name: “${name} enable bluetooth connection”

  • platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    charging:
    name: “${name} charging”
    discharging:
    name: “${name} discharging”
    balancer:
    name: “${name} balancer”


3 Likes

Something I forgot to mention is that you can also publish to MQTT broker instead of HA. Both ways work for me. I chose to stick with HA. ESPHome MQTT YAML below.

substitutions:
  name: jbd-bms-ble
  device_description: "Monitor and control a Xiaoxiang Battery Management System (JBD-BMS) via BLE"
  external_components_source: github://syssi/esphome-jbd-bms@main
  mac_address: xx:xx:xx:xx:xx:xx

esphome:
  name: ${name}
  comment: ${device_description}
  project:
    name: "syssi.esphome-jbd-bms"
    version: 1.4.0

esp32:
  board: wemos_d1_mini32
  framework:
    type: esp-idf
    version: latest

external_components:
  - source: ${external_components_source}
    refresh: 0s

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: xxx.xxx.xxx.xxx
    gateway: xxx.xxx.xxx.xxx
    subnet: 255.255.255.0

ota:
logger:

mqtt:
  broker: !secret mqtt_host
  username: !secret mqtt_username
  password: !secret mqtt_password
  id: mqtt_client

esp32_ble_tracker:
  on_ble_advertise:
    then:
      - lambda: |-
          if (x.get_name().rfind("xiaoxiang", 0) == 0) {
            ESP_LOGI("ble_adv", "New JBD-BMS found");
            ESP_LOGI("ble_adv", "  Name: %s", x.get_name().c_str());
            ESP_LOGI("ble_adv", "  MAC address: %s", x.address_str().c_str());
            ESP_LOGD("ble_adv", "  Advertised service UUIDs:");
            for (auto uuid : x.get_service_uuids()) {
              ESP_LOGD("ble_adv", "    - %s", uuid.to_string().c_str());
            }
          }
ble_client:
  - id: client0
    mac_address: ${mac_address}

jbd_bms_ble:
  - id: bms0
    ble_client_id: client0
    update_interval: 2s

binary_sensor:
  - platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    balancing:
      name: "${name} balancing"
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"

sensor:
  - platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    battery_strings:
      name: "${name} battery strings"
    current:
      name: "${name} current"
    power:
      name: "${name} power"
    charging_power:
      name: "${name} charging power"
    discharging_power:
      name: "${name} discharging power"
    state_of_charge:
      name: "${name} state of charge"
    nominal_capacity:
      name: "${name} nominal capacity"
    charging_cycles:
      name: "${name} charging cycles"
    capacity_remaining:
      name: "${name} capacity remaining"
    battery_cycle_capacity:
      name: "${name} battery cycle capacity"
    total_voltage:
      name: "${name} total voltage"
    average_cell_voltage:
      name: "${name} average cell voltage"
    delta_cell_voltage:
      name: "${name} delta cell voltage"
    min_cell_voltage:
      name: "${name} min cell voltage"
    max_cell_voltage:
      name: "${name} max cell voltage"
    min_voltage_cell:
      name: "${name} min voltage cell"
    max_voltage_cell:
      name: "${name} max voltage cell"
    temperature_1:
      name: "${name} temperature 1"
    temperature_2:
      name: "${name} temperature 2"
    temperature_3:
      name: "${name} temperature 3"
    temperature_4:
      name: "${name} temperature 4"
    temperature_5:
      name: "${name} temperature 5"
    temperature_6:
      name: "${name} temperature 6"
    cell_voltage_1:
      name: "${name} cell voltage 1"
    cell_voltage_2:
      name: "${name} cell voltage 2"
    cell_voltage_3:
      name: "${name} cell voltage 3"
    cell_voltage_4:
      name: "${name} cell voltage 4"
    cell_voltage_5:
      name: "${name} cell voltage 5"
    cell_voltage_6:
      name: "${name} cell voltage 6"
    cell_voltage_7:
      name: "${name} cell voltage 7"
    cell_voltage_8:
      name: "${name} cell voltage 8"
    cell_voltage_9:
      name: "${name} cell voltage 9"
    cell_voltage_10:
      name: "${name} cell voltage 10"
    cell_voltage_11:
      name: "${name} cell voltage 11"
    cell_voltage_12:
      name: "${name} cell voltage 12"
    cell_voltage_13:
      name: "${name} cell voltage 13"
    cell_voltage_14:
      name: "${name} cell voltage 14"
    cell_voltage_15:
      name: "${name} cell voltage 15"
    cell_voltage_16:
      name: "${name} cell voltage 16"
    cell_voltage_17:
      name: "${name} cell voltage 17"
    cell_voltage_18:
      name: "${name} cell voltage 18"
    cell_voltage_19:
      name: "${name} cell voltage 19"
    cell_voltage_20:
      name: "${name} cell voltage 20"
    cell_voltage_21:
      name: "${name} cell voltage 21"
    cell_voltage_22:
      name: "${name} cell voltage 22"
    cell_voltage_23:
      name: "${name} cell voltage 23"
    cell_voltage_24:
      name: "${name} cell voltage 24"
    cell_voltage_25:
      name: "${name} cell voltage 25"
    cell_voltage_26:
      name: "${name} cell voltage 26"
    cell_voltage_27:
      name: "${name} cell voltage 27"
    cell_voltage_28:
      name: "${name} cell voltage 28"
    cell_voltage_29:
      name: "${name} cell voltage 29"
    cell_voltage_30:
      name: "${name} cell voltage 30"
    cell_voltage_31:
      name: "${name} cell voltage 31"
    cell_voltage_32:
      name: "${name} cell voltage 32"
    operation_status_bitmask:
      name: "${name} operation status bitmask"
    errors_bitmask:
      name: "${name} errors bitmask"
    balancer_status_bitmask:
      name: "${name} balancer status bitmask"
    software_version:
      name: "${name} software version"

text_sensor:
  - platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    errors:
      name: "${name} errors"
    operation_status:
      name: "${name} operation status"
    device_model:
      name: "${name} device model"

switch:
  - platform: ble_client
    ble_client_id: client0
    name: "${name} enable bluetooth connection"

  - platform: jbd_bms_ble
    jbd_bms_ble_id: bms0
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
    balancer:
      name: "${name} balancer"

ESPHome Proxy

@flap testing energy but need to wait for data to populate(couple hours) thanks for another great update!

that’s awesome!! glad you got it! thanks for sharing!

I hope someone can help me. My battery BMS died so I replaced it with this BMS: https://www.aliexpress.us/item/2251832690490282.html?spm=a2g0o.order_detail.order_detail_item.3.2909f19ciAOAtF&gatewayAdapt=glo2usa
A Xiaoxiang 13s BMS with Bluetooth. I am using the same charger I always used which is a 4A charger. Now it will not charge at more than .5A. I am hoping there is a setting in the BMS that will let it charge at a higher rate, but I cannot find one. Does anyone have any knowledge about this? Thank you all in advance.

Start with the mobile app and check all your settings. Make sure your cells are balanced. Double check your wiring. I’m running two of the JBD branded ones. I wish I could say without issue but the Bluetooth likes to come and go so Batmon stops running. Hardware seems great though. Ideally I’ll be moving to an esp32 wifi solution in the coming months.

What if I have multiple bms’?

Great thx! As I see, one mac address hardcoded … so impossible to read several batteries?

  • address: device1
    type:
    alias: bms1
  • address: device2
    type:
    alias: bms2
  • address: repeat as needed

I’m stumped. I have 3 batteries. Just trying to get one of them working first before adding the others. I have the MAC addresses. When I put one of the MAC addresses in the esphome yaml, no matter which one I put in there, it shows up as “Not Connected” in the Logs. It shows the other 2 batteries as new/discovered. Why would this happen?



Ooh, I didn’t realize auto discovery works. What’s your config look like? Mine is literally six lines for my two BMS.