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.

temperature measurement with CC2530 smartrf05

Other Parts Discussed in Thread: CC2530

Hello I am new to zigbee, I need help explaining this code step by step and where do I put it in the GenericApp to measure temperature.

the code is:

TR0 |= 0x01;      // TR0 must be modified prior to ATEST,
ATEST |= 0x01; // otherwise P0_0 and P0_1 forced with 0
uint16 tempSample = HalAdcRead( HAL_ADC_CHN_TEMP, HAL_ADC_RESOLUTION_12 );
TR0 &= ~0x01;
ATEST &= ~0x01;

I am using the CC2530 smartrf05

  • Hi,

    Lets do it step by step:

    German David Useche said:
    TR0 |= 0x01;      // TR0 must be modified prior to ATEST,
    ATEST |= 0x01; // otherwise P0_0 and P0_1 forced with 0

    German David Useche said:
    TR0 &= ~0x01;
    ATEST &= ~0x01;

    Is part of a code that is not directly related to temperature measurement. It can be omitted in case

    you are not using P0_0 and/or P0_1 in your application.

    German David Useche said:
    uint16 tempSample = HalAdcRead( HAL_ADC_CHN_TEMP, HAL_ADC_RESOLUTION_12 );

    Once this line has been executed in the code, tempSample will hold a set of bits that are represent a

    temperature measured by internal temperature sensor.

    Refer to cc2530 datasheet "ANALOG TEMPERATURE SENSOR", to understand how this sample can

    be converted to human readable Celsius degrees value (including compensation of Voltage coefficient).

    If someone has a code for conversion of sampled value to Celcius degrees value and "one point calibration"

    for cc2530, I'll be glad to see it too (TI guys?). :)

  • I want to use internal temperature sensor in CC2530. But i didn't find it's range, whether it will sense below 0 degree. And it is recommended to use that sensor in real application.

  • Hi Hamza,

    You can refer to section 13.2 Using the Battery Monitor for Temperature Monitoring in swru191.

  • Hi Yikai,

            The link you mention is having the range -40 to 120. I need your suggestion, does this sensor gives accurate temperature?.  if yes, What is field of view.( I mean distance of sensing).

    Regards

    Hamza

  • Hi Hamza,

    The embedded temperature sensor is not accurate.

  • Hi Yikai, 

       I tried to read with below code, but temp value is giving ~5 which is either increasing nor decreasing. Is my code is correct.

    #include <stdio.h>
    #include <ioCC2530.h>
    #include "hal_types.h"

    static float temp = 0;

    void init_clock()
    {
    CLKCONCMD = (CLKCONCMD & ~(CLKCON_OSC | CLKCON_CLKSPD)) | CLKCON_CLKSPD_32M;
    while (CLKCONSTA & CLKCON_OSC);
    }

    void init_tempRegister()
    {
    ATEST = 0x01;
    TR0 |= 0x01;
    }

    void delay(int ta)
    {
    while(ta--);
    }

    void main()
    {
    init_clock();
    init_tempRegister();
    while(1)
    {
    int value = 0;

    ADCIF = 0;
    //ADCCON3 = (HAL_ADC_REF_125V | HAL_ADC_DEC_512 | HAL_ADC_CHN_TEMP);
    ADCCON3 = (0x00 | 0x30 | 0x0e);
    delay(2);
    while ( !ADCIF );
    value = ADCL;
    value |= ((uint16) ADCH) << 8;
    temp = ((((float)value) * 1150.0 / 2047.0 - 743.0) / 2.45);
    printf("Temp is %f", temp);
    delay(500);
    }
    }

     

  • Is any thing wrong in my code. I changed while ( !ADCIF )  to  while(!(ADCCON1 & 0x80));. Still i am getting wrong value. 

  • I am getting the value of  value as 1489, 1490 like wise. Is this correct value. If not how can i calibrate to get value in degree Celsius 

  • You can refer to the example at http://www.ti.com/litv/zip/swrc147c

  • The example you link is having the same code, which i have written. The value is same i am getting. But there is no proper calibration on that code also.

       1) How it is said to be 25 degree if value is 1480? how it is calculated

       2) Why in that code it is hard coded as 22 + value. As per data sheet. This sensor will give -40 to 120. Is this really giving this range. 

  • Hi

    >> 1) How it is said to be 25 degree if value is 1480? how it is calculated

    It is ADC reading.  Mentioned in the CC2530 datasheet

     >>  2) Why in that code it is hard coded as 22 + value. As per data sheet. This sensor will give -40 to 120. Is this really giving this range.

    Code assumes that calibration is done at 22 deg. It is mentioned in the code.

    Thanks,

    Saurabh

  • Hey all,

    I am using the CC2530-91 module.
    I used the same code from that example. All I have is 22ºC... all the time.!

    Is there anyone with the same symptoms? 

    BR,
    TG

  • TG,

    Did you check the sniffer trace to confirm if sensor was sending same temperature reading every time ? If yes, you might have to put breakpoints in your code and check if ADC is reporting the same value each time.

    Saurabh