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
  • I implemented this change in Eddystone example in SDK 15.2.0 with my nRF52-DK, and the temperature in the frame was decreased as expected.

    However I struggled to roll back the change - only recompiling es_tlm.c and re-linking it could have been the cause.

    I did a full erase of the nRF51822 and then full recompile and link, before coding the SoC.  Afterwards the change took effect and the temperature in the frame was as expected, 6.5 degrees below the die temperature.

    I will try to recreate the issue whereby it seems the change in es_tlm.c is not consistently included in the recompiled code.

    Regards

    Jacques

Reply
  • I implemented this change in Eddystone example in SDK 15.2.0 with my nRF52-DK, and the temperature in the frame was decreased as expected.

    However I struggled to roll back the change - only recompiling es_tlm.c and re-linking it could have been the cause.

    I did a full erase of the nRF51822 and then full recompile and link, before coding the SoC.  Afterwards the change took effect and the temperature in the frame was as expected, 6.5 degrees below the die temperature.

    I will try to recreate the issue whereby it seems the change in es_tlm.c is not consistently included in the recompiled code.

    Regards

    Jacques

Children
Related