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
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.
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
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)
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.
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
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.
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
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.