- Finding the right connection
-- Inside the BlueSmart IP22 charger
-- Capture of Data - Connecting to venus
-- Shematics of USB to TTL
-- Connected to venus
-- Manual Change Charge Current
-- Automatic Change Charge Current - Reading and Adapter
-- Adapter PCB
-- ESP Reader
If you open the case you find a 6 pin male header with 5 pin populated.
You can find the pinout here or in the Images folder Victron_BlueSmart_pinout.jpg
The used bluetooth controller is a Raytec MDBT40. You can find information about the module in the DataSheets folder.
The signal level is 3.3V and the baudrate is 19200.
After connecting a 3.3V TTL to USB converter to the RX/TX and GND pin i captured some data.
THe capture is in the Captures folder.
The Capture starts with a human readable header:
PID 0xA334
FWE 0342FF
SER# HQ2230XY6XR
V 28790
I 5100
T ---
ERR 0
CS 4
HC# 1105659
Checksum :A0920000022
and then there is much more data in hex format.
It looks like that it is the ve.direct protocol.
You can read the battery voltage (V 28790) and charging current (I 5100).
You have to divide the battery voltage and charging curent by 1000.
In this example my battery have 28.79V and is currentlt=y charged with 5.1A.
You have to use TTL to USB adapter for 3.3V TTL level.
If you use an isolated adapter you have to connect the 3.3V pin to the adapter, if not dont connect it.
if you connect the ttl to usb cable direct to a venus os device (i have on ehere running on a raspberry pi 4) the charger will show and you can see all information about it:
just wrote a little python script to change the charge current directly on the venus os raspberry:
name it charge_current.py
import sys
import serial
ser = serial.Serial("/dev/ttyUSB1", 19200)
chargeCurrent = int(sys.argv[1])
numP1 = (int)(chargeCurrent * 10)
numP2 = (0x70 - numP1) & 0xFF
hexP1 = "%X" % (numP1)
hexP2 = "%X" % (numP2)
# Write to serial port
msg = ':8F0ED00' + hexP1[0] + hexP1[1] + '00' + hexP2[0] + hexP2[1] + '\n'
print(msg)
ser.write(msg.encode())
you have to change the serial device for your setup.
just run it with:
python charge_current.py X
where X is the needed charging current in A
Thanks to sean56688 from victron community
This Script will read the Grid Power with modbus from your venus device.
When the read power is negativ (feeding to grid) it calculates the needed charge current to compensate and send it to your charger.
If you are not feeding to grid it will send a charging current of 0A.
The script will read the Grid Power and sent the charge current every 10 seconds. If you would like another interval change the sleep value in seconds in the last line of the script.
just create the file change_charge_current.py in /home/root
#!/usr/bin/python
import serial
import time
from pymodbus.constants import Defaults
from pymodbus.constants import Endian
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from pymodbus.payload import BinaryPayloadDecoder
ser = serial.Serial("/dev/ttyUSB1", 19200)
while(True):
current = 0.0
Defaults.Timeout = 5
Defaults.Retries = 5
client = ModbusClient('192.168.88.173', port=502, timeout=3, unit_id=100)
result = client.read_input_registers(822, 1)
if not result.isError():
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big)
power=decoder.decode_16bit_int()
if power < 0:
current = power / 24 * (-1)
print("Grid Power: {0:.0f}W".format(power))
print("Grid Current: {0:.2f}A".format(current))
numP1 = (int)(current * 10)
numP2 = (0x70 - numP1) & 0xFF
hexP1 = "%X" % (numP1)
hexP2 = "%X" % (numP2)
if len(hexP1) < 2:
hexP1 += "0"
msg = ':8F0ED00' + hexP1[0] + hexP1[1] + '00' + hexP2[0] + hexP2[1] + '\n'
print("VE.direct out: " + msg)
ser.write(msg.encode())
else:
print("Error:", result)
time.sleep(10)
You need to to adjust the line:
result = client.read_input_registers(822, 1)
---
to fit your system.
Here it a little list what to write for the value 822 in your setup:
L1 820
L2 821
L3 822
Now you need to run this script on startup of venus os.
Make the script executable:
chmod a+x change_charge_current.py
Add the script to crontab.
Executes this command:
crontab -e
Add this:
@reboot python /home/root/change_charge_current.py > /var/log/change_current.log
I have just created a little adapter pcb with a level shifter for RX and TX.
With this you can use a standard ve.direct cable:
All files needed are in the pcb folder.
in the ESP_BlueSmart_Reader folder is a Script for an ESP8266 thats reads voltage and current and publish them with mqtt.