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
  • HNY to all!

    @awneil, thank you for the heads-up.

    @Bjorn, I am able to configure an offset in the code, but have not yet figured out why the offset does not seem to be consistently applied after a full make.  I will be updating a few more SoC's this week and will try to recreate the issue.  Maybe its related to caching inside Android nRF Connect app, as seemingly inferred in another post here.

    Regards
    Jacques

Children
Related