-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add UART-TTL command support (write registers) #343
Conversation
09c4fd8
to
f90bb87
Compare
Hi Did a quick build but looks like it is not working. Below the logs. Did you put 100ms delay between the 0x5 and the write request as from below it seems there is no delay? |
@syssi also update the crc frame length to 18 as per the main thread. |
Fixed. Is the delay required? I would like to avoid delays as long as possible. |
From the documentation they state it is required between requests but lets test without it with the checksum fixed. |
Ok tested still not working likely would need some delay between the auth and write request. |
I've added a |
Ok works now but see this in the logs "[jk_bms:056]: Invalid size (5) for JK BMS frame!" not sure why but will have to check. Also balancer switch not working looks like you not using the correct register. Balancer Switch: Below logs for charge and discharge that is working: |
Had a quick look at seems like in jk_bms.cpp the registers from after 0x90 will need to checked and aligned with the latest documents. Hopefully not a difference for older version of the BMS that would need to be catered for. Using this document as a reference: |
Hmm... it looks like the registers has changed over time. Interesting. |
Ok also does not work but I have also now checked and looks like 0x9D was correct corresponding with example document: Difficult without the correct documentation. Will have to see why it did not want to write with 0x9D. Also confirmed the 0x9D changes when changing the switch via BLE app. |
Could you try to identify the minimum required delay? |
Ok I have done further testing but cannot get the balancer switch to change. I think you will have to just do the charge and discharge switches for now which I believe is a huge improvement already. I will try and see what I can get out of JK further. If we can just get the code for bluetooth module we should be able to get this working quickly as that seem to have the best knowledge of the protocol of the BMS. For the authentication you can also change the 0xB2 to 0x00 as it seems to be ignored. For the delay between the auth and the write it appears to work with 10ms even I guess it depends on what the BMS microcontroller is busy with. My testing for this was using a lambda to build the frame for uart.write function in esphome config so might be handled slightly differently to the delay you adding at the lower level code side. I guess the best way to test would be to for you build and the modify the value and rebuild and test. |
After some further testing I will keep delay at 100ms. |
@jrventer I've applied all suggestions! Thanks a lot for heavily testing. I've the chance today to test the code on a pretty old BMS firmware version. If it does work out of the box this is ready to get merged! |
|
My BMS (JK-BD6A17S6P, hw 7.2, sw 7.1.0H) needs a pretty high delay around 200ms to accept authenticated write instructions. But it's working!! :-) |
@syssi Not sure if you are aware but JK actually list your project url right at the top of the document they ship with the BMS. I only noticed it recently as I did not really look at it before. So they basically acknowledge that the community have a better understanding on their communication interfaces. I suspect they got a 3rd party company to develop the BMS firmware and communication components thats why they are not able to easily access information on this topic. |
We already celebrated this nice fact a year ago here: #132 |
Any progress on the balancing switch? Would be awesome if it worked via uart. |
See #341