Closed denicola2 closed 2 years ago
Hi there, to be completely honest, the settings are not easily available and a lot of it was done through brute-force testing. Most serial commands, however, are based off of an old word doc with communicating with Renogy's rover product from several years back.
I will try to find that document and will publish it once I do
Helium console code is as follows:
var error_messages = {
"16": "battery over-discharged",
"17": "battery over_voltage",
"18": "battery under-voltage warning",
"19": "load short circuit",
"20": "load overpowered or over-current",
"21": "controller overheating",
"22": "ambient temperature too high",
"23": "photovoltaic input overpower",
"24": "photovoltaic input side short circuit",
"25": "photovoltaic input side over-voltage",
"26": "solar panel counter-current",
"27": "solar panel over-voltage",
"28": "solar panel reversely connected",
"29": "anti-reverse MOS short",
"30": "circuit charge MOS short circuit",
}
function Decoder(bytes, port) {
/*
Decoded bytes are two-bit and represent the following:
bytes 0 and 1 -- Solar Panel Voltage
bytes 2 and 3 -- Solar Panel Current
bytes 4 and 5 -- Solar Panel Watts
bytes 6 and 7 -- Battery Voltage
bytes 8 and 9 -- Battery Current
bytes 10 and 11 -- Battery charge percent
bytes 12 and 13 -- Load Voltage
bytes 14 and 15 -- Load Current
bytes 16 and 17 -- Load Watts
bytes 18 and 19 -- Load Status (either 0 or 1 in second byte)
bytes 20 and 21 -- error messages in binary. Must convert to 1's and 0's corresponding to the renogy MODBUS lib.
byte 22 is the received downlink confirmation
bytes 23 to 32 are the lat/long, in the format: 23-26 lat, 27 polarity (0x00 positive, 0xFF negative), 28-31 long, 32 polarity.
*/
var decoded = {};
decoded.solar_voltage = hex_to_dec(bytes[0], bytes[1]) / 10.0;
decoded.solar_current = hex_to_dec(bytes[2], bytes[3]) / 100.0;
decoded.solar_power = hex_to_dec(bytes[4], bytes[5]);
decoded.batt_voltage = hex_to_dec(bytes[6], bytes[7]) / 10.0;
decoded.batt_current = hex_to_dec(bytes[8], bytes[9]) / 100.0;
decoded.batt_percent = hex_to_dec(bytes[10], bytes[11]);
decoded.load_voltage = hex_to_dec(bytes[12], bytes[13]) / 10.0;
decoded.load_current = hex_to_dec(bytes[14], bytes[15]) / 100.0;
decoded.load_power = hex_to_dec(bytes[16], bytes[17]);
//Reqires special processing. Within bytes[18], b7 represents the load, where 1 is on and 0 is off. b0-b6 represent the percent output from 00H to 64H.
//The second byte, bytes[19], represents the charging status from 00H to 06H
decoded.load_status = bytes[18] >> 7 & 1;
decoded.load_percent_output = bytes[18] & 01111111;
decoded.charge_status = bytes[19];
var decodedmsg = decode_error_msg(bytes[20], bytes[21])
decoded.error_msgs = decodedmsg.errors;
decoded.last_downlink_received = bytes[22];
decoded.RMS_battery_voltage= (bytes[24] << 8) | bytes[23];
//decoded.b3 = bytes[25];
//decoded.b4 = bytes[26];
//decoded.latitude = decode_coordinate(bytes, 23);
//decoded.longitude = decode_coordinate(bytes, 27);
return decoded;
}
function hex_to_dec(byte1, byte2) {
return ((byte1 << 8) + byte2);
}
function decode_coordinate(recvd_array, start_idx) {
var decoded_int = (recvd_array[start_idx+3] << 24) + (recvd_array[start_idx+2] << 16) + (recvd_array[start_idx+1] << 8) + recvd_array[start_idx];
return decoded_int ;
}
function decode_error_msg(highByte, lowByte) {
var errors = [];
var sixteen_bit_byte = ((highByte << 8) + lowByte);
for (var i = 15; i > -1; i--) {
var bitval = (sixteen_bit_byte >> i) & 00000001;
if (bitval == 1) {
var error = error_messages[(i + 16).toString()];
if (error != null) {
errors.push(error);
}
}
}
return {errors: errors};
}
Hi! This is incredible work and I'm in the process of integrating it to a larger RAK WisBlock based project. I am curious about where you found the settings commands documented. Also if you had written a decoder to be used in Helium console that you wouldn't mind sharing. Thank you!