This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: How to read a temperature value from integrated temperature sensor in CC2640R2F

Part Number: CC2640R2F


Hi,

Iam using CC2640R2FRSM package , which is 4x4. I want to read the value of temperature from sensor. I read some forums and i got one API AONBatMonTemperatureGetDegC().  Im just calling this api and printing return value of it. But iam getting a garbage value. Kindly let me know , do i need to do any configuration before using this api???

Iam using like this

void temp_sensor(void)
{
int32_t curtemp;

curtemp = AONBatMonTemperatureGetDegC();
UART_write(uart, "\n\rThe temparature is ", 34);
temp_int_to_string(curtemp); /*convert to string and printing */
}

 

  • You need to enable the battery monitor before you use it:

    AONBatMonEnable();
  • Thanks ,
    I can able to read positive values.. But i kept my room temperature as -20 deg cel. Below 0 deg im unable to read temperature sensor values.. it is giving like " /' ". Iam using UART_write() to print it in console.. Can u pls tell me what might be the reason.
  • I have tested batmon with the code below, and I have no problems measuring negative temperatures:

    AONBatMonEnable();
    
    while(1)
    {
        while(!AONBatMonNewTempMeasureReady());
        int32_t temp = AONBatMonTemperatureGetDegC();
    }

    Can you test the above and monitor temp using the debugger? Then you should see negative numbers when the temp goes below 0.

    I do not have any details of you temp_int_to_string function , but I think you need to go through it and see that it is not something wrong in your conversion of negative numbers.

    BR

    Siri