ioBroker / AdapterRequests

This Place is used to track the status of new Adapter-Requests.
248 stars 36 forks source link

JBD / Xiaoxiang / TI BQ76940 BMS über Bluetooth auslesen / communication via Bluetooth #512

Open arneproft opened 3 years ago

arneproft commented 3 years ago

Hallo, Ich suche nach einem Adapter, um mehrere auf dem BMS-Controller TI BQ76940 basierenden China-BMS (Batterie-Management-System) über Bluetooth auszulesen. Ich verwende einige dieser BMS (als 14s 30A Version) in meinem Powerwall-Projekt. Das Projekt wächst und es kommen immer mehr BMSe dazu, da ich mein Projekt mit 14s7p- Blöcken erweitere und jedes mal ein solches BMS dort verbaue. Es wäre eine sehr große und schöne Sache, wenn wir diese BMS über ioBroker überwachen könnten. Diese BMSes sind sehr beliebt und werden von vielen DIY-Powerwall-Buildern verwendet. Hier ist ein Beispiel: https://de.aliexpress.com/item/32733414980.html?traffic_analysisId=recommend_3035_null_null_null&scm=1007.13338.80878.000000000000000&pvid=35b4beeb-f901-45f7-88fa-ab6a7c0def53&tpp=1

Bluetooth könnte von einem RPI 3(+) oder so verwendet werden. Finden der Adapter ist über den BLE-Adapter möglich. Es findet die BMSes, aber es braucht definitiv etwas "Code-Magie" von einem Programmierer, um die Daten auszulesen.

Mein Plan ist es, einen "Slave" (über Multihost) ioBroker-RPI, der sich in der Nähe der Battery-Packs befindet, nur zum Auslesen dieser BMSes zu verwenden und ihn an meine Haupt-ioBroker-Appliance zu senden.

Es gibt eine App sowohl für Android als auch iOS (heißt Xiaoxiang), für Windows gibts "JBDtools" und das Communikations-Protokoll liegt auch offen. Siehe meinen nächsten Post weiter unten. Zu finden beim Hersteller: https://www.lithiumbatterypcb.com/smart-bms-software-download/

HARDWARE zum Testen: Ich würde zur Entwicklung die nötige Hardware beistellen. Also ein 14s-BMS mit dem BT-Dongle und ich würde noch eine kleine Test-Batterie vorbereiten um das BMS auch real nutzen zu können. Ein RPi 3 mit IoBroker vorinstalliert würde ich ebenfalls für diese Zeit stellen.

Ein ESP32-Projekt zum auslesen EINES BMS gibt es hier : https://github.com/kolins-cz/Smart-BMS-Bluetooth-ESP32 Vielleicht kann man sich hier etwas orientieren?

VG Arne

Links für erweiterte Informationen https://wnsnty.xyz/entry/jbd-xiaoyang-smart-bluetooth-bms-information https://hackaday.io/project/162806-jbd-bms-protocol

arneproft commented 3 years ago

Hier ist eine gute Protokoll-Beschreibung vom Simat, der hat ein anderes Projekt mit diesen BMS https://github.com/simat/BatteryMonitor :

This is the command sequence sent by the JBDTools software to obtain the battery information. It is a binary string which in HEX format is. I have added the EOLs for clarity. DD A5 03 00 FF FD 77 DD A5 04 00 FF FC 77 DD A5 05 00 FF FB 77

First two bytes are the header, bytes 3 and 4 are the command, bytes 5 and 6 are the checksum, the last byte is the EOR.

The battery current along with other information that I haven't decoded is returned by the BMS board by the first command. The second command returns the individual cell voltages and the third returns the BMS name in ASCII format and maybe other information.

The reply packet is a binary string in HEX format is. I have added the EOLs for clarity DD A5 00 1B 13 78 00 00 00 00 03 E8 00 00 22 C7 00 00 00 00 00 00 19 00 03 0C 02 0B 64 0B 5F FC 83 77 DD A5 00 18 10 39 10 3A 10 38 10 3A 10 3C 10 39 10 37 10 39 10 3B 10 3F 10 36 10 3A FC 74 77 DD A5 00 14 4C 48 2D 53 50 31 35 53 30 30 31 2D 50 31 33 53 2D 33 30 41 FB 39 77

The first two bytes are the header, bytes 3 and 4 are the length of the reply data in bytes, the data follows followed by the checksum, and finally the EOR.

The battery current is in bytes 7 and 8 of the first line

The second line are the individual cell voltages. Each voltage is a 16 bit number so 0x1039 gives a voltage of 4153mV 10 39 10 3A 10 38 10 3A 10 3C 10 39 10 37 10 39 10 3B 10 3F 10 36 10 3A These converted to decimal in mV are 4153 4155 4152 4155 4157 4153 4151 4153 4156 4159 4150 4155

Third line is the BMS name.

The command sequence to send in HEX format as a binary string is DD A5 03 00 FF FD 77 DD A5 04 00 FF FC 77 DD A5 05 00 FF FB 77

The reply packet is a binary string in HEX format is. I have added the EOLs for clarity DD A5 00 1B 13 78 00 00 00 00 03 E8 00 00 22 C7 00 00 00 00 00 00 19 00 03 0C 02 0B 64 0B 5F FC 83 77 DD A5 00 18 10 39 10 3A 10 38 10 3A 10 3C 10 39 10 37 10 39 10 3B 10 3F 10 36 10 3A FC 74 77 DD A5 00 14 4C 48 2D 53 50 31 35 53 30 30 31 2D 50 31 33 53 2D 33 30 41 FB 39 77

The battery current is in bytes 7 and 8 of the first line

The second line are the individual cell voltages. Each voltage is a 16 bit number so 0x1039 gives a voltage of 4153mV 10 39 10 3A 10 38 10 3A 10 3C 10 39 10 37 10 39 10 3B 10 3F 10 36 10 3A These converted to decimal in mV are 4153 4155 4152 4155 4157 4153 4151 4153 4156 4159 4150 4155

Arne

arneproft commented 3 years ago

Ich würde zur Entwicklung die nötige Hardware für die Zeit beistellen. Also ein 14s-BMS mit dem BT-Dongle und ich würde noch eine kleine Test-Batterie vorbereiten um die Daten im BMS komplett zu haben. Ein RPi 3 mit IoBroker vorinstalliert würde ich ebenfalls für diese Zeit stellen. Grüße Arne

sshoecraft commented 3 years ago

https://github.com/sshoecraft/jbdtool/tree/main

Conair0001-ks commented 3 years ago

Für einen iobroker adapter wäre ich bereit dem Entwickler das Equipment das "arneproft" vorschlägt zu bezahlen, sprich er kann es dann behalten.

arneproft commented 3 years ago

Hi, das klingt prima, ich hoffe jemand kann hier helfen. Das wäre wirklich eine coole Sache! Ich habe mittlerweile einige (es sind mehr als 30!) BMS hier am laufen, es wird langsam mühselig regelmäßig jedes BMS per Bluetooth mit der App zu kontrollieren, ob die jeweilige Batterie nicht ein Problem hat. Grüße!

sshoecraft commented 3 years ago

Hallo! Ich habe die Nutzung von Bluetooth aufgegeben. Ich benutze jetzt NUR das Wi-FI-Modul für meine 15 Packs.

Sehen Sie sich diesen Thread an, um die Wi-FI-Module zu erstellen:

https://diysolarforum.com/threads/jbd-bms-wi-fi-module.17252/

Mein JBDTOOL gibt MQTT-Daten aus:

https://github.com/sshoecraft/jbdtool

Und dieses Dienstprogramm kann MQTT-Ausgaben sammeln und anzeigen:

https://github.com/sshoecraft/cellmon

Es sieht aus wie das:

https://diysolarforum.com/attachments/1612628557309-png.36183/

Sobald Sie MQTT-Daten haben, können Sie diese mit Grafana grafisch darstellen. Siehe Beitrag Nr. 37 hier:

https://secondlifestorage.com/index.php?threads/jdb-xiaoxiang-bms-tool.10329/page-2

From: Arne Proft notifications@github.com Sent: Friday, February 26, 2021 1:15 PM To: ioBroker/AdapterRequests AdapterRequests@noreply.github.com Cc: Shoecraft, Stephen Stephen.Shoecraft@McKesson.com; Comment comment@noreply.github.com Subject: [EXTERNAL] Re: [ioBroker/AdapterRequests] JBD / Xiaoxiang / TI BQ76940 BMS über Bluetooth auslesen / communication via Bluetooth (#512)

CAUTION: This email was sent from an EXTERNAL source. Use caution when clicking links or opening attachments.


Hi, das klingt prima, ich hoffe jemand kann hier helfen. Das wäre wirklich eine coole Sache! Ich habe mittlerweile einige (es sind mehr als 30!) BMS hier am laufen, es wird langsam mühselig regelmäßig jedes BMS per Bluetooth mit der App zu kontrollieren, ob die jeweilige Batterie nicht ein Problem hat. Grüße!

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/ioBroker/AdapterRequests/issues/512*issuecomment-786841811__;Iw!!KMayzP4JbQ!NZNs_5F358Jk2dULoJlbX7sGadgiMIsof3WAiVE0gXlTiWmGSeG8cbzWJKF39cxWp32-og8$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ALDM57JTJTHGBYDPGFKB26DTA7XLVANCNFSM4T3EE3XQ__;!!KMayzP4JbQ!NZNs_5F358Jk2dULoJlbX7sGadgiMIsof3WAiVE0gXlTiWmGSeG8cbzWJKF39cxWJW1l57Y$.

arneproft commented 3 years ago

Hmm danke für die Infos, aber ich habe ja schon den iobroker der fast alles kann. Bluetooth sollte doch nicht die Hürde sein, mit dem BLE-Plugin (auf nem Rpi 3+) kann man ja schon alle BMSe sehen, das ist doch eigentlich schon die halbe (ok, viertel) Miete.

Ich stelle mir das so vor:

Grüse Arne

sshoecraft commented 3 years ago

Arne, ich kenne ioBroker nicht - aber es sieht cool aus!

Der Grund, warum ich Wi-Fi im Vergleich zu Bluetooth verwende, liegt in all den Problemen, die ich mit Bluetooth hatte: ständiges Trennen / Hängen / erneutes Herstellen der Verbindung, bis der Prozess beendet ist / ständiger Neustart des Bluetooth-Dienstes usw.

Außerdem war keines meiner BMS mit Bluetooth ausgestattet. Ich habe direkt bei JBD bestellt und alle meine BMS wurden nur mit UART geliefert. Wenn ich Bluetooth für alle haben wollte, hätte ich etwas extra kaufen müssen. Ich habe 2 der Bluetooth-Boxen gekauft, die an den UART-Port angeschlossen sind, und mit diesen getestet.

Denken Sie auch daran, dass ich mein BMS als Teil einer Powerwall verwende und viele davon habe. Ich sammle alle 30 Sekunden Daten von 14 BMS.

Wenn Sie Daten für ioBroker sammeln möchten, können Sie jbdtool (https://github.com/sshoecraft/jbdtool) verwenden. Es kann im Hintergrund ausgeführt werden und in regelmäßigen Abständen MQTT-Nachrichten senden.

sshoecraft commented 3 years ago

Arne, ich werde ioBroker überprüfen und sehen, ob ich JBD-Bluetooth-Ausgabe dazu bekommen kann. Es hat die Fähigkeit, MQTT-Nachrichten zu veröffentlichen, wenn dies von ioBroker verwendet wird.

Ich antwortete auf Ihre E-Mail und dachte, sie könnte aus den Solarenergie-Foren stammen.

Ich entschuldige mich dafür, dass ich jbdtool zweimal verlinkt habe. Es gibt andere Tools für das in Python geschriebene JBD-BMS, das Bluetooth verwendet. Sie könnten sie anschauen. Es wäre einfach, ihnen mqtt-Publishing hinzuzufügen.

Hier ist eine: https://gitlab.com/bms-tools/bms-tools

arneproft commented 3 years ago

Hey sshoecraft, bei mir hat jedes BMS im Lieferumfang immer gleich ein BT-Modul dabei. Es wäre eben schade, wenn ich die nicht nutzen könnte, und stattdessen noch extra Aufwand (Kosten+Zeit) betreiben muss, um für jedes BMS (könnten im Endausbau durchaus ca. 100 oder mehr werden) ein Wlan-Modul bauen muss. IObroker ist eine "eierlegende Wollmichsau" wenn es um konnektivität und offenheit geht. Das läuft bei mir sowieso schon produktiv für so ziemlich alles im Haus. MQTT kann der natürlich auch empfangen, dann hätte ich die Daten zum weiterverarbeiten im IObroker zur Verfügung.

Danke für das Aufzeigen der JBD-Tools und vor allem Dein wirklich cooles projekt! Meine programmier-skills reichen (absolut!) nicht aus um da irgendwas draus zu machen. Ich brauche eine quasi fertige Lösung oder jemanden, der dieses Projekt umsetzt. Deshalb ja meine Anfrage in diesem IObroker Adapter-request. Ich hoffe einfach ,dass sich hier jemand findet, eine Lösung irgendwie umzusetzen. Irgendwie möche ich die BMS-Daten im IObroker haben. Mit möglichst wenig zusatz-Hardware.

Arne

sshoecraft commented 3 years ago

Verstanden. Mein 100A BMS mit UART kostete jeweils nur 34 USD. Bluetooth kostete zusätzlich 8 USD. Da ich 16 BMS habe, wären das nur für Bluetooth 128 USD gewesen (was ich als unzuverlässig empfand). Das Wi-Fi-Modul kostete für die Herstellung von 16 Einheiten 80 USD an Material, und ich finde es viel zuverlässiger.

Sie könnten jbdtool mit Bluetooth- und MQTT-Ausgabe ausprobieren - es könnte jetzt für Sie funktionieren. Ich stelle im Projekt eine Binärdatei für den Raspberry PI bereit, in den Bluetooth kompiliert ist.

arneproft commented 3 years ago

Ich habe meine für ca 30Euro / stück bezogen, inkl. Bluetooth. Mittlerweile laufen hier 80Stück davon in meinem Rack. Lngsam wird es wirklich an der Zeit, eine Lösung zu finden. Hier wurde das auslesen des Bluetooth schon mal umgesetzt:

https://mono.software/2018/11/15/multiple-bms-monitor/

Leider kriege ich das trotzt der super Anleitung nicht zusammengebacken, für nen Profi wäre das sicher ein Klacks...

sshoecraft commented 3 years ago

Das ist ein guter Preis ($ 30EU).

Ich habe diese Lösung gesehen, die Sie zuvor verlinkt haben - sie ist sehr cool. Ich habe es mir angesehen, als ich Ideen für eine GUI bekam. Ich habe Grafana benutzt, bin aber nicht 100% zufrieden damit. Ich benutze auch überhaupt kein Bluetooth mehr - ich hatte zu viele Probleme damit.

Ich würde den Entwickler dieses Projekts um ein Raspberry Pi-Image bitten - das würde Ihnen viel Zeit sparen.

Ich habe einige Arbeiten an einem Projekt durchgeführt, mit dem Sie das JBD-BMS mithilfe von MQTT vollständig konfigurieren / steuern können. Ich weiß nicht, ob es mit Ihrem Bluetooth-Adapter funktioniert, aber es ist so konzipiert, dass es im Hintergrund ausgeführt wird und es Ihnen ermöglicht, so viele gleichzeitig auszuführen, wie Sie möchten, und wird parallel aktualisiert.

https://github.com/sshoecraft/solardirector

Viel Glück!

sshoecraft commented 3 years ago

Keep in mind if you use any tool that will output MQTT (like jbdtool or solardirector/jbd), then you can use telegraf or node-red/influxdb/grafana to view it

https://secondlifestorage.com/index.php?threads/jdb-xiaoxiang-bms-tool.10329/page-2#post-7247

dash

arneproft commented 3 years ago

Dear sshoecraft,

thanks for all your effort and input. Im trying your jbdtool. Set up a fresh Rpi3+, downloaded your latest static binary and i get a short connection. That was the smoothest "first start" ever! I appreciate your work!

But then i get a bt_open(97): error: failed to start bluetooth notification Maybe because of the password? its normally 000000, in the Android-app i need to enter it, when i want to connect... Is it possible to hand-over a passwort in the command-line?

Thanks!

p-f-w commented 3 years ago

if you need to send password to bms (no bluetooth-pin here, i have 5x JBD-SP04S020-L4S-120A-B-U (version 0x20), no other)->

if password is 123456 then send DD 5A 06 07 06 01 02 03 04 05 06 FF D8 77 if password is 000000 then send DD 5A 06 07 06 00 00 00 00 00 00 FF ED 77

the original Android app is first sending DD 5A 06 01 00 FF F9 77, it will work if no password is set but in the following log you see, that returned status is 80, not 00 for "ok"

xxx x.xxx000000 BluetoothLeService Logcat Text Logcat Text 142 send:DD 5A 06 01 00 FF F9 77 read:DD 06 80 00 FF 80 77

that means the request is not ok and then the android app ask you for the password, so far BMS Tool and also bms_tools from JBD will fail here to read or set parameters until the passwort isn't cleared

xxx xx.xxx000000 BluetoothLeService Logcat Text Logcat Text 160 send:DD 5A 06 07 06 01 02 03 04 05 06 FF D8 77 read:DD 06 00 00 00 00 77 <- this the correct answer

but

DD A5 03 00 FF FD 77 DD A5 04 00 FF FC 77 DD A5 05 00 FF FB 77

should work without need of password

in my tests after some time i must resend password to bms, no matter whether per ble or usb serial adapter, but I already had the same appearance with the Android app, but when using the app only a reconnect helps

see also -> https://gitlab.com/bms-tools/bms-tools/-/issues/30

Mein Anliegen ist ansich auch, mehrere Geräte mittels einer App per Bluetooth anzusprechen, gegebenenfalls die Parameter aller BMS zu ändern etc. pp, aber ob ich das schaffe, die eine mir bekannte verfügbare quelloffene App entsprechend anzupassen? Die BLE-Kommunikation ist wohl etwas tricky und schlecht implementiert in Android(zumindest bei älteren Versionen) durch Google, was gleichzeitige Kommunikation betrifft (s.a. https://issuetracker.google.com/issues/37127889). Der Autor obiger App hat die Kommunikation mit mehreren Geräten ansich auch auf seiner ToDo-Liste.

covenant1969 commented 6 months ago

Seems as if there are new JBD BMS BT Dongles around. Mine states Version 1.2 and does not in any way answer on sending DD A5 03 00 FF FD 77. Neither does sending a password work. Furthermore old Mobile Phone Apps do also not work with this one. Anybody else with this experience? I received mine directly from far east with Manufacturing date November 2023. Bye Michael.

Edit 7Jan24. Newer BT Dongle require additional write-commands to initiate communication. Those start with FFAA. Since nobody replied on my entry, i assume nobody is interested in the outcome.