question

matrixrat avatar image
matrixrat asked

Using VEDirectFramehandler on Teensy. Seeking programming help.

Sorting out an off-grid setup with 16 tired 12v 120Ah SLAs wired for 24v. Have 4 320 Ah LoFePo4 waiting in the wings.

Yesterday morning 10 Am, seeing 30 amps charge. Ambient temp 2 DegC. No way I'm gonna let lithiums see those numbers!

I know there are more elegant solutions but i see a much quicker solution.

Using VeDirectFrameHandler, Teensy is reading from a VE charger, displaying a graph. Have a DS18B20 to hook up to read Battery temp.

Goal: Teensy is watching temp and if too Low, turns charger off before sunrise.

Then some number crunching to figure when:-

Teensy switches on a load say 100 watts to warm up the batteries to a sensible number then turn load off and enable charger.

Now to the point of my question: VEDirectFramehandler has no support for sending messages.

Does anyone here have any code clues for assembling and calculating checksums for messages to be received by VEDirect devices?

Thanks in advance and more so if you are still reading.




arduino
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
custom avatar image
custom answered ·

Here's my sending function.

Example - Request for Register 0xEDF6 Battery float voltage

VEsendHex(":7F6ED00");

The checksum will be added automatically.

void VEsendHex(String input){
                  
    int str_len = input.length() + 1;
    char buffer[str_len];    
    input.toCharArray(buffer, str_len);
    uint8_t checksum = 0x55 - ascii2hex(buffer[1]);   
    for (int i = 2; i < (str_len - 1); i += 2)    
    {
                          
      checksum -= hex2byte(buffer + i);    
    }
    Serial1.print(input);    
    Serial1.println(VEByteToAscii(checksum));    
}

String VEByteToAscii(byte in)
{
    char outputBuffer[3];

    const char HEX_DIGITS[17] = "0123456789ABCDEF";

    byte upper_nibble_index = (in & 0xf0) >> 4;
    byte lower_nibble_index = in & 0xf;

    outputBuffer[0] = HEX_DIGITS[upper_nibble_index];
    outputBuffer[1] = HEX_DIGITS[lower_nibble_index];
    outputBuffer[2] = '\0';

    return outputBuffer;
}
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matrixrat avatar image
matrixrat answered ·

Thank you very much. Got some more DS18B20s so first some soldering then some code-diving.

In case anyone is interested, be careful choosing DS18B20s as there are many nasty counterfeits out there. Only use the real Dallas item and No, I do not work for them.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic