Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Temp sensor code question
PostPosted: Sat May 17, 2014 12:20 pm 

Joined: Mon Jan 13, 2014 7:51 pm
Posts: 7
Hey there,

Here's the Temp. sensor code from the library i just downloaded(17.5.2014):
Code:
   float eHealthClass::getTemperature(void)
   {   
      //Local variables
      float Temperature; //Corporal Temperature
      float Resistance;  //Resistance of sensor.
      float ganancia=5.0;
      float Vcc=3.3;
      float RefTension=3.0; // Voltage Reference of Wheatstone bridge.
      float Ra=4700.0; //Wheatstone bridge resistance.
      float Rc=4700.0; //Wheatstone bridge resistance.
      float Rb=821.0; //Wheatstone bridge resistance.
      int sensorValue = analogRead(A3);
      
      float voltage2=((float)sensorValue*Vcc)/1023; // binary to voltage conversion 

      // Wheatstone bridge output voltage.
      voltage2=voltage2/ganancia;
      // Resistance sensor calculate 
      float aux=(voltage2/RefTension)+Rb/(Rb+Ra);
      Resistance=Rc*aux/(1-aux);   
      if (Resistance >=1822.8) {
         // if temperature between 25ºC and 29.9ºC. R(tª)=6638.20457*(0.95768)^t
         Temperature=log(Resistance/6638.20457)/log(0.95768); 
      } else {
         if (Resistance >=1477.1){
               // if temperature between 30ºC and 34.9ºC. R(tª)=6403.49306*(0.95883)^t
               Temperature=log(Resistance/6403.49306)/log(0.95883); 
         } else {
            if (Resistance >=1204.8){
               // if temperature between 35ºC and 39.9ºC. R(tª)=6118.01620*(0.96008)^t
               Temperature=log(Resistance/6118.01620)/log(0.96008);
            }
            else{
               if (Resistance >=988.1){
                  // if temperature between 40ºC and 44.9ºC. R(tª)=5859.06368*(0.96112)^t
                  Temperature=log(Resistance/5859.06368)/log(0.96112);
               }
               else {
                  if (Resistance >=811.7){
                     // if temperature between 45ºC and 50ºC. R(tª)=5575.94572*(0.96218)^t
                     Temperature=log(Resistance/5575.94572)/log(0.96218);
                  }
               }
            }
         } 
      }
      
      return Temperature;
   }


The sensor works fine i believe and shows correct values of the temperature.
But for my project i need to understand the code.
So for example, what is the meaning of the line:
Code:
Temperature=log(Resistance/5575.94572)/log(0.96218);
?
What does the number 5575.94572 mean? Or 0.96218?

**Notice that the comments throughout the library are not clear enough.


Top
 Profile  
 
 Post subject: Re: Temp sensor code question
PostPosted: Wed May 21, 2014 8:37 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11323
Hello ilan kusaev,

We use this function to calibrate the sensor value. The temperature Sensor is a resistance sensor.

You can find this information in the datasheet of the sensor.

Regards.


Top
 Profile  
 
 Post subject: Re: Temp sensor code question
PostPosted: Wed Jul 09, 2014 7:12 pm 

Joined: Wed Jun 11, 2014 11:10 pm
Posts: 2
libelium-dev wrote:
Hello ilan kusaev,

We use this function to calibrate the sensor value. The temperature Sensor is a resistance sensor.

You can find this information in the datasheet of the sensor.

Regards.


Where can one access this datasheet?


Top
 Profile  
 
 Post subject: Re: Temp sensor code question
PostPosted: Thu Jul 10, 2014 7:23 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11323
Hello andrewbourhis,

You can find it searching on google "Model 405 Air Temperature Probe".

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.