-
Notifications
You must be signed in to change notification settings - Fork 151
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
JK BMS RS485 protocol #112
Comments
I've had a go at adding the first attempt at this protocol (called it jk232), likely still got work to do |
Thank you.
|
So still some bugs in the code - but more importantly there was no response from the device |
Am now using my Victron RS485 to USB cable. Higher quality and I know it works.
OUTPUT protocol: 232 using Victron dongle:
OUTPUT protocol: 485 using Victron dongle:
I'm none the wiser. Ready and willing to try what ever you think may move this forward. |
Well that output is slightly better (we are getting a response |
can you try running the below import serial
import time
## Vars ################
port = "/dev/ttyUSB0"
baud = 9600
########################
# DD A5 03 00 FF FD 77
cmds = [b'\xdd\xa5\x03\x00\xff\xfdw', b'\xdd\xa5\x03\x00\xff\xfdw\n', b'\xdd\xa5\x03\x00\xff\xfdw', b'\xdd \xa5 \x03 \x00 \xff \xfd w', b'DD A5 03 00 FF FD 77' , b'DDA50300FFFD77']
with serial.serial_for_url(port, baud) as s:
s.timeout = 1
s.write_timeout = 1
s.flushInput()
s.flushOutput()
for cmd in cmds:
print (f"sending command {cmd}")
bytes_written = s.write(cmd)
print (f"wrote {bytes_written} bytes")
for _ in range(5):
response_line = s.readline()
time.sleep(1)
print (f"Got response: {response_line}") |
Corrected syntax error for future testing.
Ran the script, a few times:
But got this every so often:
Could this be a timing issue? Also would it make any difference to use Serial.RS485? |
Opps thanks - will edit the comment
It could be - is anything else using the port?
It shouldnt - it looks to me like we are communicating ok, but not the correct commands (but I cant be sure) |
Could the Bluetooth of the BMS be messing with it? There was a flurry of green LED right before test script ended, but and as each command was sent. |
It is possible - I have never used a JKBMS with RS485 before - is there any options in the BLE app? I know there is also a CAN bus as well, is that connected as well?
Was the script still trying to read a response? |
No options in BLE App.
Only RS485 plug connected.
Don't know, possibly just flushing buffer on error. Will contact seller and see if they can help. Thanks again. 12/05/21: Waiting for seller to get back to me. |
Got response from seller: They sent back yet another protocol document in CHINESE. I then put this through GOOGLE Translate: BMS Protocol V2.5 ENGLISH (GOOGLE Translate).pdf This protocol seems radically different to any other I have seen so far. I gladly hand it over to you to take a bite at it. |
I have tried this command to activate the bms, but no joy: Send: 4E57 0013 00000000 01 00 00 00 00000000 68 00000121 and this one to get ALL data, still no joy: Send: 4E57 0013 00000000 06 00 00 00 00000000 68 00000129 Contacting seller again. |
How are you sending it? Can you post the code you used
I should get a chance to look at the doc today.
…On Mon, 17 May 2021, 3:47 am Clifford Raccani, ***@***.***> wrote:
I have tried this command to activate the bms, but no joy:
Send: 4E57 0013 00000000 01 00 00 00 00000000 68 00000121
and this one to get ALL data, still no joy:
Send: 4E57 0013 00000000 06 00 00 00 00000000 68 00000129
Contacting seller again.
Fingers crossed.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJVKNQSCJAGYLWKYSHX7WDTN7SJLANCNFSM44N5NMBA>
.
|
I've used both a program called Windmill comDebug and the following python script from your test script. Here is the code:
|
What response do you get? Nothing or \x00 ? It looks like you are running this on windows? Do you have a linux type system to test on? |
Sorry I butchered your Python script. Response is always 0x00 tried: Tried:
but again returns 0x00 Should receive this other USB to RS485 converter tomorrow: https://www.amazon.co.uk/gp/product/B082D5PXJ4/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 |
Progress, READ ALL:
RESPONSE (my indenting):
|
awesome news, what changed? |
Not using their TTL-RS485 dongle. Seems to be a faulty one. |
Machine readable list of Codes extracted from protocol document: 5.1 BMS Read/Write data identification code
*** Note 1
Note2
|
Hello, i see this issue here and have some important informations for you ;) and i got the Rs485 working but this was a lot of trouble... first the Documentation you have is an very old one ... i got an "newer" version after some discussion with the distributer ;) they send me the protocol in Chinese but i but it into an translate .... i see you already have this also ;) for Example they Change the Baudrate up to 115200 instead off 9600 ;) and even more ... second the USB to RS485 dongle you use, you can but this into the trash on my side this wans working fine it received alswasy "random" byte sometime ... but now the Problem with the RS485... I am able to read out the available values form the BMS but you cant write something and the response from the distributer was the RS485 is only for read not for write ... so with this i would say the Rs485 is not an alternative to the Bluetooth app ... and there fore i am currently searching for the Bluetooth protocol ... did someone have this ? or how the impl here was done ??? or is it the same and i only need to connect via BL ? what is whit UUID´s ??? |
I have not seen a bluetooth protocol document - the current implmentation was from reverse engineering the comms between app and unit. |
Hey @jblance |
The jkbms command with a port that is a MAC address will default to ble comms. There's some details in the usage doc |
I will test it when I finally receive my BMS. If it works I will share the results. |
@logmod Yes all their bms goes with vbat on the connector, because they have their own external uart<>rs485/can box .. and they need to power it :) The implementation is not bad .. but they could have added a damn fast fuse on the pcb for the connector ... @syssi You want uart<>uart opto or to other proto ? If you need uart<>RS485 DFRobot Isolated RS485 to UART Signal Adapter Module tested it at 4KV this is my max limit .. and it was ok. In my case I'm going on isolation from rs485 to RJ45, I'm using Industrial serial server, RS485 to RJ45 Ethernet from waveshare. For the comm you only need rx/tx/gnd .. and gnd if you don't want to really couple it you can add an resistor over 10K and it should be in the safe spot. Because for my need's I'm doing dynamic, voltage control, amperage control, base on some thresholds, all implementation goes between RS485 protocol.. mqtt(raspberry)<>HASS, and I like to have an history of the bank's ... and remote access :) |
Actually a nice idea to convert the serial output to IP, but I wanted to get rid of the RS485 converter and keep the connection to my board as simpel and safe as possible. Not sure to understand the remark about the 100k resistor, usually a 1k resistor is used to protect TTL inputs. Could you elaborate on that? |
I wanted to say 10K .. too many 0 :), edited, well think like this you have one isolation from uart<>rs485 and another one from rs485 to ether IP. Advantage on this is that you can do whatever automation you want after with any kind of equipment .. and it's wire .. only rats can affect it :) |
@syssi I have found a cheap ready-made isolator board that would fit your requirements to get the TTL signal directly from the Bluetooth interface. Its from Hailege based on an ADUM1201 Dual Channel Digital Magnetic Isolator (available e.g. on Amazon). You can power it from inside the BMS board with the available 3.3V suppy. On the outside you can directly connect it to your GPIO and the outside 3.3V. Adding a DIP switch in the connector cable to pull down RST you could have a dual-solution (BLE/serial) in parallel. |
Hi, I just wanted to know if this android app you used, runs on Bluetooth or it can also work with USB to otg connected to the mobile? If it can work using the USB to otg with the mobile, then can you please share the app? Thanks. |
No need to reopen, just want to mention that this issue was same for me. |
1.25mm 1.25 Micro JST Stecker 15cm Kabel |
Try searching for ICQUANZX ADUM4160 on Amazon, specs for the BM board interface are in this thread. |
As I had no JST 1.25 connector at hand and did not want to cut the one from the RS485 converter, I have figured out how to use the converter with an ESP8266 to query the BMS. As I use NODEMCU (LUA) for prototyping, first I had an issue with the RX serial buffer overflowing when receiving ALL the data at once at 115200 baud. So I had to figure out how to query only a certain value to receive less data and avoid the overflow: voltage The only stuff you have to change in the commands above is the code (83, 84, 85) and the CRC (sum of all values) to create your own query. See 5.1 BMS Read/Write data identification code in the table above to find your query code. After this I still did not receive the data on the ESP but I was able to receive it with a PC using an RS485-to-USB converter. It turned out that the TTL-to-RS485 converter interfacing with the ESP was not able to switch back to receiving mode fast enough. So it missed the response of the BMS. I added a second TTL-to-RS485 module for separate sending and receiving and now it works just fine with the official converter. The only drawaback of this approach is that I am also receiving my own command in front of the BMS response, but it is easy to filter it out in the software. Hope this helps someone. |
Hello, Seems with new hardware V11x, there are now both the UART-TTL (on GPS port) and RS485 on CAN bus. There are new options available on the appz Anyone tried to communicate via RS485 (modbus RTU ?), especially now there is an option to select the (modbus) address.... I hope it means we can have several JKBMS v11x on the same bus... |
what is the BMS response for this request ? |
4E57001300000000030300830000000068000001A9 |
4E57001300000000030300830000000068000001A9 is the command to get voltage value from the BMS. I need the an example that what kind of reply (receiving data ) from the BMS. request - 4E57001300000000030300830000000068000001A9 |
I made a translation file in excel from my project: |
Anybody tried this? I need comms with 9 BMSes! |
Does anyone know if there is any software that can parse this protocol yet? They issue was closed twice, but I'm not seeing any solution. I can send byte series mentioned and receive replies, but I was wondering if there already is a parser that works? |
now that esphome has modbus server support should be very easy to implement, use a modbus sniffer and see what address the inverter is asking and then use the address to query the jk-bms inverter to see what actual data is sent on those addresses, maybe I'll do a map as now I have one of those bms. |
https://github.com/stamina84/jk-bms/blob/main/serial/read_bms.py |
Please keep in mind we are probably talking about different device models / modbus register addresses / ports of the BMS here. On pretty new device models the protocol of the different UARTs is configurable now. These are the modbus registers of the JK-BMS PB (inverter) series: https://github.com/syssi/esphome-jk-bms/blob/main/docs/pb2a16s20p/BMS%20RS485%20Modbus%20V1.1.pdf This protocol is called
|
I'm talking about the most easy way, as in the new inverter bms there is the pylon modbus protocol as option and I think this ia the standard on many inverters so nothing fancy should be needed there, just the registers, and yes the data could be gained by using the gps port or ble and maybe the limited can/rs485 has enough data to be used also, of course with all that charging algorithm |
the registers presented are useful only as a bms monitor not actually what the inverter is asking on the battery side as an off-topic, I'm using this method to read the bms data but some values from time to time are with errors, like 4s valid data 2s some aproximate value, did someone has this issue or it's my modbus adapter is at fault, tried also the new 9600 bit rate available on the new firmware |
Let's have a look into the supported protocols of this project (mpp-solar): JK232
https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jk232.py This protocol was the protocol of the BMS firmware version <4. JK485
https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jk485.py This is the protocol of a pretty old Active Balancer called JK-DZ11-B2A24S. JK02/JK02_32/JK04
https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jk02.py This is the BLE communication (jk04 is the oldest one, jk02 was used up to firmware version 11, jk02_32 is currently used protocol). JKSERIAL
This is the UART-TTL / GPS port protocol. https://github.com/jblance/mpp-solar/blob/master/mppsolar/protocols/jkserial.py |
Please find attached a different RS485 protocol document, sent to me by IC GOGOGO Store for the BMS I bought from them.
I have also just received their RS485 Dongle.
The Dongle plugs into the BMS but the dongle ends in 3 bare wires at the other end. I presume these are RS485- GND, A+, B+.
I have connected these to an RS485-USB dongle.
Any experience with this setup.
I tried your RS485 protocol but did not receive any bytes back.
So looks like this BMS may use a different protocol.
Any chance of adding this protocol:
RS485-english.pdf
The text was updated successfully, but these errors were encountered: