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

A chaotic value returned from sd_temp_get() after bluetooth's connection?why would this happen?

Hi,

I want to read the temperature data from the sensor on-chip and send it to my phone by bluetooth. But as said above, after the connection between my nrf52832 module and my phone, the sd_temp_get() returned some very strange value, 

and before connection , it worked well. 

the LOG sequence was like this picture below:

if anyone have some advice?thanks

Parents Reply Children
  • Hi,

    You are declaring temp as a uninitialized pointer. So you have no control over where it points, and it is a typical issue that will lead to memory corruption. The correct would be to declare it as a normal variable, and refer to the address using &. So your temp_read() function should look something like this:

    int32_t temp_read()
    {
        uint32_t err_code;
        int32_t temp;
    
        err_code = sd_temp_get(&temp);
    
        NRF_LOG_INFO("the temp is: %d", temp);
    
        return temp;
    }

Related