Page 1 of 1

How to report negative values?

Posted: 22 Jun 2018 15:25
by ondrej_bajer
Hi guys,

I need to report the temperature in Celsius, that can be bellow zero, to the HC2.
I tried to define getter as word, int, signed int, but only positive values were shown in HC2. The values bellow zero were not transferred at all.
Also, I found this older thread on the similar topic, but I was not able to understand what's the solution: https://forum.z-wave.me/viewtopic.php?f ... =10#p65177

.....

UPDATE:
Ahhh, just got it. It looks like to define getter as a signed long helped:

Code: Select all

...
ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, SENSOR_MULTILEVEL_PRECISION_ONE_DECIMAL, getter8)
...
signed long getter8(){
    signed long getter_out;
    getter_out = atoi(CoolantTemperature); //converts char array to integer
    Serial.print("CoolantTemperature is: "); //debug
    Serial.print(getter_out);
    Serial.println;
    return getter_out;
    }

coolant.JPG
coolant.JPG (11.27 KiB) Viewed 2422 times
Not sure whether it's a right way, but it works at least. If any of you knows how to do it right, correct me please.

Thanks,
Ondrej

Re: How to report negative values?

Posted: 24 Jun 2018 09:07
by PoltoS
This is correct. You define FOUR_BYTES in your channel, means DWORD or long.

If you change to TWO_BYTES, singed into will be enough