Coder Social home page Coder Social logo

python-daly-bms's Introduction

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.

python-daly-bms's People

Contributors

abraham-hdez avatar birdie1 avatar dreadnought avatar jgimbel avatar sand1812 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-daly-bms's Issues

Is it possible to use our cmd tool to set certain parameters?

Firstly thanks for the great work, it works out of the box for me.

My BMS arrived without a bluetooth module, so I cannot connect it with my phone to setup it's parameters and that is why the SOC reading seems wrong.

I am not sure exactly how to correct it yet but it would be nice if we could support setting some important values as the bluetooth app (or the pc software) can do on it.

I also don't have a windows pc so cannot use the pc tool they provided...

Error "UTC: Under Voltage in Charge" at low Temperature (sinowealth)

I would expect a message like "Charging temperature too low" but not "UTC: Under Voltage in Charge".
And what does "UTC: Under Voltage in Charge" mean?
I'm also wondering about "CHGMOS: Charging enabled". Shouldn't it be disabled at this temperatur?

Here the output:

"soc": { "total_voltage": 13.271, "current": -0.149, "soc_percent": 95.0 }, "mosfet_status": { "full_capacity_ah": 280.0, "remaining_capacity_ah": 267.36, "pack_state": [ "FAST_DSG: Fast Discharging", "DSGING: Discharging", "DSGMOS: Discharging enabled", "CHGMOS: Charging enabled" ] }, "status": { "cycles": 12 }, "cell_voltages": { "1": 3.315, "2": 3.327, "3": 3.32, "4": 3.312 }, "temperatures": { "external1": -8.4, "external2": 0.1 }, "errors": [ "UTC: Under Voltage in Charge" ] }

--sinowealth —all

this brings an error that getall is not implemented…. i would like to integrate it in my system and send every minute this request.

daly-bms-cli: error: unrecognized arguments: --getall

the rest is working! great job

Incorrect cell count and volts

Now I have the problem that with my 4S, it tries to read 10 cells and displays wrong values. First it worked correctly, I have not made any changes and I do not know what the problem is. Until about 2 hours ago it was working without any problems. I added an Influxdb client to the script yesterday and have all the data logged every minute and suddenly since two hours I get wrong values, even with your original script. Thanks for your work a really helpful tool.

 pi@womopi:~ $ daly-bms-cli -d /dev/ttyUSB1 --sinowealth --cell-voltage
{
  "1": 10.636,
  "2": 14.984,
  "3": 3.088,
  "4": -21.43,
  "5": -17.351,
  "6": 3.286,
  "7": -26.467,
  "8": 3.088,
  "9": -21.43,
  "10": -17.351
}

at my 16s all works well

hab2:~$ daly-bms-cli -d /dev/ttyUSB1 --cell-voltage
{
  "1": 3.375,
  "2": 3.376,
  "3": 3.375,
  "4": 3.39,
  "5": 3.375,
  "6": 3.383,
  "7": 3.387,
  "8": 3.392,
  "9": 3.401,
  "10": 3.378,
  "11": 3.387,
  "12": 3.394,
  "13": 3.431,
  "14": 3.452,
  "15": 3.447,
  "16": 3.44
}

I have now changed the USB port several times and now it works again. Sorry

pi@womopi:~/python-daly-bms $ daly-bms-cli -d /dev/ttyUSB1 --sinowealth --cell-voltage
{
  "1": 3.168,
  "2": 3.171,
  "3": 3.173,
  "4": 3.17
}

Sinowealth does to seem to support battery packs more than 10s

It looks like BMSTool - Sinowealth only supports up to monitoring of 10 cells. And when I connected my BMS it shows all incorrect results. For example total voltage seems to be the voltage of 11th cell and SOC and temperature are all wrong.

I did some changes to sinowealth python script for it to iterate through 16 cells and it shows up to 15 cells and then again 16th cell is wrong

$ daly-bms-cli -d /dev/cu.usbserial-1440 --sinowealth --cell-voltages --verbose
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x01\x02'), 0a0102
DEBUG [daly_sinowealth.py:91] 0e7dbf (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 1 is 3709
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x02\x02'), 0a0202
DEBUG [daly_sinowealth.py:91] 0e7d85 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 2 is 3709
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x03\x02'), 0a0302
DEBUG [daly_sinowealth.py:91] 0e7d93 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 3 is 3709
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x04\x02'), 0a0402
DEBUG [daly_sinowealth.py:91] 0e7ef8 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 4 is 3710
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x05\x02'), 0a0502
DEBUG [daly_sinowealth.py:91] 0e7fe9 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 5 is 3711
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x06\x02'), 0a0602
DEBUG [daly_sinowealth.py:91] 0e7ddd (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 6 is 3709
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x07\x02'), 0a0702
DEBUG [daly_sinowealth.py:91] 0e7ec2 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 7 is 3710
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x08\x02'), 0a0802
DEBUG [daly_sinowealth.py:91] 0e7d19 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 8 is 3709
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\t\x02'), 0a0902
DEBUG [daly_sinowealth.py:91] 0e80f2 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 9 is 3712
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\n\x02'), 0a0a02
DEBUG [daly_sinowealth.py:91] 0e7e3c (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 10 is 3710
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x0b\x02'), 0a0b02
DEBUG [daly_sinowealth.py:91] 0e7e2a (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 11 is 3710
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x0c\x02'), 0a0c02
DEBUG [daly_sinowealth.py:91] 0e80bc (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 12 is 3712
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\r\x02'), 0a0d02
DEBUG [daly_sinowealth.py:91] 0e7f59 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 13 is 3711
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x0e\x02'), 0a0e02
DEBUG [daly_sinowealth.py:91] 0e7f63 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 14 is 3711
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x0f\x02'), 0a0f02
DEBUG [daly_sinowealth.py:91] 0e7f75 (3)
DEBUG [daly_sinowealth.py:102] Response data for cell 15 is 3711
DEBUG [daly_sinowealth.py:61] message: bytearray(b'\n\x10\x04'), 0a1004
DEBUG [daly_sinowealth.py:91] 0e7f0000a6 (5)
DEBUG [daly_sinowealth.py:102] Response data for cell 16 is 243204096

In this you can see 0B is cell voltage of 11th cell now.

Given that PC application only supports up to 10 cells, I've used android phone to capture bluetooth messages
btsnoop_hci.log. I don't know how to read this but android application shows data correctly.

3S-4S Daly BMS with Sinowealth chip are not supported

Hey,

first of all: Thanks for your work and this Projekt.

And maybe this Error is only a Problem of my Setup.

I have a Daly Smart BMS 4S 12V 100A.
This BMS is connected via the Monitor Port and the original cable with an Lubuntu (Ubuntu 18.04.5 LTS). (With this cable I can read the data and configure the BMS through the sinowealth software from a windows PC)

samuel@nb-lubuntu:~$ python3 --version
Python 3.6.9

samuel@nb-lubuntu:~$ pip3 show pyserial
Name: pyserial
Version: 3.5
Summary: Python Serial Port Extension
Home-page: https://github.com/pyserial/pyserial
Author: Chris Liechti
Author-email: [email protected]
License: BSD
Location: /home/samuel/.local/lib/python3.6/site-packages
Requires:

I have also set the right permission to the user (Added the user to the group dialout)

But I still get no data from my BMS. Instead I get the following Error:
samuel@nb-lubuntu:~$ daly-bms-cli -d /dev/ttyUSB0 --soc
ERROR [daly_bms.py:88] 94 failed after 5 tries
ERROR [daly_bms.py:88] 90 failed after 5 tries
false

Which BMS do you use and how is it connected? Do you connect your BMS with UART-Port? At the moment it is used by the Bluetooth-Dongle and I have no USB-Calbe for UART.

I hope you can help me with my problems.
Sam

ResolutionError: Script 'scripts/daly-bms-cli' not found in metadata

Hi
I'm using python 3.9 in Ubuntu 20.04 and trying to connect to a Daly BMS using USB, but getting this error (using sudo but same error as user):
tony@tony-acer:~$ sudo daly-bms-cli -d /dev/ttyUSB0 --sinowealth
[sudo] password for tony:
Traceback (most recent call last):
File "/usr/local/bin/daly-bms-cli", line 4, in
import('pkg_resources').run_script('dalybms==0.3.0', 'daly-bms-cli')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 651, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1436, in run_script
raise ResolutionError(
pkg_resources.ResolutionError: Script 'scripts/daly-bms-cli' not found in metadata at '/usr/local/lib/python3.9/dist-packages/dalybms-0.3.0.dist-info'

I installed using pip3, but it seems a script is missing? Can you suggest a solution?
Thanks

After Update it's not running anymore

I don't know why i get this:

~ $ daly-bms-cli -d /dev/ttyUSB0 --sinowealth --all
Traceback (most recent call last):
  File "/usr/local/bin/daly-bms-cli", line 183, in <module>
    result = bms.get_all()
  File "/usr/local/lib/python3.7/dist-packages/dalybms/daly_sinowealth.py", line 228, in get_all
    "mosfet_status": self.get_mosfet_status(),
  File "/usr/local/lib/python3.7/dist-packages/dalybms/daly_sinowealth.py", line 198, in get_mosfet_status
    if pack_response[key] == "1":
TypeError: 'bool' object is not subscriptable

BR
Achilles

Precision - DalyBMS

Hi!

I was reading this post here

It is mentioned that they calibrate the voltage and current measurements with a 6 1/2 digit resolution HP/Agilent meter but from the program, this precision isn't displayed. Is there a way to modify and get the higher precision?

Thank you always!
Nesrine

MQTT values incorrect

Hello,
During the MQTT transmission, the BMS temperature is displayed for the first accu.
This seems to be because in the shell both values start with a 1.

Bluetooth connection - which device ?

I'm trying to set up a connection with the Daly BMS over Bluetooth. But I can't find any documentation regarding which -d parameter to use to do this.
Does anyone know the simple steps ?
I've seen some complex scripts from a different library, but those all require additional packages that pip can't seem to find...

multiple boards

Hi, is there a way to monitor 2+ boards via RS485 with one adapter and this software?

UART sleep

I use the script with node red to manage my battery.

After a while the command:
daly-bms-cli -d /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 --all

returns the same data inconsistently. For the correct data to come back I have to unplug and plug the USB-UART back in.

Here is the return of the command when it does not work correctly:

daly-bms-cli -d /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 --all { "soc": { "total_voltage": 0.0, "current": -3000.0, "soc_percent": 0.0 }, "cell_voltage_range": { "highest_voltage": 0.0, "highest_cell": 0, "lowest_voltage": 0.0, "lowest_cell": 0 }, "temperature_range": { "highest_temperature": -40, "highest_sensor": 0, "lowest_temperature": -40, "lowest_sensor": 0 }, "mosfet_status": { "mode": "stationary", "charging_mosfet": false, "discharging_mosfet": false, "capacity_ah": 0.0 }, "status": { "cells": 0, "temperature_sensors": 0, "charger_running": false, "load_running": false, "states": { "DI1": false }, "cycles": 0 }, "cell_voltages": null, "temperatures": null, "balancing_status": { "error": "not implemented" }, "errors": [] }

only the raspberry pi is connected to my battery. Daly returns me a consumption of 0 A while in charge I could clearly see 20A. I have in parallel a shunt and an ina226 which gives me a consumption of around 0.3 A.

NO ISSUE Newbee is looking for a helping / example script

Hello World, sorry but I am a beginner in this thing... would anyone give me a helping hand and show me how to use this Dalybms script... I get it to work in the Terminal by -cli.... but how do I get values inside a python script to send it to Blynk or wherever...
Thank you very much... an example would be more than welcome.
Cheers
Stefan

--mqtt-hass option do not send any messages to the mqtt broker

Hi,

i'm trying to send data to home assistant but when i run the script nothing are send to the mqtt broker, what i wrong?
This is the command i run:

root@dockers-deb12:~/daly/python-daly-bms# daly-bms-cli -d /dev/ttyUSB0 --soc --mqtt-hass --mqtt-broker 192.168.1.2 --mqtt-user mqttuser --mqtt-password xxxxxxx
{
  "total_voltage": 54.0,
  "current": 47.3,
  "soc_percent": 35.7
}

UART connector from BMS directly to Raspi GPIO

Hi, I connected the UART connector from BMS directly to my Raspi GPIO ports , and can read the data via /dev/ttyS0 .
I send the data via mqtt to my mqtt iobroker on my Raspberry server. Send script is startetd by crontab every 10sec. But iobroker adapter shows no connection and data will come, but changing of values will not be provided.
I would apriciate for some help.
I connected BMS to my raspi GPIO Ports
connect on raspi at /dev/TTYS0
DALY --------------------- Raspberry Pi
Ground GND – pin 1 Ground e.g. pin 9
Data 1 UART_TX2 – pin 5 RXD – pin 10
Data 2 UART_RX2 – pin 6 TXT – pin 8

To wake up sleeping Daly BMS is use the KaFun method:
All that needs to be done is to short that pin 4 shortly to ground. In my case, I use
an opto coupler (want to be on the safe side) with the opto coupler output transistor‘s emitter connected to ground and
collector connected to pin 4 on the BMS. The opto coupler input is connected via a resistor to GPIO 4 which is pin 7 on the RasPI and the other input pin connected to ground as well.
To activate: Let run the activation script:

#!/usr/bin/env python3
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)

GPIO.output(4, True)
time.sleep(2)
GPIO.output(4, False)
time.sleep(2)

GPIO.cleanup() # cleanup all GPIO

Best wishes
Ralf

running in windows?

Will this run in linux only? It's working great on my Raspberry PI's, but not withing windows.

Voltage of single cell jumps alot

The voltage of my 1. cell is different with every request. These requests were made directly after each other:

{
  "1": 4.258,
  "2": 3.367,
  "3": 3.369,
  "4": 3.366
}
pi@raspberrypi-main:~ $ daly-bms-cli -d /dev/ttyUSB0 --cell-voltage
{
  "1": 3.868,
  "2": 3.367,
  "3": 3.368,
  "4": 3.366
}
pi@raspberrypi-main:~ $ daly-bms-cli -d /dev/ttyUSB0 --cell-voltage
{
  "1": 4.444,
  "2": 3.367,
  "3": 3.369,
  "4": 3.37
}
pi@raspberrypi-main:~ $ daly-bms-cli -d /dev/ttyUSB0 --cell-voltage
{
  "1": 4.307,
  "2": 3.366,
  "3": 3.368,
  "4": 3.363
}
pi@raspberrypi-main:~ $ daly-bms-cli -d /dev/ttyUSB0 --cell-voltage
{
  "1": 4.383,
  "2": 3.366,
  "3": 3.369,
  "4": 3.365
}
pi@raspberrypi-main:~ $ daly-bms-cli -d /dev/ttyUSB0 --cell-voltage
{
  "1": 4.463,
  "2": 3.366,
  "3": 3.369,
  "4": 3.365
}

The iOS app SmartBMS is telling me that the 1. cell is at around 3.6v.

issue after launch command

I have this daly bms, connected via usb cable rs 485 convertor and when I invoke command in attachment, no response.
WhatsApp Image 2023-03-11 at 10 36 09

Not an issue - how to use bluetooth script

I can see that the cli code calls in the python modules, but how can I use the python bluetooth module on its own? When I run the code it runs without error, but that is expected as it is creating the Class etc. How do I actually connect with BT and call the functions?

Issues connection using the Bluetooth class

Hi,

first of all, thanks a lot for this toolbox! Looking forward to use it to read out the battery of my cabin soon to have a bit more information how long I have before my lights here turn off ;).

So I tried something minimal like

from dalybms import DalyBMSBluetooth
import asyncio 
mac_address = "so:me:se:cr:et:11"                  
D = DalyBMSBluetooth()           
asyncio.run( D.connect(mac_address))

Nevertheless, I get an error throw from daly_bms_bluetooth.py line 45:

File "/home/xx/.local/lib/python3.9/site-packages/dalybms/daly_bms_bluetooth.py", line 45, in connect
    await self.client.start_notify(17, self._notification_callback)
  File "/home/xx/.local/lib/python3.9/site-packages/bleak/__init__.py", line 822, in start_notify
    raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 17 not found!

Any idea where I could start debugging this? Is this bluetooth module actually tested or should I use some other library for this use case?

Thanks in advance!

Characteristic 17 not found

Run with following error. It seems that characteristics specified is different in my bluetooth sensor. But it reads data correctly on Android app.

  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/tmp/a.py", line 49, in main
    await con.connect()
  File "/tmp/a.py", line 11, in connect
    await self.bt_bms.connect(mac_address=self.mac_address)
  File "/usr/local/lib/python3.10/dist-packages/dalybms/daly_bms_bluetooth.py", line 45, in connect
    await self.client.start_notify(17, self._notification_callback)
  File "/usr/local/lib/python3.10/dist-packages/bleak/__init__.py", line 639, in start_notify
    raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 17 not found!

ble-deep scan result of daly BLE sensor as below

SERVICE 00001801-0000-1000-8000-00805f9b34fb (Handle: 10): Generic Attribute Profile
     CHARACTERISTIC 00002a05-0000-1000-8000-00805f9b34fb (Handle: 11): Service Changed ['read', 'indicate']
         DESCRIPTOR 00002902-0000-1000-8000-00805f9b34fb (Handle: 13): Client Characteristic Configuration
SERVICE 0000fff0-0000-1000-8000-00805f9b34fb (Handle: 14): Vendor specific
     CHARACTERISTIC 0000fff1-0000-1000-8000-00805f9b34fb (Handle: 15): Vendor specific ['read', 'notify']
         DESCRIPTOR 00002901-0000-1000-8000-00805f9b34fb (Handle: 18): Characteristic User Description
         DESCRIPTOR 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration
     CHARACTERISTIC 0000fff2-0000-1000-8000-00805f9b34fb (Handle: 19): Vendor specific ['read', 'write-without-response', 'write']
         DESCRIPTOR 00002901-0000-1000-8000-00805f9b34fb (Handle: 22): Characteristic User Description
         DESCRIPTOR 00002902-0000-1000-8000-00805f9b34fb (Handle: 21): Client Characteristic Configuration
SERVICE 02f00000-0000-0000-0000-00000000fe00 (Handle: 23): Unknown
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff01 (Handle: 31): Unknown ['write-without-response', 'write']
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff00 (Handle: 29): Unknown ['read']
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff02 (Handle: 26): Unknown ['read', 'notify']
         DESCRIPTOR 00002902-0000-1000-8000-00805f9b34fb (Handle: 28): Client Characteristic Configuration
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff04 (Handle: 33): Unknown ['read', 'write-without-response', 'write', 'notify']
         DESCRIPTOR 00002902-0000-1000-8000-00805f9b34fb (Handle: 35): Client Characteristic Configuration
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff05 (Handle: 36): Unknown ['read', 'write-without-response', 'write']
     CHARACTERISTIC 02f00000-0000-0000-0000-00000000ff03 (Handle: 24): Unknown ['read']

Any directions or hints.

UART port - Sinowealth

Hello!

I have a 4S BMS with sinowealth and I wanted to get the data on an ESP32 board. I hooked the UART of ESP32 to the UART Port BMS and it didnt work. looking at some posts, they mentioned adding RS485-UART converter. I was able to get data this way. My code on the ESP32 is the same as yout daly_sinowealth. however the data was all wrong. Would you happen to know if it needs another kind of library?

On the monitor, I can report it works just fine, no need for conversion!

Best

Missing data/connection for a few hours

Hello! First of all thanks for your awesome peace of software!
I am currently requesting the data of a daly-bms 8s via UART to USB onto a raspberry pi every 30 seconds. This works most of the time but I encounter connection issues around once every 24hrs. They can last from 1h up to 8hrs.
Restarting the raspberry won't help, so I don't think this is the problem. Also the problem will be gone by itself without me needing to help.

Output I am getting is:
DEBUG [daly_bms.py:112] 0 empty response for command 94 DEBUG [daly_bms.py:85] 1. try failed, retrying... DEBUG [daly_bms.py:95] -- 94 ------------------------ DEBUG [daly_bms.py:65] w a5409408000000000000000081 DEBUG [daly_bms.py:112] 0 empty response for command 94 DEBUG [daly_bms.py:85] 2. try failed, retrying... DEBUG [daly_bms.py:95] -- 94 ------------------------ DEBUG [daly_bms.py:65] w a5409408000000000000000081 DEBUG [daly_bms.py:112] 0 empty response for command 94 DEBUG [daly_bms.py:85] 3. try failed, retrying... DEBUG [daly_bms.py:95] -- 94 ------------------------ DEBUG [daly_bms.py:65] w a5409408000000000000000081 DEBUG [daly_bms.py:112] 0 empty response for command 94 DEBUG [daly_bms.py:85] 4. try failed, retrying... DEBUG [daly_bms.py:95] -- 94 ------------------------ DEBUG [daly_bms.py:65] w a5409408000000000000000081 DEBUG [daly_bms.py:112] 0 empty response for command 94 DEBUG [daly_bms.py:85] 5. try failed, retrying... ERROR [daly_bms.py:90] 94 failed after 5 tries ERROR [daly_bms.py:242] get_status has to be called at least once before calling get_cell_voltages ERROR [daly_bms.py:242] get_status has to be called at least once before calling get_cell_voltages DEBUG [daly_bms.py:95] -- 97 ------------------------ DEBUG [daly_bms.py:65] w a5409708000000000000000084 DEBUG [daly_bms.py:112] 0 empty response for command 97 DEBUG [daly_bms.py:85] 1. try failed, retrying... DEBUG [daly_bms.py:95] -- 97 ------------------------ DEBUG [daly_bms.py:65] w a5409708000000000000000084 DEBUG [daly_bms.py:112] 0 empty response for command 97 DEBUG [daly_bms.py:85] 2. try failed, retrying... DEBUG [daly_bms.py:95] -- 97 ------------------------ DEBUG [daly_bms.py:65] w a5409708000000000000000084 DEBUG [daly_bms.py:112] 0 empty response for command 97 DEBUG [daly_bms.py:85] 3. try failed, retrying... DEBUG [daly_bms.py:95] -- 97 ------------------------ DEBUG [daly_bms.py:65] w a5409708000000000000000084 DEBUG [daly_bms.py:112] 0 empty response for command 97 DEBUG [daly_bms.py:85] 4. try failed, retrying... DEBUG [daly_bms.py:95] -- 97 ------------------------ DEBUG [daly_bms.py:65] w a5409708000000000000000084 DEBUG [daly_bms.py:112] 0 empty response for command 97 DEBUG [daly_bms.py:85] 5. try failed, retrying... ERROR [daly_bms.py:90] 97 failed after 5 tries DEBUG [daly_bms.py:95] -- 98 ------------------------ DEBUG [daly_bms.py:65] w a5409808000000000000000085 DEBUG [daly_bms.py:112] 0 empty response for command 98 DEBUG [daly_bms.py:85] 1. try failed, retrying... DEBUG [daly_bms.py:95] -- 98 ------------------------ DEBUG [daly_bms.py:65] w a5409808000000000000000085 DEBUG [daly_bms.py:112] 0 empty response for command 98 DEBUG [daly_bms.py:85] 2. try failed, retrying... DEBUG [daly_bms.py:95] -- 98 ------------------------ DEBUG [daly_bms.py:65] w a5409808000000000000000085 DEBUG [daly_bms.py:112] 0 empty response for command 98 DEBUG [daly_bms.py:85] 3. try failed, retrying... DEBUG [daly_bms.py:95] -- 98 ------------------------ DEBUG [daly_bms.py:65] w a5409808000000000000000085 DEBUG [daly_bms.py:112] 0 empty response for command 98 DEBUG [daly_bms.py:85] 4. try failed, retrying... DEBUG [daly_bms.py:95] -- 98 ------------------------ DEBUG [daly_bms.py:65] w a5409808000000000000000085 DEBUG [daly_bms.py:112] 0 empty response for command 98 DEBUG [daly_bms.py:85] 5. try failed, retrying... ERROR [daly_bms.py:90] 98 failed after 5 tries Traceback (most recent call last): File "/home/lfnidt/.local/bin/daly-bms-cli", line 183, in <module> result = bms.get_all() File "/home/lfnidt/.local/lib/python3.9/site-packages/dalybms/daly_bms.py", line 355, in get_all "errors": self.get_errors() File "/home/lfnidt/.local/lib/python3.9/site-packages/dalybms/daly_bms.py", line 324, in get_errors if int.from_bytes(response_data, byteorder='big') == 0: TypeError: cannot convert 'bool' object to bytes

(Excerpt). Do you have any hints what the problem could be? It'd probably help to restart the BMS but there's no way to to this without being on site right? Or should I try longer intervals to request?

[Enhancement] Turn on and off mosfets

Thanks for this repo! I was looking for ways to interface with my Daly BMS.

Wondering if you have worked/are working on a feature to turn on and off the discharge/charge mosfets? Thank you!

Error due to changes 3~4 days ago?

It seems like the recent changes in code (adding Homassistant?) produced a syntax error.:

pi@raspberrypi:~/python-daly-bms $ daly-bms-cli --help
traceback (most recent call last):
File "/usr/local/bin/daly-bms-cli", line 4, in
import('pkg_resources').run_script('dalybms==0.2.0', 'daly-bms-cli')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1500, in run_script
script_code = compile(script_text, script_filename, 'exec')
File "/usr/local/lib/python3.5/dist-packages/dalybms-0.2.0-py3.5.egg/EGG-INFO/scripts/daly-bms-cli", line 93
hass_config_topic = f'homeassistant/sensor/daly_bms/{base.replace("/", "_")}/config'
^
SyntaxError: invalid syntax

bluetooth support for sinowealth devices

Hi,

I could successfully connect to my BMS using serial and It is obviously sinowealth as it's only working with this option.

I'm trying to do same over bluetooth following the given example.

After some customization, could make the code launch which seems to connect to device, but is not able to request anything then. That wouldn't be surprising if it expects to receive sinowealth requests..

So I wondered if there was currently any support for bluetooth and sinowealth devices?
Looking at the code, it doesn't seem to be the case. Didn't find a specific class for this purpose nor any options we can provide to switch to it.

Any plan to support it in future?

PS: thanks for this tool to replace stock app and open lots of possibilities!

COM port lock under windows - alternating

I'm now trying another daly-BMS, which is a 5s -12 V 40A unit and I have managed to get the script to run under windows 10 using ipython, simply running "daly-bms-cli -d COM3 --all". It outputs everything expected, but interestingly it only works every second run. That is if I run the script once and get the results, if I run it again -- say 30 sec later - I get an error message that:
SerialException could not open port 'COM3' access is denied.
But if I rerun the script it now runs. This cycle seems consistent - run once, fail, run once fail etc. It seems that the COM port gets locked and it takes another run to unlock it. It doesn't seem to make any difference how long I wait between runs.
It's not a serious problem as I'm just using windows while I have the batteryy pack on my desk - I'll go back to linux once the power supply is finished.

mqtt values being published?

SOLVED

Is there a list of mqtt values being published so we can add them to our platform of choice? I see that data when I do mosquitto_sub but I don't see what strings the data belongs to.

Got it!
soc/total_voltage
soc/current
soc/percent
cell_voltage_range/highest_voltage, highest_cell, lowest_voltage, lowest_cell
temperature_range/highest_temperature, highest_sensor, lowest_temperature, lowest_sensor
mosfet_status/mode, charging_mosfet, discharging_mosfet, capacity_ah
status/cells, temperature_sensors, load_running, states/DI1, cycles
cell_voltages/1, 2, 3, etc
temperatures/1

Supported devices - please comment which devices you have

Hi,
my goal here is to gather information about the different BMS models sold under the Daly brand. We know that there are two different models around, the "normal" ones and the ones with "Sinowealth" chip. What's not clear yet is which one you get when you buy a BMS. The initial theory was that 3-10s BMS are Sinowealth and the ones with higher cell numbers the normal ones. But later we saw 16s Sinowealth models, which added new uncertainties.

The Download page for the PC tool says:

Dali PC download address: suitable for R16T, R32S, R32W, R25A, R25T, R32U, R32ND series products
BMStool PC download address: suitable for R05C, R05J, R05A, R05U, R05W, R05ND, R10C, R10J, R16J series products

But the problem they don't write or show these model number in their shop, so it's hard to choose the right one when you're interested in certain features.

What I would like to ask of anyone looking at this ticket is to submit information about their BMS:

  • Product name:
  • Shop URL:
  • Number of cells:
  • Model number written on the device:
  • Identified as Sinowealth? by Windows tool ("Dali PC"=normal, "BMStool PC"=Sinowealth) or daly-bms-cli ("--sinowealth" or without)
  • Tested with daly-bms-cli?

Let's start with my BMS:

  • Product name: Daly Smart BMS 3S-24S Li-Ion LiFePo4 with Bluetooth 14S/60A for Lithium-Battery Pack
  • Shop URL: https://www.aliexpress.com/item/1005001803913333.html
  • Number of cells: 14
  • Model number written on the device: R25T-GC04
  • Identified as Sinowealth? no
  • Tested with daly-bms-cli? yes

No cell_voltages or temperatures Data, Except There Is?

Howdo,

I've a DALY BMS, it seems to be one of the non-sinowealth ones, and I'm able to get loads of data back over UART so it's working.
The odd thing is that though it's telling me how many cells I have, and the high and low values, cell_voltages is null. Same for temperature.

This a known issue or a new one? I couldn't spot it in the open or closed issues so thought I'd raise one.

daly-bms-cli --uart -d /dev/ttyUSB0 --all
ERROR    [daly_bms.py:257] unkonwn status_field cells
ERROR    [daly_bms.py:257] unkonwn status_field temperature_sensors
{
  "soc": {
    "total_voltage": 35.9,
    "current": -1.6,
    "soc_percent": 99.1
  },
  "cell_voltage_range": {
    "highest_voltage": 3.601,
    "highest_cell": 10,
    "lowest_voltage": 3.596,
    "lowest_cell": 1
  },
  "temperature_range": {
    "highest_temperature": 22,
    "highest_sensor": 1,
    "lowest_temperature": 22,
    "lowest_sensor": 1
  },
  "mosfet_status": {
    "mode": "charging",
    "charging_mosfet": true,
    "discharging_mosfet": true,
    "capacity_ah": 12.387
  },
  "status": {
    "cells": 10,
    "temperature_sensors": 1,
    "charger_running": false,
    "load_running": false,
    "states": {
      "DI1": false,
      "DI2": true
    },
    "cycles": 0
  },
  "cell_voltages": null,
  "temperatures": null,
  "balancing_status": {
    "error": "not implemented"
  },
  "errors": []
}

MQTT sees only first value

Hi,

I'm using daly-bms-cli to send Daly BMS data to my mosquitto MQTT server which is then parsed via telegraf into influxdb.

I can see that daly-bms-cli is publishing the data when I start it with --verbose:

daly-bms-cli -d /dev/ttyUSB0 --sinowealth --all --mqtt --mqtt-topic dalybms --mqtt-broker localhost --mqtt-user XXXXXXX --mqtt-password YYYYYYYYYYY --verbose
DEBUG [client.py:2529] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b''
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x0b\x02'), 0a0b02
DEBUG [daly_sinowealth.py:118] 337117 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x10\x04'), 0a1004
DEBUG [daly_sinowealth.py:118] fffff9e3b6 (5)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x13\x02'), 0a1302
DEBUG [daly_sinowealth.py:118] 0021b1 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x11\x04'), 0a1104
DEBUG [daly_sinowealth.py:118] 000445c094 (5)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x12\x04'), 0a1204
DEBUG [daly_sinowealth.py:118] 000173337f (5)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x15\x02'), 0a1502
DEBUG [daly_sinowealth.py:118] 404b8f (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x14\x02'), 0a1402
DEBUG [daly_sinowealth.py:118] 000721 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x01\x02'), 0a0102
DEBUG [daly_sinowealth.py:118] 0cb2f6 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x02\x02'), 0a0202
DEBUG [daly_sinowealth.py:118] 0cf102 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x03\x02'), 0a0302
DEBUG [daly_sinowealth.py:118] 0ce85b (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x04\x02'), 0a0402
DEBUG [daly_sinowealth.py:118] 0cddb2 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x05\x02'), 0a0502
DEBUG [daly_sinowealth.py:118] 000045 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x0c\x02'), 0a0c02
DEBUG [daly_sinowealth.py:118] 0bd244 (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\r\x02'), 0a0d02
DEBUG [daly_sinowealth.py:118] 0aab2f (3)
DEBUG [daly_sinowealth.py:93] message: bytearray(b'\n\x16\x02'), 0a1602
DEBUG [daly_sinowealth.py:118] 000018 (3)
DEBUG [daly-bms-cli:131] Send data: 13.169 on topic: dalybms/soc/total_voltage, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m1), 'b'dalybms/soc/total_voltage'', ... (6 bytes)
DEBUG [daly-bms-cli:131] Send data: -1.565 on topic: dalybms/soc/current, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m2), 'b'dalybms/soc/current'', ... (6 bytes)
DEBUG [daly-bms-cli:131] Send data: 33.0 on topic: dalybms/soc/soc_percent, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m3), 'b'dalybms/soc/soc_percent'', ... (4 bytes)
DEBUG [daly-bms-cli:131] Send data: 280.0 on topic: dalybms/mosfet_status/full_capacity_ah, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m4), 'b'dalybms/mosfet_status/full_capacity_ah'', ... (5 bytes)
DEBUG [daly-bms-cli:131] Send data: 95.03 on topic: dalybms/mosfet_status/remaining_capacity_ah, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m5), 'b'dalybms/mosfet_status/remaining_capacity_ah'', ... (5 bytes)
DEBUG [daly-bms-cli:131] Send data: ["FAST_DSG: Fast Discharging", "DSGING: Discharging", "DSGMOS: Discharging enabled", "CHGMOS: Charging enabled"] on topic: dalybms/mosfet_status/pack_state, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m6), 'b'dalybms/mosfet_status/pack_state'', ... (112 bytes)
DEBUG [daly-bms-cli:131] Send data: 7 on topic: dalybms/status/cycles, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m7), 'b'dalybms/status/cycles'', ... (1 bytes)
DEBUG [daly-bms-cli:131] Send data: 3.25 on topic: dalybms/cell_voltages/1, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m8), 'b'dalybms/cell_voltages/1'', ... (4 bytes)
DEBUG [daly-bms-cli:131] Send data: 3.313 on topic: dalybms/cell_voltages/2, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m9), 'b'dalybms/cell_voltages/2'', ... (5 bytes)
DEBUG [daly-bms-cli:131] Send data: 3.304 on topic: dalybms/cell_voltages/3, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m10), 'b'dalybms/cell_voltages/3'', ... (5 bytes)
DEBUG [daly-bms-cli:131] Send data: 3.293 on topic: dalybms/cell_voltages/4, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m11), 'b'dalybms/cell_voltages/4'', ... (5 bytes)
DEBUG [daly-bms-cli:131] Send data: 29.6 on topic: dalybms/temperatures/external1, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m12), 'b'dalybms/temperatures/external1'', ... (4 bytes)
DEBUG [daly-bms-cli:131] Send data: 0.1 on topic: dalybms/temperatures/external2, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m13), 'b'dalybms/temperatures/external2'', ... (3 bytes)
DEBUG [daly-bms-cli:131] Send data: [] on topic: dalybms/errors, retain flag: False
DEBUG [client.py:2529] Sending PUBLISH (d0, q0, r0, m14), 'b'dalybms/errors'', ... (2 bytes)
DEBUG [client.py:2529] Sending DISCONNECT

Unfortunately I can only see the first value when I'm using chronograf/grafana, in this case it's dalybms/soc/total_voltage.

I've also tried to listen to the MQTT messages via "MQTT Explorer" where I can also confirm that it seems like only the first value is being sent.

My telegraf.conf is configured like this:

[[inputs.mqtt_consumer]]
servers = ["tcp://127.0.0.1:1883"]
username = "XXXXXXX"
password = "YYYYYYYYYYY"
topics = [
"dalybms/#",
]

data_format = "value"
data_type = "float"

As I'm running out of ideas, do I miss something?

3S BMS single data frame in get_cell_voltages

Hello !

I did the experiment on the 3S BMS and I got the following error with the get_cell_voltages function:

TypeError: a bytes-like object is required, not 'int' (Line

parts = struct.unpack(structure, response_bytes)
)

response_data = b'\x01\x0e`\x0e\x9a\x00' 

After looking at the get_temperatures function, I noticed that the response_data was a list instead of an array of bytes.

Thus, in BMS 3S, we only get one frame of data for the cell voltages. I have included the following fix:

    def get_cell_voltages(self, response_data=None):
        if not response_data:
            max_responses = self._calc_cell_voltage_responses()
            if not max_responses:
                return
            response_data = self._read_request("95", max_responses=max_responses)
        if not response_data:
            return False

        if not isinstance(response_data, list):
            response_data = [response_data, bytes([0] * len(response_data))]

        cell_voltages = self._split_frames(response_data=response_data, status_field="cells", structure=">b 3h x")

        for id in cell_voltages:
            cell_voltages[id] = cell_voltages[id] / 1000
        return cell_voltages

Is there another way around it?

Many thanks to you!

No values are displayed

After installation on a Raspberry 3B, the first queries worked as expected. Now I get an empty json format without values. What else can I try? Why did it work for a short time?
Output example:
root@solaranzeige:/home/pi# daly-bms-cli -d /dev/ttyUSB0 --soc
{
"total_voltage": 0.0,
"current": -3000.0,
"soc_percent": 0.0
}
#+++++++++++++++
root@solaranzeige:/home/pi# daly-bms-cli -d /dev/ttyUSB0 --soc --verbose DEBUG [daly_bms.py:95] -- 94 ------------------------
DEBUG [daly_bms.py:65] w a5409408000000000000000081
DEBUG [daly_bms.py:114] 0 a5409408000000000000000081 13
DEBUG [daly_bms.py:95] -- 90 ------------------------
DEBUG [daly_bms.py:65] w a540900800000000000000007d
DEBUG [daly_bms.py:114] 0 a540900800000000000000007d 13
{
"total_voltage": 0.0,
"current": -3000.0,
"soc_percent": 0.0
}

Daly readings over Bluetooth

Hi,

Thanks for your code, it's very helpful. Where did you find the doc to interact with the BMS through Bluetooth ? I was able to find that my Daly is using this module to turn serial data into bluetooth, but it still doesn't really describe how to interact with the module or which characteristics to read/write from.

In any case, my current problem is that I can't read the cell voltages using a Raspberry Pi Zero W. Bleak calls the notification_callback() twice, first with 200 bytes of data, then another time with 8 bytes. The first 200 byes start well with a succession of 13 bytes frames, but the last ~20% is garbage. I couldn't make sense of the 2nd set of 8 bytes.

I put the data here for your reference (I have a 16s daly), all concatenated together, with an attempt at formatting it along the 13-bytes frames :

\xa5\x01\x95\x08\x01\x0c\x89\x0c\x86\x0c\x89\xd3\xd3
\xa5\x01\x95\x08\x02\x0c\x86\x0c\x8a\x0c\x88\xd3\xd4
\xa5\x01\x95\x08\x03\x0c\x89\x0c\x86\x0c\x94\xd3\xe0
\xa5\x01\x95\x08\x04\x0c\x8e\x0c\x8f\x0c\x8e\xd3\xe9
\xa5\x01\x95\x08\x05\x0c\x8f\x0c\x8a\x0c\x8d\xd3\xe5
\xa5\x01\x95\x08\x06\x0c\x8c\x00\x00\x00\x00\xd3\xb4
\xa5\x01\x95\x08\x07\x00\x00\x00\x00\x00\x00\xd3\x1d
\xa5\x01\x95\x08\x08\x00\x00\x00\x00\x00\x00\xd3\x1e
\xa5\x01\x95\x08\t\x00\x00\x00\x00\x00\x00\xd3\x1f
\xa5\x01\x95\x08\n\x00\x00\x00\x00\x00\x00\xd3
\xa5\x01\x95\x08\x0b\x00\x00\x00\x00\x00\x00\xd3!
\xa5\xa8\x00@\x00\x00 @\x00\r0\x00\x00\x00 @\x00\xdel\x00\x00m2\x00\x00\x00 @\x00S1\x00\x00\x00\x00\x00\x00\xa8\x00@\x00\x00\x00\x00\x000\x00@\x00\x00\x00\x00
\xa5\x01\x95\x08\x10\x00\x00\x00\x00\x00\x00\xd3&

Seems like the problem is not coming from your lib, but more from Bleak, Bluez or my Raspberry itself. I spent a couple of hours on the net, but couldn't find anything meaninful. My expertise with BLE is very limited so I create this issue here as a last attempt solving the probblem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.