Hauptmenü

JK BMS

Begonnen von domo, 16 März 2024, 16:19:16

Vorheriges Thema - Nächstes Thema

domo

I have a 12V LIFEPO4 4KW battery with a JK BMS.  I have installed the RS485 adapter, which seems to be isolated, which is a good thing.  I will connect this to a WROVER32 running tasmota, and use two pins as a modbus RS485 bridge.  I am running FHEM on a RASPI, which communicates with a lot of of other tasmota sensors using MQTT. Does a module exist for decoding and categorizing the BMS stream which I will hopefully be able to receive on the PI?  Have I missed something ?  Will this work like I imagine it could ?  I would like to get the information so that I can control the charging routine for the battery pack, which presently gets any energy which is above +5W according to the main power meter reading using an optical magnetic adapter on the face of the meter (also tasmota).  I get a reading every second from the Stromzahler.  The software and hardware performs quite well presently, but extra info from the BMS could be an advantage. The charger is a server PSU (maximum 70A @ 13.7V) controlled from the PWM on tasmota. Any input or comment would be appreciated. Thanks.

Gisbert

#1
Hi domo,

please check this link: https://github.com/syssi/esphome-jk-bms
In a couple of weeks, I'm gonegoing to a have JK-BMS and I will either use this code or something similiar from GitHub.

Cheers
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

domo

hi Gisbert, cool, i'll wait for your feedback.. 

domo

so this is what the JK BMS is sending, I think it is ok, it needs to be parsed into different values:
4E5700FD00000000060001790C010CDA020CDA030CDA040CDA80001781001782001583052484000085458602870042890000498E8A00048B00008C00038E05A08F0410900E10910DDE920005930A28940A5A95000596012C97002898012C9900C89A001E9B0B549C00039D019E00649F0050A00064A10064A20014A30046A40050A5FFECA60003A7FFECA8FFF6A904AA0000011DAB01AC01AD03C5AE01AF00B0000AB114B231323334000000000000B300B4496E707574205573B532333034B60005C653B731312E58575F5331312E32365F5F5FB800B90000011DBA496E70757420557365726461534261745F31325632383041C001000000006800004AD0

best regs

domo

Hello Gisbert, I decoded locally on the esp32 using berry script, and MQTT.PUBLISH commands.it works great. I think it is the best way to go.  Regards domo

Gisbert

Hi domo,

I have to wait for another ESP32 which hopefully will arrive in about 2 weeks. The battery and the JK-BMS are now working since a couple of days.
My plan is to use syssis code: https://github.com/syssi/esphome-jk-bms. The connection seems to be easy as no further components besides the ESP32 board are necessary. 3 of the 4 pins (JST 1.25mm pitch) of the port called GPS are necessary. The 4th pin is the voltage of the battery (about 50~56 V) - this must not be used.
I will send the data via MQTT to Fhem. Syssis code is based on ESPHome / Python which needs to be installed on your computer. I followed the instructions of this page for another project (my DEYE hybrid inverter), it worked right from the start: https://smarthomeyourself.de/wiki/esphome/esphome-mit-python-ueber-die-kommandozeile-flashen/.

Regards
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

domo

Hi Gisbert, yes I looked at that project a lot, I used the file jk_bms.cpp to template my berry script, which is working quite nicely, it sends the mqtt already decoded to my rasberry pi, where FHEM gets it.  so i guess you will look at decoding the data on your host.  yes that pin4 is a no no, it has battery voltage on it, best leave it alone.  so i have a small non FHEM related question, regarding berry script, why can't i use *=-1 to invert an integer ?  this is very frustrating, it simply will not accept it, neither will a=-a , i am at my limit trying to get the mqtt.publish current reading negative when it should be...  I have built a bespoke controller for my battery pack, with two charger and discharger PWMs which control a modified server power supply and a solar inverter to charge and discharge the battery.  My pack is only 4KW so not too big.  I guess i will need a few more panels on the roof now to charge that in one day. hope to hear how you get on too.  best regards Domo.

Gisbert

#7
Hi domo,

from a former project, I get used to ESPHome which seems to be much user friendly than Arduino code. Therefore I will use the ESPHome code.

When I want to transform a reading in something else, I use most likely the attribut userReadings, e.g. in your case
attr userReadings Device newreading {0-ReadingsNum($name,'oldreading,'')}
Regards
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

Gisbert

Hi domo,

I got finally the code from syssi working.
It took a couple of ESP32 boards until it worked.
The ESP32 Boards from AliExpress had a bad quality - I returned them.
The quality of boards from AZ-Delivery were good as expected. Unfortunately, I killed the 1st board. The colors of my cables were missleading and I put 55V on one of the GPIOs - it crackled and I send the ESP to heaven, RIP. The second works now perfect.
I reduced the reading cycle from 5 to 10 seconds when I realized that my server was under pressure.

I give the code from syssi some time and check later whether there are better codes available.

Regards
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

domo

Hi Gisbert, sounds good, keep in touch about findings, I am actually reading the BMS at 1 second intervals, I need the battery status, especially the current, I need to watch the power taken from the battery, so I monitor it closely. Best regards

holle75

Hallo Gisbert, ich auch gerade an dem Thema. JK Inverter BMS (das aktuelle) und natürlich möchte ich die Einzelspannungen der Zellen irgendwie in fhem sehen. Auf der Verbindung auch noch Einstellungen im BMS setzen zu können, wäre die Krönung (aber nicht essentiell). Jetzt am erruieren, wie.

Mein CAN Port ist von der Anlage belegt, bleibt nur RS485 Port oder Bluetooth. Da ja immer die Wahl der Technik und des Weges der komplizierteste Part ist: Was ist deiner und wie hast du es gemacht? Am liebsten wäre mir via MQTT weil der Server in fhem sowieso läuft, aber ich erinnere mich noch dunkel (Jahre her) dass das gar nicht so einfach war. Jahre her ist es auch, dass ich mit Arduinos und ESp32 gebastelt habe. Alles vergessen, was nicht prinzipiell war ;)

Würde mich über deine Erkenntnisse freuen. Habe zwar oben alles gelesen, aber wie gesagt, Weg und Technik und das Verständnis von diesen .... altes Hirn.

Gisbert

#11
Hallo holle75,

ich hab eigentlich nur die Anweisungen befolgt, die im GitHub-Projekt von syssi vorgegeben werden: https://github.com/syssi/esphome-jk-bms
Du musst dich mit ESPHome beschäftigen, und wie du ESPHome, bzw. die entsprechende YAML-Datei auf einen ESP32 geflasht bekommst.
Um ESPHome zu flashen, bin ich einer Anleitung von haus-automatisierung.com gefolgt (falsch erinnert, siehe nächster Beitrag, genauer Link folgt später). Ich hänge dann auch meine yaml-Datei an, die ich für mein JK-BMS benutze (den Typ schreib ich auch dazu).

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Danke Gisbert, sehr nett.

ESPHome bekomme ich hin. Also hatte ich damals. Das war, meine ich mich zu erinnern, damals der simpelste Weg was das flashen angeht. Will sagen, hatte auf Anhieb funktioniert.

Was ich nicht mehr weiß, hatte ESPHome via MQTT kommuniziert (scheint so, ja, eben deinem Link gefolgt)? Und wie wird das Platinchen am BMS kontaktiert (ok, Rs485 Port laut deinem Link)?

Kannst du auch ins BMS "schreiben"? Kannst du mir auch noch gleich deine fhem DEF RAW hinterlassen? Entschuldige so zu drängen, aber das spart immer 10 Stunden Gepröbel wenn man direkt auf den richtigen Weg geleitet wird. Zu viele Baustellen gerade mal wieder (Eine Zelle war in der Battery defekt. Aber nur "ein bißchen". Du kannst dir vorstellen wieviel Freude und Zeit es bedeutet das erstmal einzukreisen und herauszufinden ... und wieviel Zeit du vergeudest die ersetzte Zelle im laufenden Betrieb, weil sonst kein Strom aufm Land, zu laden und zu balancen)

"Mein" BMS habe ich jetzt auf der syssi Übersicht nicht direkt gesehen, aber ich probiere es einfach mal aus, dann.

Danke!

Gisbert

Hallo holle75,

ESPHome hatte ich über diesen Link in Windows installiert: https://smarthomeyourself.de/wiki/esphome/esphome-mit-python-ueber-die-kommandozeile-flashen/

MQTT vom ESP32 rauszusenden ist vglw. einfach. Bitte schaue in den Code, dann wirst du es verstehen und sehen, dass es tatsächlich einfach ist.

Mögliche Stolpersteine:
esp32:
  board: nodemcu-32s
  framework:
    type: esp-idf
Ich habe ein ESP32-Board von AZ-Delivery im Einsatz. Bei anderen Boards müssen u.U. andere Einträge gemacht werden.

#Optional manual IP - damit gelingt ein wireless update in Home Assistant und in ESPHome
  manual_ip:
    static_ip: 192.168.2.63
    gateway: 192.168.2.1
    subnet: 255.255.255.0
Bitte zuerstmal auskommentieren, da ja die IP-Adresse des ESP32 noch unbekannt sein dürfte. Anschließend mit den richtigen Daten nochmals ESPHome laufen lassen. Damit sind Updates vom PC aus extrem einfach durchzuführen.

Die Funktionsweise der secrets.yaml kennst du sicher, da werden die Credentials gespeichert.

Zur Zeit lese ich nur die Daten vom BMS per MQTT aus, ich schreibe nichts per MQTT ins BMS. Bei meinem DEYE 3-Phasen-Wechselrichter schreibe ich auch Register per MQTT. Dazu publishe ich aus Fhem und der ESP lauscht wie folgt "on message":
mqtt:
  broker: !secret my_broker
  port: !secret my_port
  topic_prefix: "/DEYE"
  username: !secret my_username
  password: !secret my_password
  on_message:
    - topic: /DEYE/Batt/off
      then:
        - select.set:
            id: ${device_type}_Battery_Mode
            option: "No Batt"
        - mqtt.publish:
            topic: /DEYE/Batt/state
            payload: "Battery is OFF!"         
    - topic: /DEYE/Batt/on
      then:
        - select.set:
            id: ${device_type}_Battery_Mode
            option: "Use Batt V"
        - mqtt.publish:
            topic: /DEYE/Batt/state
            payload: "Battery is ON!"
    - topic: /DEYE/MaxBattCharge/current
      payload: "40"
      then:
        - number.set:
            id: ${device_type}_Maximum_battery_charge_current
            value: 40
    - topic: /DEYE/MaxBattCharge/current
      payload: "30"
      then:
        - number.set:
            id: ${device_type}_Maximum_battery_charge_current
            value: 30
    - topic: /DEYE/MaxBattCharge/current
      payload: "20"
      then:
        - number.set:
            id: ${device_type}_Maximum_battery_charge_current
            value: 20
    - topic: /DEYE/MaxBattCharge/current
      payload: "10"
      then:
        - number.set:
            id: ${device_type}_Maximum_battery_charge_current
            value: 10
    - topic: /DEYE/MaxBattCharge/current
      payload: "80"
      then:
        - number.set:
            id: ${device_type}_Maximum_battery_charge_current
            value: 80
    - topic: /DEYE/battery_float/voltage
      payload: "55"
      then:
        - number.set:
            id: ${device_type}_Battery_float_voltage
            value: 55
    - topic: /DEYE/battery_float/voltage
      payload: "55.4"
      then:
        - number.set:
            id: ${device_type}_Battery_float_voltage
            value: 55.4
    - topic: /DEYE/battery_float/voltage
      payload: "55.8"
      then:
        - number.set:
            id: ${device_type}_Battery_float_voltage
            value: 55.8

Wichtig ist auch, ob das Register "number", "select" oder was auch immer ist.
Im obigen Beispiel sende ich auch vom ESP32 etwas zurück, um sicherzustellen, dass die Kommunikation erfolgreich war:
        - mqtt.publish:
            topic: /DEYE/Batt/state
            payload: "Battery is OFF!"

Prinzipiell mache ich es so, dass ich essentielle Änderungen vorort mache. Register von Fhem per MQTT zu schreiben kann fatal enden, d.h. man sollte sich absolut sicher sein, was man tut, und mutig sein, ist hier absolut falsch.

Mein Fhem-Device:
defmod JK_BMS MQTT_DEVICE
attr JK_BMS IODev MyBroker
attr JK_BMS autoSubscribeReadings jk-bms/#
attr JK_BMS event-min-interval total_voltage:300,capacity_remaining:600
attr JK_BMS event-on-change-reading Zeitstempel,average_cell_voltage,balancing,\
,capacity_remaining,capacity_remaining_derived,charging_cycles,current:0.2,\
,delta_cell_voltage,power:10,power_tube_temperature,temperature_sensor_1,\
,temperature_sensor_2,total_charging_cycle_capacity,total_runtime,\
,total_runtime_formatted,total_voltage:0.02,errors
attr JK_BMS icon measure_battery_100
attr JK_BMS room DEYE
attr JK_BMS stateFormat {'SOC: '.ReadingsNum($name,'capacity_remaining','').'%<br/>\
charging cycle: '.ReadingsNum($name,'charging_cycles','').'<br/>\
power: '.-round(ReadingsNum($name,'power','')/1000,3).' kW<br/>\
current: '.-round(ReadingsNum($name,'current',''),2).' A<br/>\
Ø cell voltage: '.ReadingsNum($name,'average_cell_voltage','').' V<br/>\
Δ cell voltage: '.round(ReadingsNum($name,'delta_cell_voltage','')*1000,0).' mV<br/>\
battery voltage: '.ReadingsNum($name,'total_voltage',''). 'V<br/>'\
.ReadingsVal($name,'IPaddress','').'<br/>\
<span style="vertical-align: +0px;; font-size: 85%;;">'.ReadingsVal($name,'Zeitstempel','').'</span>'}
attr JK_BMS subscribeReading_actual_battery_capacity jk-bms/sensor/jk-bms_actual_battery_capacity/state
attr JK_BMS subscribeReading_average_cell_voltage jk-bms/sensor/jk-bms_average_cell_voltage/state
attr JK_BMS subscribeReading_balancing jk-bms/binary_sensor/jk-bms_balancing/state
attr JK_BMS subscribeReading_balancing_switch jk-bms/binary_sensor/jk-bms_balancing_switch/state
attr JK_BMS subscribeReading_binary_sensor_charging jk-bms/binary_sensor/jk-bms_charging/state
attr JK_BMS subscribeReading_binary_sensor_discharging jk-bms/binary_sensor/jk-bms_discharging/state
attr JK_BMS subscribeReading_capacity_remaining jk-bms/sensor/jk-bms_capacity_remaining/state
attr JK_BMS subscribeReading_capacity_remaining_derived jk-bms/sensor/jk-bms_capacity_remaining_derived/state
attr JK_BMS subscribeReading_cell_voltage_1 jk-bms/sensor/jk-bms_cell_voltage_1/state
attr JK_BMS subscribeReading_cell_voltage_10 jk-bms/sensor/jk-bms_cell_voltage_10/state
attr JK_BMS subscribeReading_cell_voltage_11 jk-bms/sensor/jk-bms_cell_voltage_11/state
attr JK_BMS subscribeReading_cell_voltage_12 jk-bms/sensor/jk-bms_cell_voltage_12/state
attr JK_BMS subscribeReading_cell_voltage_13 jk-bms/sensor/jk-bms_cell_voltage_13/state
attr JK_BMS subscribeReading_cell_voltage_14 jk-bms/sensor/jk-bms_cell_voltage_14/state
attr JK_BMS subscribeReading_cell_voltage_15 jk-bms/sensor/jk-bms_cell_voltage_15/state
attr JK_BMS subscribeReading_cell_voltage_16 jk-bms/sensor/jk-bms_cell_voltage_16/state
attr JK_BMS subscribeReading_cell_voltage_2 jk-bms/sensor/jk-bms_cell_voltage_2/state
attr JK_BMS subscribeReading_cell_voltage_3 jk-bms/sensor/jk-bms_cell_voltage_3/state
attr JK_BMS subscribeReading_cell_voltage_4 jk-bms/sensor/jk-bms_cell_voltage_4/state
attr JK_BMS subscribeReading_cell_voltage_5 jk-bms/sensor/jk-bms_cell_voltage_5/state
attr JK_BMS subscribeReading_cell_voltage_6 jk-bms/sensor/jk-bms_cell_voltage_6/state
attr JK_BMS subscribeReading_cell_voltage_7 jk-bms/sensor/jk-bms_cell_voltage_7/state
attr JK_BMS subscribeReading_cell_voltage_8 jk-bms/sensor/jk-bms_cell_voltage_8/state
attr JK_BMS subscribeReading_cell_voltage_9 jk-bms/sensor/jk-bms_cell_voltage_9/state
attr JK_BMS subscribeReading_charging jk-bms/switch/jk-bms_charging/state
attr JK_BMS subscribeReading_charging_cycles jk-bms/sensor/jk-bms_charging_cycles/state
attr JK_BMS subscribeReading_charging_power jk-bms/sensor/jk-bms_charging_power/state
attr JK_BMS subscribeReading_current jk-bms/sensor/jk-bms_current/state
attr JK_BMS subscribeReading_current_calibration jk-bms/sensor/jk-bms_current_calibration/state
attr JK_BMS subscribeReading_debug jk-bms/debug
attr JK_BMS subscribeReading_dedicated_charger_switch jk-bms/binary_sensor/jk-bms_dedicated_charger_switch/state
attr JK_BMS subscribeReading_delta_cell_voltage jk-bms/sensor/jk-bms_delta_cell_voltage/state
attr JK_BMS subscribeReading_discharging jk-bms/switch/jk-bms_discharging/state
attr JK_BMS subscribeReading_discharging_power jk-bms/sensor/jk-bms_discharging_power/state
attr JK_BMS subscribeReading_errors jk-bms/sensor/jk-bms_errors/state
attr JK_BMS subscribeReading_max_cell_voltage jk-bms/sensor/jk-bms_max_cell_voltage/state
attr JK_BMS subscribeReading_max_voltage_cell jk-bms/sensor/jk-bms_max_voltage_cell/state
attr JK_BMS subscribeReading_min_cell_voltage jk-bms/sensor/jk-bms_min_cell_voltage/state
attr JK_BMS subscribeReading_min_voltage_cell jk-bms/sensor/jk-bms_min_voltage_cell/state
attr JK_BMS subscribeReading_online_status jk-bms/binary_sensor/jk-bms_online_status/state
attr JK_BMS subscribeReading_operation_mode jk-bms/sensor/jk-bms_operation_mode/state
attr JK_BMS subscribeReading_password jk-bms/sensor/jk-bms_password/state
attr JK_BMS subscribeReading_power jk-bms/sensor/jk-bms_power/state
attr JK_BMS subscribeReading_power_tube_temperature jk-bms/sensor/jk-bms_power_tube_temperature/state
attr JK_BMS subscribeReading_status jk-bms/status
attr JK_BMS subscribeReading_switch_charging jk-bms/switch/jk-bms_charging/state
attr JK_BMS subscribeReading_switch_discharging jk-bms/switch/jk-bms_discharging/state
attr JK_BMS subscribeReading_temperature_sensor_1 jk-bms/sensor/jk-bms_temperature_sensor_1/state
attr JK_BMS subscribeReading_temperature_sensor_2 jk-bms/sensor/jk-bms_temperature_sensor_2/state
attr JK_BMS subscribeReading_total_battery_capacity_setting jk-bms/sensor/jk-bms_total_battery_capacity_setting/state
attr JK_BMS subscribeReading_total_charging_cycle_capacity jk-bms/sensor/jk-bms_total_charging_cycle_capacity/state
attr JK_BMS subscribeReading_total_runtime jk-bms/sensor/jk-bms_total_runtime/state
attr JK_BMS subscribeReading_total_runtime_formatted jk-bms/sensor/jk-bms_total_runtime_formatted/state
attr JK_BMS subscribeReading_total_voltage jk-bms/sensor/jk-bms_total_voltage/state
attr JK_BMS userReadings Zeitstempel {substr(ReadingsTimestamp($name,'total_voltage',''),0,19)}, \
IPaddress \
{"<a href=\"http://192.168.2.63\" style=\"color: green;; text-decoration: underline;;\" target=\"_blank\" rel=\"noopener noreferrer\">http://192.168.2.63</a>"}

Falls es noch Fragen gibt, dann melde dich bitte wieder, gerne auch, wenn es keine Fragen gibt, und du es erfolgreich umgesetzt hast.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Danke dir vielmals.

Ich werde hoffentlich übers Wochenende oder nächste Woche dazu kommen und werde natürlich berichten wie es läuft.

Jamo

Hallo Ihr 2,
warum schreibt Ihr nicht in Englisch in der "English Corner"? Dann hat der User domo auch was davon.
Bullseye auf iNUC, Homematic + HMIP(UART/HMUSB), Debmatic, HUEBridge, Zigbee/Conbee III, FB7690, Alexa (fhem-lazy), Livetracking, LaCrosse JeeLink, LoRaWan / TTN / Chirpstack, Sonos, ESPresence

holle75

you are right, but writing/thinking in a language thats not your mother tongue is harder. Especially on topics that are more complicated than a relaxed conversation and having a tendency to get technical.
Anyways, i promise to write an english summary when the work is done .... so Gisbert and i can continue in german for a bit. Or i open up a new topic (which helps none of us, imho).

holle75

Gisbert, kurze Zwischenfrage: wo hattest du die Basis für deinen yaml file her? Ich bin schon relativ weit (Gott, was für ein gezicke dieses bin-file kompiliert zu bekommen) und will gerade auf der ESP32 Seite noch ein bißchen optimieren ... bevor ich mich an die Verbindung mache.

Gisbert

Hallo holle75,

den yaml-File hab ich aus dem Projekt von syssi auf GitHub. Es gibt da etliche Varianten, ich hab mich dann für diese entschieden und etwas auf meine Bedürfnisse angepasst.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Ah jetzt, ich habe nur in dem Readme das Beispiel gefunden. IN den Files sollte man schauen ;)

holle75

#20
... weißt du noch, welcher file deine Basis war? Wenn ich das richtig überblicke, gibts da schon deutliche Unterschiede wie die Daten ausgelesen werden.... und vor allem die Frage (an mich) welche Basis dann für meinen ESP32 und BMS die Richtige ist.

EDIT: ok, gefunden -> esp32-example.yaml (erst denken, dann schreiben)

holle75

... ohoh, und woher wußtest du welchen PIN am Rs485 Stecker am BMS du mit GPIO17, GPIO16, GND verbinden musstest?
Muss ich wahrscheinlich das JK-BMS Manual durchforsten

holle75

Ich muss nochmal auf die physische Verbindung und die damit einhergehenden Einstellungen eingehen. Bei meinem JK-PB2A16S20P hat es

RS485|CAN|RS232|Rs485|RS485

im Panel.

Korrespondierend, wenn ich es richtig verstanden habe, kannst du in der App/Software UART Protokolle für 1 und 2 einstellen. Auf welche Ports die sich jetzt beziehen wäre interessant.

... und vor allem, welchen Port und welchen Pin hast du mit dem ESP32 verbunden?

CAN (zur Anlage) und die beiden rechten RS485 (wohl zum Verbinden mehrerer Batterien) sind wohl nicht für unseren Fall vorgesehen. Bleibt nur der linke RS485 und der mittlere RS232?

Gisbert

Hallo holle75,

mein Board ist deutlich einfacher aufgebaut. Die Beschreibung von syssi auf GitHub trifft genau zu:
ZitatThe UART-TTL (labeled as RS485) socket of the BMS can be attached to any UART pins of the ESP. A hardware UART should be preferred because of the high baudrate (115200 baud). The connector is called 4 Pin JST with 1.25mm pitch.

Am BMS hat dieser Stecker die Bezeichnung GPS/RS485.

Auch die App sieht bei mir anders aus, d.h. hier kann ich dir keinen Rat geben. In der App gibt es bei meinem BMS die Option bei Port Switch: CAN oder RS485 - sie steht bei mir auf CAN. Ich habe keine Signalverbindung zwischen meinem Wechselrichter und dem JK-BMS.

Versuche ein aussagekräftiges Dokument deines JK-BMS zu finden. Das müsste ein Dokument mit 50+ Seiten sein. Vielleicht ist da beschrieben, wie die PIN-Belegungen sind. Ansonsten müsstest du schauen, wie die PIN-Belegung eines RJ45-Steckers bei einer RS485-Schnittstelle aussieht.
Auf jeden Fall solltest du dann messen, welche Adern 3.3V gegen eine GND-Ader haben. Diese 3 Adern sollten dann mit dem ESP32 verbunden werden.

Ich hatte mir noch dieses Zubehörteil gekauft, dass ich aber dann gar nicht benötigt habe: https://www.nkon.nl/de/charger-84/bms-mod/accessoires/jk-485-converter-for-jk-bms-rs485-adapter-module.html. Falls du es benötigst, kannst du das gerne haben.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

Gisbert

Noch ein Hinweis: dieses Forum ist für PV und Akku möglicherweise nicht das beste. Es gibt noch das Akkudoktor-Forum und das Photovoltaik-Forum - vielleicht wurde da dein konkreter Aufbau schon mal behandelt.
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Danke Gisbert, ja Akkudoktor Forum mag ich gerne. Habe da auch eine ähnliche Frage zur physischen Verbindung laufen. Das JK Manual zum BMS ist schon ok, nur genau zu den beschriebenen Punkten ein wenig "dünne". Will sagen, zumindest ich, finde einfach nicht raus, welcher Port/Einstellungen es denn jetzt genau wäre.

Tendenz mit den, ebenfalls dünnen, Infos aus anderen Foren bis jetzt ist der RS232 Port derjenige welcher genutzt werden könnte/sollte. Aber ich möchte mir ungern das BMS oder den ESP32 braten. Das sind die kleinen Details die nie jemand dediziert beschreibt weil scheinbar völlig klar ;) ... trotz wenn falsch, deutlichen Auswirkungen.

Zu "dem Teil" was du nicht benötigst: Auch ich habe genau das Teil gekauft und nicht benötigt ;) ... verstehen, was es genau macht oder wofür es gut wäre, tue ich auch nicht. Nach den Anschlüssen zu urteilen müsste man es aber intern nutzen.

holle75

#26
Die Zusammenfassung:

Es gibt ein git Projekt für die kabelgebundene Verbindung vom "neuen JK inverter BMS" -> https://github.com/txubelaxu/esphome-jk-bms
Dieses beschäftigt sich mit der RS485 Schnittstelle und man braucht für seinen ESP32 noch einen zusätzlichen RS485 Konverter.

Da ich mich als Unwissender erstmal nur mit dem von Gisbert verlinkten git Projekt -> https://github.com/syssi/esphome-jk-bms
auseinandergesetzt hatte, stand ich zwischenzeitlich ein wenig auf dem Schlauch.

Dann habe ich mich entschieden den Bluetooth Weg zu gehen.... und zweiteres git https://github.com/syssi/esphome-jk-bms
war wieder aktuell.

Ich muss jetzt mal für ein paar Wochen die Stabilität verfolgen, aber für den Anfang sieht das ziemlich gut aus. Alle Werte aus dem BMS laufen in fhem über MQTT2 (interner Server) auf.

Als erstes Gisberts Link zum flashen gefolgt -> https://smarthomeyourself.de/wiki/esphome/esphome-mit-python-ueber-die-kommandozeile-flashen/
hier zu beachten, dass der Install von Python bei mir nur final nutzbar über Windows-App-Install funktioniert hat. Hatte ich noch nie probiert, nervt, aber nur so gings.

Dann müssen noch irgendwelche Repos nachinstalliert werden. Vergessen. Die error messages beim ersten kompilieren zeigen aber auf, was fehlt.

Danach muss man im yaml file DEBUG mode anschalten, um an die MAC Adresse vom BMS zu kommen (wird dir wenn beim ESP32 eingeloggt in den Debugs gezeigt) . Danach mit der gefundenen MAC Adresse im yaml neu flashen. Ja, um drei Ecken ... vielleicht gibts einen besseren Weg.

dann autocreate in fhem´s MQTT2 Server (oder welchen du benutzt) an und die Sache rennt.

Mein yaml für hardware vers 15.x

substitutions:
  name: jk-bms
  device_description: "Monitor and control a JK-BMS v15 via bluetooth"
  external_components_source: github://syssi/esphome-jk-bms@main
  mac_address: C8:47:80:xx:xx:xx
  # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0)
  # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26)
  # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0)
  protocol_version: JK02_32S

esphome:
  name: ${name}
  comment: ${device_description}
  min_version: 2024.6.0
  project:
    name: "syssi.esphome-jk-bms"
    version: 2.0.0
# this should match your ESP32 --- take care
esp32:
  board: nodemcu-32s
  framework:
    type: esp-idf

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

wifi:
  ssid: ssidxxxx
  password: passwordxxxx

# Optional manual IP - damit gelingt ein wireless update in Home Assistant und in ESPHome
# manual IP
  use_address: 192.168.1.70
  manual_ip:
    static_ip: 192.168.1.70
    gateway: 192.168.1.1
    subnet: 255.255.255.0

web_server:
  port: 80

ota:
  platform: esphome
  password: passowrdxxx
  on_begin:
    then:
      - switch.turn_off: ble_client_switch0
      - logger.log: "BLE connection suspended for OTA update"

# for the first run to find out the mac address of your BMS you need DEBUG instead of INFO
logger:
  level: INFO

# If you don't use Home Assistant please remove this `api` section and uncomment the `mqtt` component!
# api:

mqtt:
  broker: 192.168.1.23
  port: 1883
  username: usernamexxx
  password: passwordxxx
  id: MQTT2_JK_BMS_Container_ESP32

esp32_ble_tracker:
  on_ble_advertise:
    then:
      - lambda: |-
          if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
            ESP_LOGI("ble_adv", "New JK-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:
  - mac_address: ${mac_address}
    id: client0

jk_bms_ble:
  - ble_client_id: client0
    protocol_version: ${protocol_version}
    throttle: 5s
    id: bms0

binary_sensor:
  - platform: jk_bms_ble
    balancing:
      name: "${name} balancing"
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
    heating:
      name: "${name} heating"
    online_status:
      name: "${name} online status"

button:
  - platform: jk_bms_ble
    retrieve_settings:
      name: "${name} retrieve settings"
    retrieve_device_info:
      name: "${name} retrieve device info"

number:
  - platform: jk_bms_ble
    jk_bms_ble_id: bms0
    balance_trigger_voltage:
      name: "${name} balance trigger voltage"
    cell_count:
      name: "${name} cell count"
    total_battery_capacity:
      name: "${name} total battery capacity"
    cell_voltage_overvoltage_protection:
      name: "${name} cell voltage overvoltage protection"
    cell_voltage_overvoltage_recovery:
      name: "${name} cell voltage overvoltage recovery"
    cell_voltage_undervoltage_protection:
      name: "${name} cell voltage undervoltage protection"
    cell_voltage_undervoltage_recovery:
      name: "${name} cell voltage undervoltage recovery"
    balance_starting_voltage:
      name: "${name} balance starting voltage"
    voltage_calibration:
      name: "${name} voltage calibration"
    current_calibration:
      name: "${name} current calibration"
    power_off_voltage:
      name: "${name} power off voltage"
    max_balance_current:
      name: "${name} max balance current"
    max_charge_current:
      name: "${name} max charge current"
    max_discharge_current:
      name: "${name} max discharge current"
    smart_sleep_voltage:
      name: "${name} smart sleep voltage"
    cell_soc100_voltage:
      name: "${name} cell soc100 voltage"
    cell_soc0_voltage:
      name: "${name} cell soc0 voltage"
    cell_request_charge_voltage:
      name: "${name} cell request charge voltage"
    cell_request_float_voltage:
      name: "${name} cell request float voltage"

sensor:
  - platform: jk_bms_ble
    jk_bms_ble_id: bms0
    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"
    delta_cell_voltage:
      name: "${name} delta cell voltage"
    average_cell_voltage:
      name: "${name} average cell voltage"
    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_resistance_1:
#      name: "${name} cell resistance 1"
#    cell_resistance_2:
#      name: "${name} cell resistance 2"
#    cell_resistance_3:
#      name: "${name} cell resistance 3"
#    cell_resistance_4:
#      name: "${name} cell resistance 4"
#    cell_resistance_5:
#      name: "${name} cell resistance 5"
#    cell_resistance_6:
#      name: "${name} cell resistance 6"
#    cell_resistance_7:
#      name: "${name} cell resistance 7"
#    cell_resistance_8:
#      name: "${name} cell resistance 8"
#    cell_resistance_9:
#      name: "${name} cell resistance 9"
#    cell_resistance_10:
#      name: "${name} cell resistance 10"
#    cell_resistance_11:
#      name: "${name} cell resistance 11"
#    cell_resistance_12:
#      name: "${name} cell resistance 12"
#    cell_resistance_13:
#      name: "${name} cell resistance 13"
#    cell_resistance_14:
#      name: "${name} cell resistance 14"
#    cell_resistance_15:
#      name: "${name} cell resistance 15"
#    cell_resistance_16:
#      name: "${name} cell resistance 16"
#    cell_resistance_17:
#      name: "${name} cell resistance 17"
#    cell_resistance_18:
#      name: "${name} cell resistance 18"
#    cell_resistance_19:
#      name: "${name} cell resistance 19"
#    cell_resistance_20:
#      name: "${name} cell resistance 20"
#    cell_resistance_21:
#      name: "${name} cell resistance 21"
#    cell_resistance_22:
#      name: "${name} cell resistance 22"
#    cell_resistance_23:
#      name: "${name} cell resistance 23"
#    cell_resistance_24:
#      name: "${name} cell resistance 24"
    total_voltage:
      name: "${name} total voltage"
    current:
      name: "${name} current"
    heating_current:
      name: "${name} heating current"
    power:
      name: "${name} power"
    charging_power:
      name: "${name} charging power"
    discharging_power:
      name: "${name} discharging power"
    temperature_sensor_1:
      name: "${name} temperature sensor 1"
    temperature_sensor_2:
      name: "${name} temperature sensor 2"
    temperature_sensor_3:
      name: "${name} temperature sensor 3"
    temperature_sensor_4:
      name: "${name} temperature sensor 4"
    temperature_sensor_5:
      name: "${name} temperature sensor 5"
    power_tube_temperature:
      name: "${name} power tube temperature"
    balancing:
      name: "${name} balancing"
    state_of_charge:
      name: "${name} state of charge"
    capacity_remaining:
      name: "${name} capacity remaining"
    total_battery_capacity_setting:
      name: "${name} total battery capacity setting"
    charging_cycles:
      name: "${name} charging cycles"
    total_charging_cycle_capacity:
      name: "${name} total charging cycle capacity"
    total_runtime:
      name: "${name} total runtime"
    balancing_current:
      name: "${name} balancing current"
    errors_bitmask:
      name: "${name} errors bitmask"
    emergency_time_countdown:
      name: "${name} emergency time countdown"

switch:
  - platform: jk_bms_ble
    charging:
      name: "${name} charging"
    discharging:
      name: "${name} discharging"
    balancer:
      name: "${name} balancer"
    emergency:
      name: "${name} emergency"
    heating:
      name: "${name} heating"
    disable_temperature_sensors:
      name: "${name} disable temperature sensors"
    display_always_on:
      name: "${name} display always on"
    smart_sleep:
      name: "${name} smart sleep"
    disable_pcl_module:
      name: "${name} disable pcl module"
    timed_stored_data:
      name: "${name} timed stored data"
    charging_float_mode:
      name: "${name} charging float mode"

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

text_sensor:
  - platform: jk_bms_ble
    errors:
      name: "${name} errors"
    total_runtime_formatted:
      name: "${name} total runtime formatted"

das ist für 8 Zellen. Falls man mehr hat entsprechend die auskommentierten Zellen anpassen.
This yaml is for 8 cells, please check lines marked with # in the lower part if you have more.

Mein fhem DEF RAW, basierend auf Gisberts

defmod MQTT2_JK_BMS MQTT2_DEVICE jk_bms_2462abc9d910
attr MQTT2_JK_BMS autocreate 0
attr MQTT2_JK_BMS event-min-interval .*:600
attr MQTT2_JK_BMS event-on-change-reading cell_voltage_1:0.01,cell_voltage_2:0.01,cell_voltage_3:0.01,cell_voltage_4:0.01,cell_voltage_5:0.01\
,cell_voltage_6:0.01,cell_voltage_7:0.01,cell_voltage_8:0.01,balancer,current:1,capacity_remaining:1,charging_cycle,power\
,average_cell_voltage:0.1,delta_cell_voltage,total_voltage:0.1,max_cell_voltage,min_cell_voltage,SOC:1,Zeitstempel,sensor_online_status,status
attr MQTT2_JK_BMS event-on-update-reading .*
attr MQTT2_JK_BMS readingList jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_errors/state:.* errors\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_balancing_current/state:.* balancing_current\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_state_of_charge/state:.* SOC\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_capacity_remaining/state:.* capacity_remaining\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_total_battery_capacity_setting/state:.* total_battery_capacity_setting\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_charging_cycles/state:.* charging_cycles\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_total_charging_cycle_capacity/state:.* charging_cycle_capacity\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_total_runtime/state:.* total_runtime\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_total_runtime_formatted/state:.* total_runtime_formatted\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_heating_current/state:.* heating_current\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_1/state:.* cell_voltage_1\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_2/state:.* cell_voltage_2\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_3/state:.* cell_voltage_3\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_4/state:.* cell_voltage_4\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_5/state:.* cell_voltage_5\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_6/state:.* cell_voltage_6\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_7/state:.* cell_voltage_7\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_cell_voltage_8/state:.* cell_voltage_8\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_min_cell_voltage/state:.* min_cell_voltage\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_max_cell_voltage/state:.* max_cell_voltage\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_average_cell_voltage/state:.* average_cell_voltage\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_delta_cell_voltage/state:.* delta_cell_voltage\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_max_voltage_cell/state:.* max_voltage_cell_nr\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_min_voltage_cell/state:.* min_voltage_cell_nr\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_power_tube_temperature/state:.* power_tube_temperature\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_total_voltage/state:.* total_voltage\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_current/state:.* current\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_power/state:.* power\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_charging_power/state:.* charging_power\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_discharging_power/state:.* discharging_power\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_temperature_sensor_1/state:.* temperature_sensor_1\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_temperature_sensor_2/state:.* temperature_sensor_2\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_temperature_sensor_3/state:.* temperature_sensor_3\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_temperature_sensor_4/state:.* temperature_sensor_4\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_temperature_sensor_5/state:.* temperature_sensor_5\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_errors_bitmask/state:.* errors_bitmask\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_balancing/state:.* balancing\
jk_bms_2462abc9d910:jk-bms/sensor/jk-bms_emergency_time_countdown/state:.* emergency_time_countdown\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_charging/state:.* switch_charging\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_discharging/state:.* switch_discharging\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_balancer/state:.* switch_balancer\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_enable_bluetooth_connection/state:.* switch_enable_bluetooth_connection\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_emergency/state:.* switch_emergency\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_heating/state:.* switch_heating\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_disable_temperature_sensors/state:.* switch_disable_temperature_sensors\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_display_always_on/state:.* switch_display_always_on\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_smart_sleep/state:.* switch_smart_sleep\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_disable_pcl_module/state:.* switch_disable_pcl_module\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_timed_stored_data/state:.* switch_timed_stored_data\
jk_bms_2462abc9d910:jk-bms/switch/jk-bms_charging_float_mode/state:.* switch_charging_float_mode\
jk_bms_2462abc9d910:jk-bms/binary_sensor/jk-bms_online_status/state:.* sensor_online_status\
jk_bms_2462abc9d910:jk-bms/binary_sensor/jk-bms_balancing/state:.* sensor_balancing\
jk_bms_2462abc9d910:jk-bms/binary_sensor/jk-bms_charging/state:.* sensor_charging\
jk_bms_2462abc9d910:jk-bms/binary_sensor/jk-bms_discharging/state:.* sensor_discharging\
jk_bms_2462abc9d910:jk-bms/binary_sensor/jk-bms_heating/state:.* sensor_heating\
jk_bms_2462abc9d910:jk-bms/status:.* status\
jk_bms_2462abc9d910:jk-bms/debug:.* debug\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_voltage_undervoltage_protection/state:.* cell_voltage_undervoltage_protection\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_voltage_undervoltage_recovery/state:.* cell_voltage_undervoltage_recovery\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_voltage_overvoltage_protection/state:.* cell_voltage_overvoltage_protection\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_voltage_overvoltage_recovery/state:.* cell_voltage_overvoltage_recovery\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_balance_trigger_voltage/state:.* balance_trigger_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_power_off_voltage/state:.* power_off_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_max_charge_current/state:.* max_charge_current\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_max_discharge_current/state:.* max_discharge_current\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_max_balance_current/state:.* max_balance_current\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_count/state:.* cell_count\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_total_battery_capacity/state:.* total_battery_capacity\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_balance_starting_voltage/state:.* balance_starting_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_smart_sleep_voltage/state:.* smart_sleep_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_soc100_voltage/state:.* soc100_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_soc0_voltage/state:.* soc0_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_request_charge_voltage/state:.* cell_request_charge_voltage\
jk_bms_2462abc9d910:jk-bms/number/jk-bms_cell_request_float_voltage/state:.* cell_request_float_voltage
attr MQTT2_JK_BMS room MQTT2_DEVICE
attr MQTT2_JK_BMS stateFormat {'Status: '.ReadingsVal($name,'status','').'<br/>\
SOC: '.ReadingsNum($name,'SOC','').'%<br/>\
charging cycles: '.ReadingsNum($name,'charging_cycles','').'<br/>\
power: '.ReadingsNum($name,'power','').' W<br/>\
current: '.ReadingsNum($name,'current','').' A<br/>\
Ø cell voltage: '.ReadingsNum($name,'average_cell_voltage','').' V<br/>\
Δ cell voltage: '.round(ReadingsNum($name,'delta_cell_voltage','')*1000,0).' mV<br/>\
max cell voltage: '.ReadingsNum($name,'max_cell_voltage','').' V<br/>\
min cell voltage: '.ReadingsNum($name,'min_cell_voltage','').' V<br/>\
battery voltage: '.ReadingsNum($name,'total_voltage',''). 'V<br/>'\
.ReadingsVal($name,'IPaddress','').'<br/>\
<span style="vertical-align: +0px;; font-size: 85%;;">'.ReadingsVal($name,'Zeitstempel','').'</span>'}
attr MQTT2_JK_BMS userReadings Zeitstempel {substr(ReadingsTimestamp($name,'total_voltage',''),0,19)}, \
IPaddress \
{"<a href=\"http://192.168.xx.xx\" style=\"color: green;; text-decoration: underline;;\" target=\"_blank\" rel=\"noopener noreferrer\">http://192.168.xx.xx</a>"}

Summary:

There is a git project for a wired connection for the "new JK inverter BMS" -> https://github.com/txubelaxu/esphome-jk-bms
This deals with the RS485 interface and you need an additional RS485 converter for your ESP32.

As an ignorant person, I initially only dealt with the git project linked by Gisbert -> https://github.com/syssi/esphome-jk-bms
This one is mainly thought out for a Bluetooth connection for the new BMS, but works wired for older BMS´ses (it seems to me?)

Which i finally decided on .... and the git https://github.com/syssi/esphome-jk-bms
was up again.

I'll have to monitor the stability for a few weeks now, but it looks pretty good to start with. All values from the BMS flow to fhem via MQTT2 (internal server).

First, follow Gisbert's link to flash -> https://smarthomeyourself.de/wiki/esphome/esphome-mit-python-ueber-die-kommandozeile-flashen/
Please note that the Python install only worked for me via Windows app installation. I had never tried it before, annoying, but that was the only way.

Then more repos have to be installed. Forgotten which ones. The error messages during the first compilation show what is missing.

Then you have to switch on DEBUG mode in the yaml file to find the MAC address of the BMS (MAC of your BMS will be shown in the Debug messages when logged into your ESP32 dashboard). Then reflash with the MAC address found and put in the yaml. Yes, complicated undertaking ... maybe there is a better way.

then activate autocreate in fhem´s MQTT2 server (or whatever Server you use) ... and the games can begin. Please see yaml and fhem DEF RAW above

holle75

... vielleicht ist ja der RS485 Konverter von weiter oben genau das Teil was man braucht um kabelgebundenen zu fahren. Aber von/wohin das Ding konvertiert weiß irgendwie niemand genau. Auch wo man das anschließen soll weiß ich nicht.

holle75

.... ein

attr MQTT2_FHEM_Server ignoreRegexp milight/0x[0-9a-fA-F]{1,4}/.*/[0-8]|shellies/[^/]+/command|cmnd/[^/]+/|homeassistant/.*/config|tasmota/discovery/

in eurem MQTT2 Server (fhem intern) hilft die Last auf dem fhem device zu reduzieren... und reading RETAIN mal anschauen, was sich da alles reingeschlichen hat.

holle75

@Gisbert, sorry, ich finde mal wieder keine Info zu den Basics .... secrets.yaml ... wohin damit in fhem? Bis jetzt hab ich alles direkt ins Device yaml eingetragen. Aber so ließe sich das allgemein für mehr Devices vereinfachen.

Und wie binde ich es ein? Also muss man im Device.yaml noch irgendwas beachten? Oder nur bei jeweiligen "passwert" die Referenz eintragen? zb

!secret my_broker

Gisbert

Hallo holle75,

schau dir die GitHub-Seite von Bagges an und vergleiche die Einträge in einer "Haupt"-Dateien mit den Einträgen in der secrets.yaml: https://github.com/bagges/deye-esp32-bridge/tree/main
Damit dürfte das Prinzip schnell klar werden. In der secrets.yaml kann man alles mögliche geheim halten, und den eigentlichen Code mit anderen Teilen, ohne dass man an verschiedenen Stellen die Passwörter unkenntlich machen muss.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Hallo Gisbert und Danke, aber ... ich steh auf dem Schlauch ... das secret.yaml muss doch irgendwo in fhem hinterlegt werden? Oder wird das einfach nur "mitgeflasht" wenn man den ESP beschreibt? und falls, kommt das dann einfach in den selben Ordner wie das yaml was du flashst? Manchmal glaube ich, ich bin zu alt für den Krempel ;)

Gisbert

Achso, das ist dein Problem. Die secrets.yaml kommt in den gleichen Ordner wie der eigentliche Code/yaml-Datei.
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

holle75

Danke dir. Einfach, wenn manns weiss ;)

juepi

Hey folks,

This is the manual i've found for the new JK "inverter BMS":
https://www.jkbms.com/wp-content/uploads/2024/06/JK-BMS-User-Manual-for-PB-series-jkbms.com_.pdf


The interesting part starts at page 8. To my understanding, the RS485-2 ports are only relevant when interconnecting paralleled battery packs, so those ports should not be relevant for communicating with a single BMS.
For communicating with the RS485-1 port you will most probably need a converter, as RS485 uses 2 differential pairs for safe communcation, whereas the ESP needs TTL/CMOS UART communication.
Beside of the pinout, the RS232 port is not described in the manual, so i don't know which possibilities there are.


yours,
Juergen

holle75

Hi Juergen, yes, know this manual. As mentioned further above you can follow

https://github.com/txubelaxu/esphome-jk-bms

to connect your JK-BMS to the ESP via wire. Using RS485-1 or the two RS485 connections "on the right" shouldn´t make a difference, i suppose. I think UART-1 (or was it -2?) in the BMS-settings might need to be checked or modified when using RS485-1 (left), though.

And yes, it seems you´ll need an additional RS485 converter to do so.

No one knows exactly what´s possible with the RS232 port. I opened an issue on https://github.com/syssi/esphome-jk-bms to ask that question. Even "the master" whos working this git doesn´t know precisely (or i don´t/didn´t understand enough about this topic to follow).