Closed PRADIPMAHAJAN closed 3 years ago
Thank you so much for your response. But now I am trying to get data through python code using UART-USB cable when I send the command to BMS. BMS gives the response but how can I convert this response to a human-readable form. please help if you have an idea about that.
########################## python-code ################################ import serial import time
port = "COM6" baud = 9600 ########################
startFlag = bytes.fromhex("A5")
moduleAddress = bytes.fromhex("40")
commandID = bytes.fromhex("90")
dataLength = bytes.fromhex("08")
data = bytes.fromhex("00" * 8)
checksum = 0
_cmd = startFlag + moduleAddress + commandID + dataLength + data
for b in _cmd: checksum += b
checksum = checksum & 0xff
checksum = f"{checksum:02X}" checksum = bytes.fromhex(checksum)
print(f"checksum: {checksum}")
cmd = _cmd + checksum + b"\n" print (f"sending command {cmd}")
with serial.serial_for_url(port, baud) as s: s.timeout = 1 s.write_timeout = 1 s.flushInput() s.flushOutput() bytes_written = s.write(cmd) print (f"wrote {bytes_written} bytes")
response_line = s.readline()
#time.sleep(2)
print (f"Got response: {response_line}")
Output is : sending command b'\xa5@\x90\x08\x00\x00\x00\x00\x00\x00\x00\x00}\n' wrote 14 bytes Got response: b'\xa5\x01\x90\x08\x01\xcc\x00\x00u0\x01\xf4\xa5' PS C:\Users\Pradip\Desktop\python_code>
here the first byte is started bit second is address third is the command for getting SOC than the fourth 8 bytes data then from xcc to xa5 is our data but how can I change that.
can you show your wiring connection of Daly BMS with arduino please I need your help.
I don't have a Daly BMS, I used this one. https://www.aliexpress.com/item/32844170262.html Not available any more. I don't use Python either.
I have a DalyBMS which has a UART port in this UART port there is a 6 pin, But I am using only three-pin first GND second last for Tx, and last for Rx. Because RS-458 cable also used the same. and Arduino Uno pin 10 is connected to the Tx pin of Daly BMS and Arduino Uno 11 is connected to the Rx pin of Dalybms. but when I upload the code below https://github.com/bres55/Smart-BMS-arduino-Reader/blob/master/smart_bms_reader_Mega_v11.ino code is running on serial port but the value remains the same not update. please I need your help.
I changed my code in some places for UNO
include
SoftwareSerial MySoftSerial(10, 11);
define MySerial MySoftSerial
Serial.begin(9600); // will be sending all data to serial, for later analysis // newline in serial com on for 2way communication. MySerial.begin(9600); // set the data rate for the MySerial port
can we need to more changes in this code .