Journey with Confidence RV GPS App RV Trip Planner RV LIFE Campground Reviews RV Maintenance Take a Speed Test Free 7 Day Trial ×


Reply
 
Thread Tools Display Modes
 
Old 12-23-2019, 11:18 AM   #1
Bus Crazy
 
kazetsukai's Avatar
 
Join Date: May 2017
Location: Athens, TN
Posts: 1,574
Year: 1999
Coachwork: Amtran
Chassis: International RE
Engine: International T444e
Rated Cap: 76
Victron Owners: VEDirect Java Library

Hey folks,

I bought a VE.Direct USB cable a while back that I'm just now getting around to programming for. I'm trying to write a generalized Java library to allow for communication with these types of devices, wondering if anyone else out there can help test. I only have one type of Victron product (Smart Solar MPPT) so there are limits to what I can do.

I'm about to start fleshing out the README, feature requests are welcome.

https://github.com/kazetsukaimiko/victron-java


The VE.Direct protocol is silly simple, I think it is also read-only. This is what you get back, raw:

Code:
PID    0xA059
FW    146
SER#    HQ1748J433S
V    24480
I    0
VPV    37340
PPV    0
CS    5
MPPT    1
OR    0x00000000
ERR    0
LOAD    ON
Relay    OFF
H19    27969
H20    3
H21    22
H22    3
H23    22
HSDS    292
Currently I have a few fields working. I map the PID to a product name with a fairly elaborate enum mapping:
https://github.com/kazetsukaimiko/vi...onProduct.java
I also have a Math library embedded around Potential (Voltage), Current (Amperage), Power (Wattage), and Energy (Wattage/Time), which I modeled after Java 8+ java.time for unit conversion. Its still rough, but will hopefully be worth expanding as time goes on:
https://github.com/kazetsukaimiko/vi...java/kaze/math


Example of what is currently working:

Code:
VEDirectMessage{product=SMARTSOLAR_MPPT_150_100_REV2,  relayState=OFF, firmwareVersion='null', offReason=null,  resettableYield=279.69 kWh, yieldToday=0.03 kWh, maxPowerToday=22 W,  yieldYesterday=0.03 kWh, maxPowerYesterday=22 W}
This was all implemented according to Victron's own PDF on the matter, "VE.Direct-Protocol-3.27.pdf" available on their website.


The packets from the VEDirect device look like this, its a read-only protocol from what I can tell. To manage the devices I'll need to implement their equivalent HEX protocols, something I may do later if there's demand for it.

kazetsukai is offline   Reply With Quote
Old 12-23-2019, 03:16 PM   #2
Skoolie
 
Marceps's Avatar
 
Join Date: Aug 2016
Posts: 216
Year: 1999
Coachwork: Thomas
Chassis: Saf-T-Liner MVP ER
Engine: CAT 3126
Thanks for sharing your work. It's too bad Victron feels that vendor-locked smartphone apps are a higher priority than releasing a library, instead leaving such work to a lone skoolie, apparently--though it's nice that they at least published documentation of the protocol.
Marceps is offline   Reply With Quote
Old 12-23-2019, 03:19 PM   #3
Bus Crazy
 
kazetsukai's Avatar
 
Join Date: May 2017
Location: Athens, TN
Posts: 1,574
Year: 1999
Coachwork: Amtran
Chassis: International RE
Engine: International T444e
Rated Cap: 76
Quote:
Originally Posted by Marceps View Post
Thanks for sharing your work. It's too bad Victron feels that vendor-locked smartphone apps are a higher priority than releasing a library, instead leaving such work to a lone skoolie, apparently--though it's nice that they at least published documentation of the protocol.
I'm also puzzled why they do this as well. They themselves would benefit from a generalized library to do this kind of work.



I could pretty easily put a REST frontend on it if people are interested, like localhost:8080/victronDevices/ttyACM0/ to get one message from the device, etc. Or a command line interface. For now I'm going to focus on documentation a bit.
kazetsukai is offline   Reply With Quote
Old 12-25-2019, 10:54 AM   #4
Bus Crazy
 
kazetsukai's Avatar
 
Join Date: May 2017
Location: Athens, TN
Posts: 1,574
Year: 1999
Coachwork: Amtran
Chassis: International RE
Engine: International T444e
Rated Cap: 76
I built some pretty nice electrical unit conversion code into victron-java with 100% code coverage.

You can do things like:

Code:
// Scale
Power thousandWatts = Power.of(new BigDecimal("1000"), PowerUnit.WATTS); // 1000 W
// Specify unit
Power oneKilowatt = thousandWatts.scale(PowerUnit.KILOWATTS); // 1 kW
// Normalize to nearest functional unit
Power autoOneKilowatt = thousandWatts.normalize(); // 1 kW

// Compare
Power hundredWattsAsKilowatts = Power.of(new BigDecimal("100"), PowerUnit.KILOWATTS); // 0.1 kW

Power hundedWatts = hundredWattsAsKilowatts.normalize(); // 100 W

if (Objects.equals(hundredWatts, hundredWalls)) { // True
}
if (thousandWatts.greaterThan(hundredWatts)) { // True
}
if (thousandWatts.subtract(hundredWatts).greaterThan(hundredWatts)) { // True
}
There are equivalents for Power (Wattage), Energy (Watts over Time), Potential (Voltage) and Current (Amperage).


The result as JSON for reading my solar charge controller:
Click image for larger version

Name:	veDirectMessage.png
Views:	2
Size:	62.5 KB
ID:	40133
kazetsukai is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


» Featured Campgrounds

Reviews provided by

Powered by vBadvanced CMPS v3.2.3

All times are GMT -5. The time now is 12:22 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2024, vBulletin Solutions, Inc.