Hi,
Thank you for your reply
Your code didnt quite work but certainly pointed me in the right direction.
This code below works. Thought I would share this if any one else has want to do the same. As everyone probaly knows that the balance current is not much and only enables when charging.
I wanted to set a automation that when my battery system is in idle to enable auto balancing if the cells are out of balance. Im using node red exec node to run this python script.
import sys
import time
import serial
import struct
from binascii import unhexlify
import requests as req
import bluetooth
from bluetooth import *
import sys
#if sys.version < '3':
# input = raw_input
bd_addr = "AA:BB:CC:B1:23:45"
port = 1
#sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
#sock.connect((bd_addr, port))
#sock.close()
#time.sleep(1)
#Define RS485 serial port
ser = serial.Serial(
port='/dev/rfcomm2',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout = 1)
#while True :
test='A5A5FC0000FC'
try:
ser.write (test.decode('hex'))
except:
ser.close()
time.sleep(3)
s.close()
Thanks for your help
Cheers
Gareth