Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new range of JK BMS (JK-PBx) #390

Open
PMPoulsen opened this issue Nov 8, 2023 · 188 comments
Open

Support for new range of JK BMS (JK-PBx) #390

PMPoulsen opened this issue Nov 8, 2023 · 188 comments
Labels

Comments

@PMPoulsen
Copy link

Hi,

Do you have plans for supporting the new range of BMS's from JK e.g. JK-PB1A16S10P?

@syssi
Copy link
Owner

syssi commented Nov 8, 2023

Could you provide or ask the seller about some details about the supported protocols?

@PMPoulsen
Copy link
Author

I will contact them on Aliexpress to see what they can provide. I have ordered but not yet received.
There are new features in this BMS hence I expect that they have updated the protocol. I would guess still modbus over RS-232 and the JKBMS app do also support these new BMS's

@syssi
Copy link
Owner

syssi commented Nov 8, 2023

The hardware looks like a Seplos BMS.

@PMPoulsen
Copy link
Author

yes and the protocols for the RS485 / CAN busses should support multiple inverters as well

@PMPoulsen
Copy link
Author

I have received an example on the protocol from JKBMS, how ever I don't know how useful this is as the new parameters for e.g. the communication settings do not seems to be described
Jikong-BMS-RS485-Communication example.pdf

@testpaul999
Copy link

Hi,
If I can help I have one of this new BMS an can send RAW protocol if needed.
Regards

@syssi
Copy link
Owner

syssi commented Nov 22, 2023

I'm happy about every detail about the new models. Please provide as much input as you can.

@testpaul999
Copy link

Hi,
Now I have had time and here some files.
Hopefully the names are self explanatory.
sending 1.4A charge.txt
resive 1_4A charge.txt
sending_site_no load.txt
sendig 1_3A load.txt
resive_site_no load.txt
resive 1_3A load.txt
jk new
jk new charge 1_4A
jk new 1_3A load
Collected via rs485 adapter
Regards

@syssi
Copy link
Owner

syssi commented Nov 27, 2023

Cool! Could you provide some more screenshots (of the different tabs) of the JK-BMS-MONITOR app? It's the first time I see this application.

@syssi
Copy link
Owner

syssi commented Nov 27, 2023

I've extracted all Modbus requests from the capture above:

01 10 10 70 00 02 04 00 01 00 00 68 8B
01 10 10 74 00 02 04 00 01 00 00 69 78
01 10 10 84 00 02 04 0D DE 00 00 55 6A
01 10 16 0C 00 01 02 00 00 D1 5D
01 10 16 1C 00 01 02 00 00 D3 CD
01 10 16 1E 00 01 02 00 00 D2 2F
01 10 16 20 00 01 02 00 00 D6 F1
01 10 16 22 00 01 02 00 00 D7 13
01 10 16 24 00 01 02 00 00 D7 75
 |  |  |  |  |  |  |  |  |  |  |
 |  |  |  |  |  |  |  |  |  |  CRC
 |  |  |  |  |  |  |  |  |  CRC
 |  |  |  |  |  |  |  |  Data
 |  |  |  |  |  |  |  Data
 |  |  |  |  |  |  Data length
 |  |  |  |  |  Number of registers low
 |  |  |  |  Number of registers high
 |  |  |  Start address low
 |  |  Start address high
 |  Function code
 Device address

Conclusion: The request frames look like valid Modbus frames now.

@testpaul999
Copy link

Hi, screenshots from PC software
new jk fw update screen
new jk about screen
new jk control screen
new jk fault screen
new jk comm protocol screen
new jk main screen
new jk logging screen
new jk settings2 screen
new jk settings1 screen

regards

@jrventer
Copy link

I just got two JK_PB2A16S20P BMS so busy getting them ready to test. Managed to get the JK Modbus protocol document however in Chinese but most of the important parts are english as well.
JK_BMS RS485 Modbus v1_0.pdf
Will be testing these soon might save time reverse engineering using the JK BMS monitor. At least with modbus should be straight forward integration now.

@testpaul999
Copy link

I‘m to be anxious to get the esp32 run with this new bms.
Are the BT integration available as well?

regards

@jrventer
Copy link

jrventer commented Dec 2, 2023

I‘m to be anxious to get the esp32 run with this new bms. Are the BT integration available as well?

regards

I have not tested the BT integration but it works through the same mobile app via BT. Not sure if the BT protocol is a different version but I assume most would work the same as the other BMSs. There is obviously a couple of extra features and values that will have to be added. I have done some initial testing with the RS485 using standard ESPHOME modbus components and it seems to work without any issues.

@jrventer
Copy link

jrventer commented Dec 2, 2023

Small sample of collecting SoC% via modbus

# Configure uart that will be used
uart:
  id: mod_bus
  rx_pin: GPIO21
  tx_pin: GPIO22
  baud_rate: 115200
  rx_buffer_size: 384

modbus:
  id: jk_modbus

modbus_controller:
  - id: jk_modbus_bat1pack1
    address: 0x01   ## address of the ModBUS slave device on the bus
    modbus_id: jk_modbus
    setup_priority: -10
    update_interval: "5s"
    command_throttle: "50ms"
sensor:
  - platform: modbus_controller # 0x1200 index 0x90 Battery Voltage
    modbus_controller_id: jk_modbus_bat1pack1
    name: "Bat 1 Pack 1 Battery Voltage"
    id: battery_voltage
    register_type: holding
    address: 0x1290
    unit_of_measurement: "V"
    accuracy_decimals: 3
    device_class: voltage
    state_class: measurement
    filters:
      - multiply: 0.001
    value_type: U_DWORD_R

@testpaul999
Copy link

Hello,

have build esp32-ble for this new jk bms.
It run without problem and display all parameters accept the new one‘s.
Is there any beta decode for maximize to all parameters?

regards.

@testpaul999
Copy link

Happy new year 🎇
Is there any progress within implement the newer jk inverter BMS?

regards

@syssi syssi changed the title support for new range of JK BMS Support for new range of JK BMS (JK-PBx) Jan 11, 2024
syssi added a commit that referenced this issue Jan 11, 2024
syssi added a commit that referenced this issue Jan 14, 2024
@silviudc
Copy link

I have a jk-pb2a16s20p bms on v14.17, and would like to connect via an esp32 and ble and home assistant, have people managed to get it to work? Which yaml file to use?

@syssi
Copy link
Owner

syssi commented Jan 17, 2024

If you want to use BLE please try this one: https://github.com/syssi/esphome-jk-bms/blob/main/esp32-ble-example.yaml

If you want to talk to your BMS using RS485 this is a first draft: https://github.com/syssi/esphome-jk-bms/blob/add-jk-pbx-support/esp32-jk-pb-modbus-example.yaml

@silviudc
Copy link

Thank you. And use protocol JK02_32S in the config?

@testpaul999
Copy link

@silviudc
see here have build this #390 (comment)
yes this will work with this protocol.
you will see all informations accept the new parameter like RCV and RFV.
hopefully Syssi will improve the BT protocol as well.

regards

@silviudc
Copy link

Yes I got it to work, it is great.
The only thing missing, those two values, a toggle for float mode on/off and temperature sensor 3 and 4, only see 1 and 2

@syssi
Copy link
Owner

syssi commented Jan 17, 2024

@testpaul999 @silviudc Could one of you increase the log level to VERY_VERBOSE and provide a ESPHome log which includes some RAW data?

@silviudc
Copy link

silviudc commented Jan 17, 2024

@syssi
Copy link
Owner

syssi commented Jan 18, 2024

The (for me) important parts of the logs for analysis later on:

# logs_esp32-jkbms-bt_logs.txt
# The device info frame isn't part of the log

# Cell info frame (version 3, 300 bytes) received
55.AA.EB.90.02.2B.C8.0C.CA.0C.CD.0C.CD.0C.CF.0C.D0.0C.D0.0C.CC.0C.C7.0C.CB.0C.CB.0C.CC.0C.CD.0C.D1.0C.D1.0C.CF.0C.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.FF.00.00.CD.0C.0A.00.0E.0C.5B.00.3C.00.3E.00.3B.00.3F.00.3C.00.3F.00.3C.00.40.00.3D.00.40.00.3D.00.40.00.3E.00.40.00.3E.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.7C.00.00.00.00.00. CD.CC.00.00.38.DF.35.00.2C.F3.FE.FF.71.00.68.00.00.00.08.00.00.00.00.51.A4.75.07.00.C0.27.09.00.02.00.00.00.37.6E.17.00.64.00.00.00.7C.0E.08.00.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.00.01.00.00.00.9D.03.00.00.BA.00.8E.8A.40.40.00.00.00.00.7A.14.00.00.00.01.01.01.00.06.00.00.62.88.06.00.00.00.00.00.7C.00.71.00.74.00.A1.03.77.D0.9C.07.3D.00.00.00.80.51.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FE.FF.7F.DD.2F.01.01.B0.07.00.00.00.59

# Cell info frame (version 3, 300 bytes) received
55.AA.EB.90.02.37.C8.0C.CA.0C.CD.0C.CD.0C.CF.0C.D1.0C.D0.0C.CC.0C.C7.0C.CB.0C.CB.0C.CC.0C.C6.0C.CF.0C.D1.0C.CF.0C.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.FF.00.00.CD.0C.0B.00.0E.0C.5B.00.3C.00.3E.00.3B.00.3F.00.3C.00.3F.00.3C.00.40.00.3D.00.40.00.3D.00.40.00.3E.00.40.00.3E.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.7C.00.00.00.00.00. CF.CC.00.00.17.94.35.00.F4.F8.FE.FF.71.00.68.00.00.00.08.00.00.00.00.51.2A.75.07.00.C0.27.09.00.02.00.00.00.B1.6E.17.00.64.00.00.00.82.0E.08.00.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.00.01.00.00.00.9D.03.00.00.B6.00.8E.8A.40.40.00.00.00.00.7B.14.00.00.00.01.01.01.00.06.00.00.A4.88.06.00.00.00.00.00.7C.00.71.00.74.00.A1.03.7D.D0.9C.07.3D.00.00.00.80.51.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FE.FF.7F.DD.2F.01.01.B0.07.00.00.00.0C

# logs_esp32-jkbms-bt_logs (1).txt
# Cell info frame (version 3, 300 bytes) received
55.AA.EB.90.02.45.CB.0C.CA.0C.CC.0C.C8.0C.C8.0C.CD.0C.CF.0C.CC.0C.C6.0C.CB.0C.CC.0C.CF.0C.CD.0C.D0.0C.D0.0C.CB.0C.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.FF.00.00.CB.0C.0A.00.0D.08.5B.00.3C.00.3E.00.3B.00.3F.00.3C.00.3F.00.3C.00.40.00.3D.00.40.00.3D.00.40.00.3E.00.40.00.3E.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.7D.00.00.00.00.00. B5.CC.00.00.8A.70.36.00.10.F6.FE.FF.71.00.68.00.00.00.08.00.00.00.00.51.2E.60.07.00.C0.27.09.00.02.00.00.00.AE.83.17.00.64.00.00.00.A1.0F.08.00.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.00.01.00.00.00.9D.03.00.00.B8.00.8E.8A.40.40.00.00.00.00.78.14.00.00.00.01.01.01.00.06.00.00.D7.93.06.00.00.00.00.00.7D.00.72.00.74.00.A1.03.9C.D1.9C.07.3D.00.00.00.80.51.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FE.FF.7F.DD.2F.01.01.B0.07.00.00.00.DA

# Cell info frame (version 3, 300 bytes) received
55.AA.EB.90.02.5B.CA.0C.CA.0C.CB.0C.CA.0C.CA.0C.CF.0C.D0.0C.CD.0C.CC.0C.CD.0C.CC.0C.CB.0C.C6.0C.CC.0C.D0.0C.CC.0C.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.FF.00.00.CB.0C.0B.00.0E.08.5B.00.3C.00.3E.00.3B.00.3F.00.3C.00.3F.00.3C.00.40.00.3D.00.40.00.3D.00.40.00.3E.00.40.00.3E.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.7E.00.00.00.00.00. B5.CC.00.00.8A.70.36.00.10.F6.FE.FF.71.00.68.00.00.00.08.00.00.00.00.51.4C.5F.07.00.C0.27.09.00.02.00.00.00.8F.84.17.00.64.00.00.00.AD.0F.08.00.01.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FF.00.01.00.00.00.9D.03.00.00.B8.00.8E.8A.40.40.00.00.00.00.78.14.00.00.00.01.01.01.00.06.00.00.4F.94.06.00.00.00.00.00.7E.00.72.00.74.00.A1.03.A8.D1.9C.07.3D.00.00.00.80.51.01.00.00.00.00.00.00.00.00.00.00.00.00.00.00.FE.FF.7F.DD.2F.01.01.B0.07.00.00.00.84

@syssi
Copy link
Owner

syssi commented Jan 18, 2024

@silviudc Could you provide another log including the device info frame and settings frame you can request this data using the button entities:

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

@grydo
Copy link

grydo commented Jun 12, 2024

Hi, what is the new yaml for the new bms jk inverter ble?

@syssi
Copy link
Owner

syssi commented Jun 12, 2024

@grydo
Copy link

grydo commented Jun 12, 2024

Are there any new sensors?

@syssi
Copy link
Owner

syssi commented Jun 12, 2024

Not yet. Do you miss something important?

@grydo
Copy link

grydo commented Jun 12, 2024

no yet tested

@syssi
Copy link
Owner

syssi commented Jun 12, 2024

Give it a try and create a new issue if you miss something!

@grydo
Copy link

grydo commented Jun 12, 2024

ok

@nigel914
Copy link

nigel914 commented Jul 1, 2024

I am running into issues getting the total voltage using esp32 and rs458 to serial adapter testing per @syssi suggestion in previous post the current battery voltage is 52V. following this post I noticed @affer had a similar issue before he went ble any ideas on hot to resolve .

PS
individual cell voltages and resistances match the values in the phone app.

sensor:
  - platform: modbus_controller
    modbus_controller_id: bms0
    name: "${name} total voltage"
    address: 0x1290
    register_type: holding
    value_type: U_DWORD_R
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
[10:16:23][V][modbus_controller:224]: Updating modbus component
[10:16:23][V][modbus_controller:191]: Range : 1290 Size: 2 (3) skip: 0
[10:16:23][V][modbus_controller:044]: Sending next modbus command to device 1 register 0x1290 count 2
[10:16:23][V][modbus:210]: Modbus write: 01.03.12.90.00.02.C1.5E (8)
[10:16:23][V][modbus_controller:557]: Command sent 3 0x1290 2
[10:16:23][D][uart_debug:158]: >>> "\x01\x03\x12\x90\x00\x02\xC1^"
[10:16:23][V][modbus:042]: Modbus received Byte  1 (0X1)
[10:16:23][V][modbus:042]: Modbus received Byte  3 (0X3)
[10:16:23][V][modbus:042]: Modbus received Byte  4 (0X4)
[10:16:23][V][modbus:042]: Modbus received Byte  0 (0X0)
[10:16:23][V][modbus:042]: Modbus received Byte  0 (0X0)
[10:16:23][V][modbus:042]: Modbus received Byte  207 (0Xcf)
[10:16:23][V][modbus:042]: Modbus received Byte  116 (0X74)
[10:16:23][V][modbus:042]: Modbus received Byte  175 (0Xaf)
[10:16:23][V][modbus:042]: Modbus received Byte  228 (0Xe4)
[10:16:23][V][modbus_controller:075]: Modbus response queued
[10:16:23][V][modbus_controller:083]: Process modbus response for address 0x1290 size: 4
[10:16:23][V][modbus_controller:164]: data for register address : 0x1290 : 
[10:16:23][D][modbus_controller.sensor:025]: Sensor new state: 3480485888.00
[10:16:23][V][sensor:043]: 'diy-battery-04 total voltage': Received new state 3480485888.000000
[10:16:23][D][sensor:094]: 'diy-battery-04 total voltage': Sending state 3480486.00000 V with 3 decimals of accuracy
[10:16:23][D][uart_debug:158]: <<< "\x01\x03\x04\x00\x00\xCFt\xAF\xE4"

@ech0-py
Copy link

ech0-py commented Sep 1, 2024

I am running into issues getting the total voltage using esp32 and rs458 to serial adapter testing per @syssi suggestion in previous post the current battery voltage is 52V. following this post I noticed @affer had a similar issue before he went ble any ideas on hot to resolve .

Use value_type: U_DWORD (v15 shows correct voltage value with this type at least)

@ech0-py
Copy link

ech0-py commented Sep 5, 2024

image

0x12C0 UINT8 R Charge 1:on ; 0:off
0x12C0 UINT8 R Discharge 1:on ; 0:off

There are two values in a single register. Any ideas how to read/deal with it using esphome modbus? I've tried bitmask, word_from_hex_str, but with no luck

@syssi
Copy link
Owner

syssi commented Sep 5, 2024

The bitmask is your friend. Could you provide the raw data of the register?

@meccip
Copy link

meccip commented Sep 5, 2024

just to read the charge/discharge sensors

 # 0x12C0   192 UINT8 Charge (1:on ; 0:off)
  - platform: modbus_controller
    modbus_controller_id: bms0
    name: "status charge"
    address: 0x12C0
    register_type: holding
    value_type: U_WORD
    bitmask: 0xFF00

  # 0x12C0   192 UINT8 Discharge (1:on ; 0:off)
  - platform: modbus_controller
    modbus_controller_id: bms0
    name: "status discharge"
    address: 0x12C0
    register_type: holding
    value_type: U_WORD
    bitmask: 0x00FF
 

@meccip
Copy link

meccip commented Sep 5, 2024

or to control charge/discharge switch

  - platform: modbus_controller
    modbus_controller_id: bms0
    name: "discharging"
    custom_command: [0x00, 0x03, 0x10, 0x74, 0x00, 0x02]
    write_lambda: |-
      payload.push_back(0x00);
      payload.push_back(0x10);
      payload.push_back(0x10);
      payload.push_back(0x74);
      payload.push_back(0x00);
      payload.push_back(0x02);
      payload.push_back(0x04);
      payload.push_back(0x00);
      payload.push_back(0x00);
      payload.push_back(0x00);
      payload.push_back(x);
      return true;
    lambda: |-
      if (data.size() != 4 ) {
        ESP_LOGE("Custom", "Invalid data size %d",data.size());
        return {};
      }
      return (data[3] == 1);

  - platform: modbus_controller
    modbus_controller_id: bms0
    name: "charging"
    custom_command: [0x00, 0x03, 0x10, 0x70, 0x00, 0x02]
    write_lambda: |-
      payload.push_back(0x00);
      payload.push_back(0x10);
      payload.push_back(0x10);
      payload.push_back(0x70);
      payload.push_back(0x00);
      payload.push_back(0x02);
      payload.push_back(0x04);
      payload.push_back(0x00);
      payload.push_back(0x00);
      payload.push_back(0x00);
      payload.push_back(x);
      return true;
    lambda: |-
      if (data.size() != 4 ) {
        ESP_LOGE("Custom", "Invalid data size %d",data.size());
        return {};
      }
      return (data[3] == 1);

@bernstein7
Copy link

Can someone please share the wiring for RS485 with the new PBx series with RJ45 for esp controllers? Does it require some additional adapter?
I had this integration working just perfect for the previous generation of jk with no adapters just 3 wires (A,B, GND) to my esp8266 and now with a new bms can't figure out the wiring..

@meccip
Copy link

meccip commented Sep 15, 2024

for jkpb you need rs485 adapter to TxRx
326189763-26176aff-c3e0-43b0-8675-f3bb18dc5ab8

Do you have one master bms or multiple ?

@bernstein7
Copy link

for jkpb you need rs485 adapter to TxRx 326189763-26176aff-c3e0-43b0-8675-f3bb18dc5ab8

Do you have one master bms or multiple ?

Thanks! Just one master bms JK-PB2A16S-15P

@meccip
Copy link

meccip commented Sep 15, 2024

use RS485 bms socket - pin 1-B and pin 2-A. Wire to A-B adapter and then connect esp to RxTx to adapter and a separate 5v supply to GND and Vcc adapter.
You can use jkpb modbus yaml on esp and select in bms UART1 protocol 001-jkbms rs485
or you can use old jkbms yaml on esp and select in bms UART1 protocol 000-4G GPS Remote

@bernstein7
Copy link

use RS485 bms socket - pin 1-B and pin 2-A. Wire to A-B adapter and then connect esp to RxTx to adapter and a separate 5v supply to GND and Vcc adapter. You can use jkpb modbus yaml on esp and select in bms UART1 protocol 001-jkbms rs485 or you can use old jkbms yaml on esp and select in bms UART1 protocol 000-4G GPS Remote

Awesome! Thank you so much @meccip 👍🏻

@Ghilm1986
Copy link

Hi, i m going to buy a Pb2A16S20P v15.
In the first time i ll use it as only master, but i already have a b2A20S20P on another battery pack working perfectly with esp32 and bt protocol.
Can I use another esp32 (already at home)via Bt with the new Pb or I need a rs485 adapter?.
In case I'll change my older b2A with one other pb, I ll Need another connection or the master will manage all the bms?
Thanks a lot

@meccip
Copy link

meccip commented Sep 19, 2024

If you use BT connection, you dont need adapters. Just use new esp with BT yaml file for jkpb series. You can add 15 jkpb in master-slave position.

@Ghilm1986
Copy link

Thanks for the explanation..i should use which protocol for the pb into esp32?

@meccip
Copy link

meccip commented Sep 19, 2024

#390 (comment)

@Ghilm1986
Copy link

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests