Citrin 1.3 Solar : Minus temperature on the collector gives a wrong result

50 views
Skip to first unread message

Richard Haslauer

unread,
Dec 31, 2023, 6:53:49 AM12/31/23
to RESOL VBus
Hello,
I use ESPHome to read the VBUs datas of a Citrin Solar 1.3. All works fine, but minus tempertures are wrong.!
I use the following formular to get the temperature :
lambda: return x[0] * 0.1f + x[1] * 25.6f;
If in this case the temperature is minus, so you get a diplay value about
65363 degrees.
When I use this formular, I get approximately the right value:
lambda: if (x[1] == 0xFF) {return (x[1] - x[0]) * -0.1f;} else {return x[0] * 0.1f + x[1] * 25.6f;}

Question: Is this the right formular?

Regards Richard Haslauer

Edwin van den Oetelaar

unread,
Jan 1, 2024, 6:05:47 AM1/1/24
to resol...@googlegroups.com
Hello  Richard,

I am just reading your code and it looks like you are trying to do a decode of 2 bytes yourself.
Looks like a Signed int from your example.

import struct
y = bytearray(2)
y[1] = 0xFF
y[0] = 0x10
def get_temp2(x):
t = struct.unpack('h',x)
return t[0] * 0.1
Read up on the 'struct' module of python, this works with positive and negative numbers without issue.

Best regards and a happy new year,
Edwin van den Oetelaar

--
You received this message because you are subscribed to the Google Groups "RESOL VBus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resol-vbus+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/resol-vbus/7b420dc0-0d38-435b-8db1-54b667686764n%40googlegroups.com.

Richard Haslauer

unread,
Jan 3, 2024, 3:47:24 AM1/3/24
to RESOL VBus
Hello Edwin,
your function works well. Do you have any idea, what it would look like in C or C++.

Thank you and also a happy new year!
Regards Richard Haslauer

Edwin van den Oetelaar

unread,
Jan 3, 2024, 8:16:39 AM1/3/24
to resol...@googlegroups.com
Sure here is the source code and how to compile this on a normal unix/linux system

// print the demo code to console

$ cat demo.c

#include <stdint.h>
#include <stdio.h>

// Union to aid in converting byte data to signed shorts
union {
    char bytes[2];
    int16_t value;
} shortUnion;

float get_temp2(char *x) {
    shortUnion.bytes[0] = x[0];
    shortUnion.bytes[1] = x[1];

    return shortUnion.value * 0.1f;
}

int main() {
    char bytes[] = {0x10, 0xFF}; // Example byte array
    printf("%f\n", get_temp2(bytes));

    return 0;
}

// compile the demo code
// creates 'a.out' executable
$ gcc demo.c 

// run the demo

$ ./a.out
-24.000000

// result seems fine


Richard Haslauer

unread,
Jan 3, 2024, 2:48:14 PM1/3/24
to RESOL VBus
Hello Edwin,
thank you very much for your help!

Regards Richard Haslauer
Reply all
Reply to author
Forward
0 new messages