This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Configuring an offset for sd_temp_get() - how?

Good day

My nRF51822 uses the Eddystone example with SDK 12.3.0 in conjunction with S130.  When I configure TLM in slot 1, I notice that the temperature is about 6.5 degrees C higher than ambient.  Referring to e.g.

https://devzone.nordicsemi.com/f/nordic-q-a/5997/nrf51822-temp-internal-temperature-sensor-characteristic

I need to subtract 4 times the difference from the die temperature, i.e. 26.  However when I subtract 26 in:

D:\Nordic\nRF5_SDK_12.3.0\components\libraries\eddystone\es_tlm.c

it does not make a difference.  Even if I subtract 1000, the unadjusted temperature is carried in the TLM frame.  My code copied below.

Please assist to point out where I should code this offset?

Thank you

Regards

Jacques

static void update_temp(void)
{
int32_t temp; // variable to hold temp reading
(void)sd_temp_get(&temp); // get new temperature
temp = temp - 26; // ADDED OFFSET HERE
int16_t temp_new = (int16_t) temp; // convert from int32_t to int16_t
m_tlm.temp[0] = (uint8_t)((temp_new >> 2) & 0xFFUL); // Right-shift by two to remove decimal part
m_tlm.temp[1] = (uint8_t)((temp_new << 6) & 0xFFUL); // Left-shift 6 to get fractional part with 0.25 degrees C resolution
}

Parents Reply Children
Related