Skip to main content

Client for Daly BMS

Project description

This is a Python module for reading data from Daly BMS devices. It supports serial as well as Bluetooth connections. Not all commands that the BMS supports are implemented yet, please take a look at the examples below to see if it serves your needs.

Compatibility

There are two different types of devices sold under the Daly Brand, which use different communication protocols. This module was initially written for BMS supported by the Windows program BMS monitor. Later (in #1) the support for BMS supported by the BMStool, also known as Sinowealth, was added. They don't support all commands of the first protocol, but still provide valuable information.

There are two ways to check if your BMS is supported:

  1. First run daly-bms-cli normally and see if --soc returns data. If not, run it again while adding --sinowealth, which switches to the other protocol.
  2. Connect the BMS to a Windows computer, run the PC tools provided by Daly (Download) and see which one works.

If you make it work with the Windows software, but not with daly-bms-cli, feel free to create a bug report.

Installation

From PyPI

pip3 install dalybms

From Git

git clone https://github.com/dreadnought/python-daly-bms.git
cd python-daly-bms
sudo python3 setup.py install

Dependencies

For serial connections:

pip3 install pyserial

For bluetooth connections:

pip3 install bleak

For MQTT:

pip3 install paho-mqtt

CLI

daly-bms-cli is a reference implementation for this module, but can also be used to test the connection or use it in combination with other programming languages. The data gets returned in JSON format. It doesn't support Bluetooth connections yet.

Usage

# daly-bms-cli --help
usage: daly-bms-cli [-h] -d DEVICE [--uart] [--sinowealth] [--status] [--soc] [--mosfet] [--cell-voltages] [--temperatures] [--balancing] [--errors] [--all] [--check] [--set-discharge-mosfet SET_DISCHARGE_MOSFET] [--set-soc] [--retry RETRY] [--verbose] [--mqtt]
                    [--mqtt-hass] [--mqtt-topic MQTT_TOPIC] [--mqtt-broker MQTT_BROKER] [--mqtt-port MQTT_PORT] [--mqtt-user MQTT_USER] [--mqtt-password MQTT_PASSWORD]

optional arguments:
  -h, --help            show this help message and exit
  -d DEVICE, --device DEVICE
                        RS485 device, e.g. /dev/ttyUSB0
  --uart                UART instead of RS485
  --sinowealth          BMS with Sinowealth chip
  --status              show status
  --soc                 show voltage, current, SOC
  --mosfet              show mosfet status
  --cell-voltages       show cell voltages
  --temperatures        show temperature sensor values
  --balancing           show cell balancing status
  --errors              show BMS errors
  --all                 show all
  --check               Nagios style check
  --set-discharge-mosfet SET_DISCHARGE_MOSFET
                        'on' or 'off'
  --set-soc SET_SOC     0.0 to 100.0
  --retry RETRY         retry X times if the request fails, default 5
  --verbose             Verbose output
  --mqtt                Write output to MQTT
  --mqtt-hass           MQTT Home Assistant Mode
  --mqtt-topic MQTT_TOPIC
                        MQTT topic to write to. default daly_bms
  --mqtt-broker MQTT_BROKER
                        MQTT broker (server). default localhost
  --mqtt-port MQTT_PORT
                        MQTT port. default 1883
  --mqtt-user MQTT_USER
                        Username to authenticate MQTT with
  --mqtt-password MQTT_PASSWORD
                        Password to authenticate MQTT with

Examples:

Get the State of Charge:

# daly-bms-cli  -d /dev/ttyUSB0 --soc
{
  "total_voltage": 57.7,
  "current": -11.1,
  "soc_percent": 99.1
}

Get everything possible:

# daly-bms-cli  -d /dev/ttyUSB0 --all
{
  "soc": {
    "total_voltage": 52.5,
    "current": 0.0,
    "soc_percent": 18.9
  },
  "cell_voltage_range": {
    "highest_voltage": 3.78,
    "highest_cell": 14,
    "lowest_voltage": 3.728,
    "lowest_cell": 1
  },
  "temperature_range": {
    "highest_temperature": 15,
    "highest_sensor": 1,
    "lowest_temperature": 15,
    "lowest_sensor": 1
  },
  "mosfet_status": {
    "mode": "stationary",
    "charging_mosfet": true,
    "discharging_mosfet": true,
    "capacity_ah": 5.67
  },
  "status": {
    "cells": 14,
    "temperature_sensors": 1,
    "charger_running": false,
    "load_running": false,
    "states": {
      "DI1": false,
      "DI2": true
    },
    "cycles": 21
  },
  "cell_voltages": {
    "1": 3.728,
    "2": 3.734,
    "3": 3.734,
    "4": 3.736,
    "5": 3.736,
    "6": 3.742,
    "7": 3.757,
    "8": 3.766,
    "9": 3.768,
    "10": 3.761,
    "11": 3.744,
    "12": 3.78,
    "13": 3.749,
    "14": 3.78
  },
  "temperatures": {
    "1": 15
  },
  "balancing_status": {
    "error": "not implemented"
  },
  "errors": [
    "SOC is too low. level one alarm"
  ]
}

Send SOC data to a MQTT broker:

# daly-bms-cli -d /dev/ttyUSB0 --soc --mqtt --mqtt-broker 192.168.1.123

Notes

Bluetooth

  • It's also recommended to have a recent BlueZ installed (>=5.53).

    The Bluetooth connection uses asyncio for the connection, so the data is received asynchronous.

  • It seems like the Bluetooth BMS Module goes to sleep after 1 hour of inactivity (no load or charging), while the serial connection responds all the time. Sending a command via the serial interface wakes up the Bluetooth module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dalybms-0.4.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

dalybms-0.4.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file dalybms-0.4.0.tar.gz.

File metadata

  • Download URL: dalybms-0.4.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for dalybms-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a5fe146ae71c1984759bfc996d081be6a3c395a9b1e1e8b43e0960bb7968583f
MD5 8161750577f5e87384ef2b4239ae831a
BLAKE2b-256 141394b006307c5491e44a01b1d71f5ba5f4b0d1c8c9c1a77d7daffa379423c2

See more details on using hashes here.

File details

Details for the file dalybms-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: dalybms-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for dalybms-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe1f5a824e1e2fea772fc483602d4b52d8fdcc472be7cf07b60fd98c865da2b
MD5 7960d47dd96cfe8c02f229fdc6e11ba4
BLAKE2b-256 6abb493de763e76c9a2d2bc7a6fb9da5af689a76b98a7e420df9e4cfc100dd64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page