View Single Post
Old 01-01-15, 10:31 AM   #64
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

nkuck, I would suggest a static offset to correct things. Say your sensor reading is off by 10F, just add 10 to the Ssensor variable. With the current way you're doing it, it may read normal at the temperatures you're reading, but as you get farther from those temperatures your readings will get farther and farther off.

Here is what I would do:

Code:
// read sensor inputs, convert to degrees, and assign to variables
  Counter = 0;
  while(Counter < SensorReadings) {
    Ssensor += analogRead(SsensorPin) / 2;
    Tsensor += analogRead(TsensorPin) / 2;
    Counter++;
    digitalWrite(ledPin, HIGH);
    Delay(250);
    digitalWrite(ledPin, LOW);
    Delay(250);
  }


  // calculate average temp from sensor inputs
  Ssensor = Ssensor / SensorReadings;
  Tsensor = Tsensor / SensorReadings;

  // calibrate sensors
  Ssensor = Ssensor + 10;
  Tsensor = Tsensor + 13;

This is just an example. Replace the 10 and 13 with whatever the readings seem to be off by. This will create a linear offset that won't drift as the temperature varies.
__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline   Reply With Quote