diy solar

diy solar

Simple Seplos BMS Protocol Decode Bash Script

sidepipe

New Member
Joined
Feb 7, 2022
Messages
8
In case anyone's interested, I've created a quick and dirty shell script to read the telemetry data from a Seplos BMS here. It should work on something like a Raspberry PI with a standard Debian install, with the BMS connected via a USB to RS485 serial. You will need to edit the serial device ( and maybe address if you have more than one connected ) at the top of the script.

You simply pass a command code and associated data, so
query_seplos.sh 4F00 will get the protocol version string
query_seplos.sh 4201 will get ( and decode ) the battery status information

It's only really intended as a proof of concept - you can edit it to do what you want.... I've made no attempt to tidy it up or optimise it at this point. Also, no guarantees other than it works for me! Obviously it's compressed, so you'll need to download it from my Google Drive link and bunzip2
 
Last edited:
Nice. Could you make one to decode Pylontech BMS data?
I would just like to be able to read single cell voltages.
-
 
Hi, I couldn't understand how to use this script. I tried it on my Raspberry PI connected to the BMS but I get binary output. Any usage instruction will be helpful. I want to get full battery voltage data from the BMS and log it into influx, I can do it from the ME3000SP inverter's RS485 interface but not from this BMS. If I can get it working I can try to translate this in python.
 
Hi, I couldn't understand how to use this script. I tried it on my Raspberry PI connected to the BMS but I get binary output. Any usage instruction will be helpful. I want to get full battery voltage data from the BMS and log it into influx, I can do it from the ME3000SP inverter's RS485 interface but not from this BMS. If I can get it working I can try to translate this in python.
There are no real usage instructions other than what I wrote in the first post. The only data it decodes is the battery data, so if you run

Bash:
./query_seplos.sh 4201

then you should see human readable information about the status, including cell voltages and temperature.

As I mentioned, it's not meant to be a fully fledged piece of software, just a framework for people to use.

The only other thing I can think of is you need to make sure that "bc" is installed on your PI - I don't think it is by default.
 
Tried a few times today but failed to read anything meaningful, not sure what is wrong here

Bash:
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Failed to read start of input char (~), read "7050CD50CD60CD60CD50CD7060B7D0▒"
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4F00
Sending "~2000464FE00200FD23\r\n"
Failed to read start of input char (~), read "▒d*$▒▒"
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4F00
Sending "~2000464FE00200FD23\r\n"
Failed to read start of input char (~), read "▒낢▒▒▒▒▒▒▒2       4"
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4F00
Sending "~2000464FE00200FD23\r\n"
Failed to read start of input char (~), read "▒낢▒▒▒▒▒▒▒2       4"
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Failed to read start of input char (~), read "80CD50CD60CD60CD50CD40CD70CD50CD40CD70CD50CD50CD60CD60CD50CD7060B7D0B7A0B870B840B920B8C000014896CD40A6D6003E36D60007803E8148B0000000000000000DCD0"
 
Right. I wonder how the "~20004642E00201FD36" (or "~2000464FE00200FD23" or whatever) is worked out.
-
 
Tried a few times today but failed to read anything meaningful, not sure what is wrong here
Looks as though something else might be using the serial port and interfering with the data. Do you have any remote serial software running ( such as ser2net ) or is anything else using it? What does

Bash:
sudo lsof | grep ttyUSB0

show? ( Obviously if your BMS isn't on ttyUSB0 change to the correct port. )
 
Looks as though something else might be using the serial port and interfering with the data. Do you have any remote serial software running ( such as ser2net ) or is anything else using it? What does

Bash:
sudo lsof | grep ttyUSB0

show? ( Obviously if your BMS isn't on ttyUSB0 change to the correct port. )
It worked once :) and then it stopped :(.

I have been running my python code to read data from the inverter over RS485 to USB interface but I stopped that before running this code.

Bash:
pi@raspberrypi:~ $ lsof | grep -i ttyUSB
python3   24751                               pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24774 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24775 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24776 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24777 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24778 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24779 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24781 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24782 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24783 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
python3   24751 24784 python3                 pi    4u      CHR      188,0      0t0        456 /dev/ttyUSB0
pi@raspberrypi:~ $ sudo service BatteryStorageManager stop
pi@raspberrypi:~ $ lsof | grep -i ttyUSB
pi@raspberrypi:~ $ lsof | grep -i ttyUSB
pi@raspberrypi:~ $ lsof | grep -i ttyUSB
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Number of cells: 16
Cell 1: 2937mV
Cell 2: 2936mV
Cell 3: 2937mV
Cell 4: 2937mV
Cell 5: 2937mV
Cell 6: 2937mV
Cell 7: 2907mV
Cell 8: 2937mV
Cell 9: 2921mV
Cell 10: 2937mV
Cell 11: 2936mV
Cell 12: 2924mV
Cell 13: 2905mV
Cell 14: 2937mV
Cell 15: 2923mV
Cell 16: 2905mV
Cell Temp  22.4C
Cell Temp  22.1C
Cell Temp  23.2C
Cell Temp  22.9C
Environmental Temp 24.2C
Power Temp 22.7C
Charge/Discharge: 0A
Total Voltage: 46.85V
Residual Capacity: 222.47Ah
Battery Capacity: 280.00Ah
SOC: 79.4%
Rated Capacity: 280.00Ah
Cycles: 122
SOH: 100.0%
Port Voltage: 46.88V
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Failed to read start of input char (~), read "▒▒}▒▒▒▒▒▒▒ʲ▒▒▒▒▒▒▒780B770B780B780B780B780B5B0B780B690B790B780B6C0B590B790B6C0B5A060B8B0B880B940B900B9E0B8E0000124C56E70A6D60031A6D60007A03E8124F0000000000000000DD66"
pi@raspberrypi:~/BattStorageManager $ lsof | grep -i ttyUSBlsof | grep -i ttyUSB^C
pi@raspberrypi:~/BattStorageManager $ lsof | grep -i ttyUSB
pi@raspberrypi:~/BattStorageManager $ lsof | grep -i ttyUSB
pi@raspberrypi:~/BattStorageManager $ ./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Failed to read start of input char (~), read "▒▒}▒▒▒▒▒▒▒ʲ▒▒▒▒▒▒▒780B760B770B770B770B770B5B0B770B680B780B770B6B0B590B780B6B0B5A060B8B0B880B930B900B9E0B8E0000124B56E70A6D60031A6D60007A03E8124E0000000000000000DD75"

Not sure what is happening here. Is this due to cheap RS485 to USB converter. Must add that BMS and the inverter are on the same RS485 wire on different addresses.
 
It will almost certainly be because you've got two devices on the same line - the script makes no attempt to perform any arbitration of the bus.

As I mentioned it was only ever meant as a proof of concept - I'm actually using it ( or a version of it ) for myself but I have a 1:1 connection so I've no need to do more, and I know it works reliably when there is just a single device. I don't really have the time to spend on it, sorry.
 
hi
any info about "warn and protect" messages ?
are they coded in "remote communication data" ?
Any help is appreciated ;)
 
Hi @sidepipe i wrote a script that use your modified script to send data to home assistant, can i publish it on github to help other users to have the data logged on HA?
View attachment 99588
@peppebytes as @sidepipe mentioned:
you can edit it to do what you want....
Do you have some code for Home Assistant yet? I'm starting to play with the Seplos BMS as well, and would be grateful if there's something pre-existing that can be collaborated on.
 
Hi @sidepipe i wrote a script that use your modified script to send data to home assistant, can i publish it on github to help other users to have the data logged on HA?
Sorry - the email telling me about this went to spam and only just noticed it! Yes, feel free to do with it as you want.
 
Hello,
I have problem with reading data over RS485 (connected to raspi).
TYPE E
model 1101-SP85
BMS 16S
protocol version 2.0
software version 16.4

./query_seplos.sh 4201
Sending "~20004642E00201FD36\r\n"
Error code 05

./query_seplos.sh 4F00
Sending "~2000464FE00200FD23\r\n"
Response: "~200046050000FDAF"


what is error 05?

I have another one seplos BMS (type C) and so it works correctly ...

is problem in different type of BMS? (C/E)
 
Last edited:
Back
Top