diff options
-rw-r--r-- | trygvisio_soil_moisture.ino | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/trygvisio_soil_moisture.ino b/trygvisio_soil_moisture.ino index 8ecc907..4c9e0d7 100644 --- a/trygvisio_soil_moisture.ino +++ b/trygvisio_soil_moisture.ino @@ -208,15 +208,15 @@ static void aci_loop() { int32_t t = aci_evt->params.cmd_rsp.params.get_temperature.temperature_value; - // t is in 1/4 degrees celcius parts. + // t is number of 1/4 degrees celcius. // Multiply t by 25 without having to include float support t = t * 16 + t * 8 + t; - uint32_t exponent = ((uint32_t) 2) << 24; + uint8_t exponent = -2; // example. reading=111. real temperature = 111 / 4 = 27.75 dec C - // Calculation: t = 2775, exp = 2. formula: 10^exp * 0.t => 10^2 * 0.2775 = 27.75 + // Calculation: t = 111, formula: t*25 * 10^exp => 2775 * 10^-2 = 27.75 // The value of flags // bit 0: 0=Celcius, 1=Farenheight @@ -231,7 +231,7 @@ static void aci_loop() { // temperature type } temperature_measurement = { 0, - exponent | (t & 0x00FFFFFF) + ((uint32_t)exponent) << 24 | (t & 0x00FFFFFF) }; lib_aci_set_local_data(&aci_state, PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET, |