esphome-jk-bms icon indicating copy to clipboard operation
esphome-jk-bms copied to clipboard

Add JK-PB bms compatibility. Target: 1 ESP in a "listening mode" connected to RS485 network.

Open txubelaxu opened this issue 1 year ago • 65 comments

JK-PB2A16S-20P model jk-bms. Two bms connected to that RS485 internal network. ubuntu connected in a "listening mode" using a USB<->RS485 adaptor.

txubelaxu avatar Feb 25 '24 11:02 txubelaxu

I have created a new component: "jk_rs485". It is for JK-PB HW v14. This is a sniffing way to gather information across the RS485 network. The goal to achieve is to gathering information about every jk-bms using only one ESP. This way, Bluetooth remains free.

To compile: esphome compile esp32-example-rs485.yaml

Pending:

  • testing
  • configure yaml with multiple BMSs. Each one: 1 address [0x00,0x0f]. So, address paramether to insert inside yaml config is pending.

txubelaxu avatar Mar 03 '24 19:03 txubelaxu

I will have a look as soon as possible. Please give me some time! :-)

syssi avatar Mar 04 '24 21:03 syssi

Sorry!! I am very newbie at github. 👏👏😉

txubelaxu avatar Mar 05 '24 12:03 txubelaxu

No problem. Feel free to ask any questions.

syssi avatar Mar 05 '24 12:03 syssi

No problem. Feel free to ask any questions.

Many thanks, Sebastian. Certainly, I do not know how to manage/arrange the "code + configuration.yaml" to demultiplex the info arraiving from RS485. So, I have got the info about every BMS connected to the RS485 network (it does not matter how many are: max 16). I know how to pass the UART information to the jk_rs485 component (but only one). But I have achieve the goal of sharing the same UART with two jk_rs485 components. I would like to:

  1. remake the configuration.yaml structure in order to place inside that file each jk_rs485 node: each one with a identifyer and an address.
  2. "publish_state" info and settings, but signaling the identifyer (not address) of the jk_rs485 node.

I do not know if this is possible.

Many thanks!!

txubelaxu avatar Mar 05 '24 15:03 txubelaxu

any chance you could put a wiring diagram together so I can test with my 3 new JK BMS?

brycelarge avatar Mar 10 '24 05:03 brycelarge

any chance you could put a wiring diagram together so I can test with my 3 new JK BMS?

https://github.com/syssi/esphome-jk-bms/issues/463#issuecomment-1973320806

txubelaxu avatar Mar 10 '24 09:03 txubelaxu

any chance you could put a wiring diagram together so I can test with my 3 new JK BMS?

#463 (comment)

Which Ethernet wires go to tx and rx on the ESP board?

brycelarge avatar Mar 10 '24 13:03 brycelarge

any chance you could put a wiring diagram together so I can test with my 3 new JK BMS?

#463 (comment)

Which Ethernet wires go to tx and rx on the ESP board?

image

txubelaxu avatar Mar 10 '24 14:03 txubelaxu

it is not ethernet. It is RS485, ok? You need a USB to RS485 adaptor.

txubelaxu avatar Mar 10 '24 14:03 txubelaxu

it is not ethernet. It is RS485, ok? You need a USB to RS485 adaptor.

USB plugs into the ESP32 dev board and RJ45 into the RS485 port in the inverter?

brycelarge avatar Mar 10 '24 14:03 brycelarge

Sorry my mistake. Forget my previous answer.

ESP TXRX to a serial2RS485 converter. From this converter to the right (any of the two) existing RJ45 connectors.

txubelaxu avatar Mar 10 '24 14:03 txubelaxu

Can you point to a code that should be loaded to ESPHome please? Is it working already? Master and Slave Sniff? I have 1 Master and 6 Slaves right now lol.

denveronly avatar Mar 10 '24 18:03 denveronly

I am trying to develope a solution. At this moment, half working code is at my github

txubelaxu avatar Mar 10 '24 20:03 txubelaxu

I am trying to develope a solution. At this moment, half working code is at my github

What is working at this moment and what is not

denveronly avatar Mar 11 '24 11:03 denveronly

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

txubelaxu avatar Mar 11 '24 11:03 txubelaxu

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

With pleasure. I will start preparing the ESP for that and write back in 24-48hrs Need the converter

denveronly avatar Mar 11 '24 18:03 denveronly

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

brycelarge avatar Mar 12 '24 08:03 brycelarge

If we have 1 master and 2 slaves what would the rs485_address be on the second slave? esp32-example-jkpb-rs485.yaml shows master at rs485_address: 0x00 and first slave at rs485_address: 0x07

brycelarge avatar Mar 12 '24 08:03 brycelarge

Master always must be 0x00. 1 master is mandatory. If no master, no data.

Slaves: any address from 0x01 to 0x0f Each slave one different address.

El El mar, 12 mar 2024 a las 9:34, Bryce Large @.***> escribió:

If we have 1 master and 2 slaves what would the rs485_address be on the second slave? esp32-example-jkpb-rs485.yaml shows master at rs485_address: 0x00 and first slave at rs485_address: 0x07

— Reply to this email directly, view it on GitHub https://github.com/syssi/esphome-jk-bms/pull/464#issuecomment-1991038248, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDAWOAJDKSN7IZMXDLYX242JAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGAZTQMRUHA . You are receiving this because you modified the open/close state.Message ID: @.***>

txubelaxu avatar Mar 12 '24 08:03 txubelaxu

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

In the converter I have used,

  1. the converter needs +5Vcc and GND
  2. the RS485 bus needs: A, B and GND "GND" point in this device is the same for 1) and for 2)

Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know.

txubelaxu avatar Mar 12 '24 10:03 txubelaxu

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

In the converter I have used,

1. the converter needs +5Vcc and GND

2. the RS485 bus needs: A, B and GND
   "GND" point in this device is the same for 1) and for 2)

Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know.

Thanks just wanted to try understand.

I got everything working just the temp sensors not working

brycelarge avatar Mar 12 '24 11:03 brycelarge

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

In the converter I have used,

1. the converter needs +5Vcc and GND

2. the RS485 bus needs: A, B and GND
   "GND" point in this device is the same for 1) and for 2)

Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know.

Thanks just wanted to try understand.

I got everything working just the temp sensors not working

None of temp sensors? temp0 and temp1 are not working?

txubelaxu avatar Mar 12 '24 11:03 txubelaxu

Updated. @denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

In the converter I have used,

1. the converter needs +5Vcc and GND

2. the RS485 bus needs: A, B and GND
   "GND" point in this device is the same for 1) and for 2)

Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know.

Thanks just wanted to try understand. I got everything working just the temp sensors not working

None of temp sensors? temp0 and temp1 are not working?

Yes temp 1 and 2 are not working.

brycelarge avatar Mar 12 '24 11:03 brycelarge

I have to review that. I have not changed that code but I see it was there before.

How many BMS have you connected using RS485 network? 3 (1 master and 2 slaves?

El mar, 12 mar 2024 a las 12:34, Bryce Large @.***>) escribió:

Updated. @denveronly https://github.com/denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md

Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams?

In the converter I have used,

  1. the converter needs +5Vcc and GND

  2. the RS485 bus needs: A, B and GND "GND" point in this device is the same for 1) and for 2)

Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know.

Thanks just wanted to try understand. I got everything working just the temp sensors not working

None of temp sensors? temp0 and temp1 are not working?

Yes temp 1 and 2 are not working.

— Reply to this email directly, view it on GitHub https://github.com/syssi/esphome-jk-bms/pull/464#issuecomment-1991446647, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDHCFFP25NCJVOW4W3YX3R3LAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2DMNRUG4 . You are receiving this because you modified the open/close state.Message ID: @.***>

txubelaxu avatar Mar 12 '24 11:03 txubelaxu

I have to review that. I have not changed that code but I see it was there before. How many BMS have you connected using RS485 network? 3 (1 master and 2 slaves? El mar, 12 mar 2024 a las 12:34, Bryce Large @.>) escribió: Updated. @denveronly https://github.com/denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams? In the converter I have used, 1. the converter needs +5Vcc and GND 2. the RS485 bus needs: A, B and GND "GND" point in this device is the same for 1) and for 2) Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know. Thanks just wanted to try understand. I got everything working just the temp sensors not working None of temp sensors? temp0 and temp1 are not working? Yes temp 1 and 2 are not working. — Reply to this email directly, view it on GitHub <#464 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDHCFFP25NCJVOW4W3YX3R3LAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2DMNRUG4 . You are receiving this because you modified the open/close state.Message ID: @.>

Yes 1 master and 2 slaves. MOS temp is working just not temp 1 and 2

brycelarge avatar Mar 12 '24 11:03 brycelarge

Maybe it is because is an array of temperatures, and MOS temp is a parameter independent. I will review that.

El mar, 12 mar 2024 a las 12:40, Bryce Large @.***>) escribió:

I have to review that. I have not changed that code but I see it was there before. How many BMS have you connected using RS485 network? 3 (1 master and 2 slaves? El mar, 12 mar 2024 a las 12:34, Bryce Large @.

>) escribió: … <#m_323099578995665119_> Updated. @denveronly https://github.com/denveronly https://github.com/denveronly https://github.com/denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams? In the converter I have used, 1. the converter needs +5Vcc and GND 2. the RS485 bus needs: A, B and GND "GND" point in this device is the same for 1) and for 2) Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know. Thanks just wanted to try understand. I got everything working just the temp sensors not working None of temp sensors? temp0 and temp1 are not working? Yes temp 1 and 2 are not working. — Reply to this email directly, view it on GitHub <#464 (comment) https://github.com/syssi/esphome-jk-bms/pull/464#issuecomment-1991446647>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDHCFFP25NCJVOW4W3YX3R3LAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2DMNRUG4 https://github.com/notifications/unsubscribe-auth/BFHIJMDHCFFP25NCJVOW4W3YX3R3LAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2DMNRUG4 . You are receiving this because you modified the open/close state.Message ID: @.>

Yes 1 master and 2 slaves. MOS temp is working just not temp 1 and 2

— Reply to this email directly, view it on GitHub https://github.com/syssi/esphome-jk-bms/pull/464#issuecomment-1991456539, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMAAUNGG4O5YBTTZUX3YX3SSVAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2TMNJTHE . You are receiving this because you modified the open/close state.Message ID: @.***>

txubelaxu avatar Mar 12 '24 11:03 txubelaxu

I have to review that. I have not changed that code but I see it was there before. How many BMS have you connected using RS485 network? 3 (1 master and 2 slaves? El mar, 12 mar 2024 a las 12:34, Bryce Large @.>) escribió: Updated. @denveronly https://github.com/denveronly, could you test this? https://github.com/txubelaxu/esphome-jk-bms/blob/main/components/jk_rs485_bms/README.md Thanks for the hard work here. Quick question, is there a reason why you have all the grounds connected together in your wiring diagrams? In the converter I have used, 1. the converter needs +5Vcc and GND 2. the RS485 bus needs: A, B and GND "GND" point in this device is the same for 1) and for 2) Maybe there is in the market a device to "isolate" two circuits (optocoupled). I do not know. Thanks just wanted to try understand. I got everything working just the temp sensors not working None of temp sensors? temp0 and temp1 are not working? Yes temp 1 and 2 are not working. — Reply to this email directly, view it on GitHub <#464 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDHCFFP25NCJVOW4W3YX3R3LAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGQ2DMNRUG4 . You are receiving this because you modified the open/close state.Message ID: _@**.**_>

Yes 1 master and 2 slaves. MOS temp is working just not temp 1 and 2

added: jk-rs485-bms/sensor/bms0_temperature_sensor_1/state 19.4 jk-rs485-bms/sensor/bms0_temperature_sensor_2/state 20.1 jk-rs485-bms/sensor/bms0_temperature_sensor_4/state 19.4 jk-rs485-bms/sensor/bms0_temperature_sensor_3/state 20.2

jk-rs485-bms/sensor/bms1_temperature_sensor_1/state 18.7 jk-rs485-bms/sensor/bms1_temperature_sensor_2/state 19.4 jk-rs485-bms/sensor/bms1_temperature_sensor_4/state 18.7 jk-rs485-bms/sensor/bms1_temperature_sensor_3/state 18.8

txubelaxu avatar Mar 13 '24 10:03 txubelaxu

Ive made a test board as soon as the converter arrived. All went smooth, but one thing. All that my ESP is giving is BMS0 info. (i have 1 Master and 6 Slaves) The code has bms0 and bms1, i didnt implement those 5 more it is not important i guess.

Dip switches are correct (BMS's Bluetooth name changes to DIP switch number set)

Do you have an idea why i am not receiving other BMS's?

[19:39:22][W][component:214]: Component jk_rs485_sniffer took a long time for an operation (1.16 s). [19:39:22][W][component:215]: Components should block for at most 20-30ms.

Maybe my RS485 bus info is very large due to number of devices, and it doesnt complete the handshake crashing the sniffer component idk.

Logs with UART and LOGGER in DEBUG MODE here: https://pastebin.com/NS376nhZ

denveronly avatar Mar 13 '24 17:03 denveronly

yaml code needs all bms references.

Send me your yaml and I could modify if you want. Tell me each bms address as well.

El El mié, 13 mar 2024 a las 18:42, denveronly @.***> escribió:

Ive made a test board as soon as the converter arrived. All went smooth, but one thing. All that my ESP is giving is BMS0 info. (i have 1 Master and 6 Slaves) The code has bms0 and bms1, i didnt implement those 5 more it is not important i guess.

Dip switches are correct (BMS's Bluetooth name changes to DIP switch number set)

Do you have an idea why i am not receiving other BMS's?

— Reply to this email directly, view it on GitHub https://github.com/syssi/esphome-jk-bms/pull/464#issuecomment-1995140980, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFHIJMDIT6LD5K3QBHFLXVLYYCF2DAVCNFSM6AAAAABDYZKHACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVGE2DAOJYGA . You are receiving this because you modified the open/close state.Message ID: @.***>

txubelaxu avatar Mar 13 '24 18:03 txubelaxu