diy solar

diy solar

Chargery BMS communications.

Craig

Watts are Watts!
Staff member
Moderator
Joined
Sep 20, 2019
Messages
2,924
Location
Hollister CA and off the grid in Idaho
As per request I am going to try and explain how I get the Chargery communications to send its data to my PC.

Right now I can read data from the Chargery. I have not played with sending data to it.

For me one of the biggest benefits of the unit is that It will display each cells individual voltage on its display as well as with serial communications.
I know there are many units out there that do have Bluetooth communications, but for me this is a non starter because I wish to see the data from my remote cabin and I will not have access to Bluetooth.

I do however think that there is a way to read the Chargery with a secondary Bluetooth module. I will pursue that at a later time.

Right now what I have is simply the each cells voltage being read by my PC via a python script. I figure getting the data is the first thing after that one can do what they wish with it.

Equipment
  • Chargery BMS 16T (this is what I have code can easily be modified for others)
  • serial cable
  • USR-TCP232-410S
  • ethernet cable
  • router/hub
  • PC
Setup
There is a red and black lead that connects to com port 3 of the Chargery base unit.
Connect the Red to pin 3 and the Black to pin 5 Ground. rs232-pinout.jpg

If your battery is between 5 and 36 volts hook the power from the USR-TCP232-410S to your battery if not there is an external power adapter provided.

Plug the Ethernet cable from the USRIOT device to your router or Ethernet hub.

Configuration.
if all goes well you should be able to go to http://192.168.0.7/ on yor browser and get a log in page.
username=admin
password = admin

usr.png


After you log in click "Web to Serial" and you should get a pop up saying "Connect Success"

Your USRIOT device should now be seeing streaming data!

this is a simple python script to read the data and output the data to a terminal. (I will make it output to a web browser later)

Code:
#!/usr/bin/env python3

import websocket
cells=12   #update for your configuration
    
def on_message(ws,message ):
    ma=[]
    high=0
    low=5
    for byte in bytearray(message):
        ma.append(byte)
    if ma[2]==86:
        #print(ma)
        total=0
        for x in range (4,cells*2+4,2):
            #print(bin(ma[x]),bin(ma[x+1]))
            a=bin(ma[x]).replace("0b", "")
            b=bin(ma[x+1]).replace("0b", "")
            #print(b,'len',len(b))
            while len(b) <8:
                b='0'+b
                
            cellV=int((a+b),2)/1000
            total+=cellV
            if cellV  >1:
                if cellV > high:
                    high=cellV
                if cellV < low:
                    low=cellV
            print ("Cell {:.0f}  {:.3f} V".format((x/2)-1,cellV))
        print ('High:{:.3f}V  Low:{:.3f}V Diff:{:.3f}'.format(high,low,(high-low)))
        print ('Total {:.2f}'.format(total))
    
    
        print()
            
 
def on_error(ws, error):
    print(error)

def on_close(ws):
    print("### closed ###")
    
    #wsconnect()
    
def on_open(ws):
    
    print ('Connected and subscribed')
  

if __name__ == "__main__":
    #websocket.enableTrace(True)
    def wsconnect():
        ws=None
        print('connecting')
        ws = websocket.WebSocketApp("ws://192.168.0.7:6432",
                                  on_message = on_message,
                                  on_error = on_error,
                                  on_close = on_close)
        ws.on_open = on_open
        ws.run_forever()
    wsconnect()

you will need to install Websocket client before running code.


fire up terminal and hopefully it works for you.

there is one line commented out #wsconnect() in the on_close function sometimes things go wrong and disconnect uncomment this if you want the connection persistent. But you need a Ctrl-Z to stop the program ctrl-C wont work.
 
I might have to play with this at another time. I need to focus on my build first and just getting the Chargery connected lol. Awesome work this could open up to many options down the road.
 
Hi All.

My name is Mario and I'm new to this forum.

Just as background, I have a Chargery BMS16T on my system and it works great. It took some working through with the manual but got there at the end. I had some trouble with the the unit energizing the Charge & Discharge contactors at the same time, but sorted that with some small interposing relays. I also had to play a lot with the settings of the BMS but got that sorted now.

My next thing is to get the data from the BMS onto my pc via a web browser or Excel VBA but have no clue how to do that. Hopefully someone can assist me on this. See some pics of my system.

Overview.jpgBMS16T.jpgContactors.jpgUSR-TC232-302.jpgBMS16T display.jpg
 
Last edited:
Hi All.

My name is Mario and I'm new to this forum.

Just as background, I have a Chargery BMS16T on my system and it works great. It took some working through with the manual but got there at the end. I had some trouble with the the unit energizing the Charge & Discharge contactors at the same time, but sorted that with some small interposing relays. I also had to play a lot with the settings of the BMS but got that sorted now.

My next thing is to get the data from the BMS onto my pc via a web browser or Excel VBA but have no clue how to do that. Hopefully someone can assist me on this. See some pics of my system.
Very NICE Setup, I'm impressed with how you have all of that very nice & tidy installation. Hoping you'll give us a breakdown of how you put the relay box and all the bits. Even the Box you used to house everything, I really like that for several reasons but I have to ask, how is the temps inside that box as those relays make heat and a fair bit of it too.

NEW RS232 data DOC HERE:
 
Hi Steve_S

I'll be happy to share more detail on what I have done, but I'll have to say, it took some trial and error to get things working. The main relays (C1 & C2) is not running hot at all (I got them from Aliexpress). I'm using a 60V-12V DC to DC buck converter and is set to exactly 12VDC. The main relays after being energized draws only about 80mA each and was pleasantly surprized by that. Energizing these relays probably takes quite a bit more, but with my interposing relays and 200W 12V power supply have no issues doing that. Before I made the interposing relay board, with the main relays directly connected to the BMS, it could not energize both, the BMS would go blank & cut out. It was fine driving 1 relay, but 2 was too much.
 

Attachments

  • BMS Connections.pdf
    52.9 KB · Views: 68
  • DC Bus & BMS Control.pdf
    64.7 KB · Views: 54
  • System Overview.pdf
    69.7 KB · Views: 59
  • Interposing Relay Board.pdf
    21 KB · Views: 53
If you guys are interested, here are some higher quality pictures below of my system and some screenshots of the settings of the Chargery BMS in pdf format.
 

Attachments

  • BMS Box.pdf
    1.2 MB · Views: 57
  • BMS Cell Voltage Screen.pdf
    2 MB · Views: 44
  • BMS Setup Screen 1.pdf
    2 MB · Views: 43
  • BMS Setup Screen 2.pdf
    2 MB · Views: 45
  • BMS Setup Screen 3.pdf
    1.7 MB · Views: 27
  • Interposing Relay Board - Colour.pdf
    978.7 KB · Views: 38
  • Main Relay Box - Bare Copper.pdf
    1.7 MB · Views: 54
  • Main Relay Box - Nickel Plated.pdf
    1.7 MB · Views: 38
  • System Overview.pdf
    2 MB · Views: 61
Yes I had my unit for 4 months before I got to messing with the com port.

Hi Craig.

I had my BMS up and running since February (2 months now) and pretty mush ironed out the settings for it. Being an electrician, the hardware side was no issue for me but I am a bit of a novice on the software side.

Not knowing where to start, I got myself a USR-TCP232-302 but am not sure it it will do the job for me now, I might have to get a USR-TCP232-410S. Can you please do a screenshot of your data you get on your PC from the setup you have done.
 
I started with a 410S and now have a 540 (4 port model) because "things just grew". Actually the 540 was the better choice, even came with the adapter dongles for RS232/RS485, while I had to source one for the 410S (pain in the …) These are nice devices.
 
Screenshot at 2020-04-11 15-22-15.png

Sorry just saw the updates to this thread. This is what I have so far. Beautiful setup by the way I will be reviewing your images for days. Please feel free to ask any and all questions.
 
View attachment 10765

Sorry just saw the updates to this thread. This is what I have so far. Beautiful setup by the way I will be reviewing your images for days. Please feel free to ask any and all questions.

Hi Graig.

Thanks for your reply and the screenshot. Also thanks for the suggestion of the N540, I do have other stuff that I can connect to the other ports also. As far as I can gather, the USR unit need to have websocket capability, else it won't work.

I also posted some higher quality images in PDF format of my setup, hope it can be of help to anyone.
 
Hi Graig.

Thanks for your reply and the screenshot. Also thanks for the suggestion of the N540, I do have other stuff that I can connect to the other ports also. As far as I can gather, the USR unit need to have websocket capability, else it won't work.

I also posted some higher quality images in PDF format of my setup, hope it can be of help to anyone.
There should be another way to make it work But I have not found it out yet. This communication stuff is new to me. I am learning as I go.
 
Hi Graig.

Thanks for your reply and the screenshot. Also thanks for the suggestion of the N540, I do have other stuff that I can connect to the other ports also. As far as I can gather, the USR unit need to have websocket capability, else it won't work.

I also posted some higher quality images in PDF format of my setup, hope it can be of help to anyone.

Thanks for the larger screenshot, looks perfect!

When I studied the USR units, I noticed that they have a "Httpd Client" mode and I imagined that I somehow could use the "Httpd Client" with the "GET" command directly via a web browser, but as yet don't know how to do that. Any thoughts on this method?
 
Thanks for the larger screenshot, looks perfect!

When I studied the USR units, I noticed that they have a "Httpd Client" mode and I imagined that I somehow could use the "Httpd Client" with the "GET" command directly via a web browser, but as yet don't know how to do that. Any thoughts on this method?
I will play with it that would be somewhat simpler than the websocket for sure.
 
Hi All.

I missed to share one drawing with you guys, the "Modified BMS Connections" drawing, showing the small 12VDC interposing relay circuit. Here it is:
 

Attachments

  • BMS Connections Mod.pdf
    55.7 KB · Views: 89
Hi All.

I missed to share one drawing with you guys, the "Modified BMS Connections" drawing, showing the small 12VDC interposing relay circuit. Here it is:
You couldn't have posted that a couple of days ago eh ! I would have taken that image and made a variation for the new Chargery BMS manuals I just finished up and sent to Jason @ Chargery. Although they got more drawings & examples too in all of them, so.
 
You couldn't have posted that a couple of days ago eh ! I would have taken that image and made a variation for the new Chargery BMS manuals I just finished up and sent to Jason @ Chargery. Although they got more drawings & examples too in all of them, so.
Yes his drawings are phenomenal wish I had that patience
 
Back
Top