Hi ,
  I  got the formula to convert the hex data to Battery & Light ....unable to get temperature i tried the below formula with a sample data but it doesnt work....:
I would really appreciate is someone could  take time to  look at it ...and help me out......Thank you...!!!
 
nandy
 
 
uint16_t xconvert_thermistor_resistance(uint16_t thermistor)
{
    float    adc  = (float)thermistor;
    uint16_t Rthr = 10000 * (1023-adc) / adc;
    return   Rthr;
}
/**
 * Converts thermistor reading from raw ADC data to engineering units.
 *
 * @author    Martin Turon
 *
 * @return    Temperature reading from thermistor as a float in degrees Celcius
 *
 * @version   2004/3/22       mturon      Initial revision
 * @version   2004/4/19       husq     
 *
 */
float xconvert_thermistor_temperature(uint16_t thermistor)
{
    float temperature, a, b, c, Rthr;
    a  = 0.001307050;
    b  = 0.000214381;
    c  = 0.000000093;
    Rthr = xconvert_thermistor_resistance(thermistor);
    temperature = 1 / (a + b * log(Rthr) + c * pow(log(Rthr),3));
    temperature -= 273.15;   // Convert from Kelvin to Celcius
    //printf("debug: a=%f b=%f c=%f Rt=%f temp=%f\n",a,b,c,Rt,temperature);
    return temperature;
}
 
 
 
Sample Data:
 
7e42ffff007d5d1d84010100b0010d028a03f301e3014d014d01c8000000000000000000003967 [
39]
mts310 id=0001 vref= 01b0 thrm=020d light=038a mic=01f3
       accelX=01e3 accelY=014d magX=014d magY=00c8
MTS310 [sensor data converted to engineering units]:
   health:     node id=1 parent=0
   battery:  = 2898 mv
   temperature=26.10 degC
   light: = 2566 ADC mv
   mic: = 499 ADC counts
   AccelX: = 660.000000 milliG, AccelY: = -2340.000000 milliG
   MagX: = 44.97 mgauss, MagY: =27.01 mgauss
 


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to