Go Down

Topic: Project 3 - TMP36 Good ambient reading, but inverse reading while applying heat! (Read 2334 times) previous topic - next topic

jgcragno

Hi, I'm new to Arduino and wanted to see if anybody could help me see where the problem might be.
So something really strange happens while doing the project, everything seems to work fine (the readings of the sensor match my real ambient temperature )  but while applying body heat, touching the sensor or even heating with lighter temperatures go down instead of up, any ideas on why this might happen?
I have already redone the circuit a couple of times but no change.

Code: [Select]
const int sensorPin = A0;
const float baselineTemp = 20.0;

void setup() {

Serial.begin(9600); //open serial port

for(int pinNumber = 2; pinNumber<5; pinNumber ++) {
  pinMode(pinNumber, OUTPUT);
  digitalWrite(pinNumber, LOW);
  }
}

void loop() {

int sensorVal = analogRead(sensorPin);

Serial.print("Sensor Value: ");
Serial.print(sensorVal);
// Convert the ADC reading voltage
float voltage = (sensorVal/1024.0) * 5.0;

Serial.print(", Volts: ");
Serial.print(voltage);
Serial.print(", Degrees: ");
// Convert voltage to degrees
float temperature = (voltage - 0.5) * 100;

Serial.println(temperature);

if (temperature < baselineTemp)
  {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }
 
  else if (temperature >= baselineTemp + 2 && temperature < baselineTemp + 4)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }
 
  else if (temperature >= baselineTemp + 4 && temperature < baselineTemp + 6)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  }
 
  else if (temperature > baselineTemp + 6)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
 
  delay(10);
 
}


Ambient Temperature:
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 148, Volts: 0.72, Degrees: 22.27
Sensor Value: 146, Volts: 0.71, Degrees: 21.29
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 147, Volts: 0.72, Degrees: 21.78
Sensor Value: 148, Volts: 0.72, Degrees: 22.27

Temperature Readings while applying body heat:
Sensor Value: 136, Volts: 0.66, Degrees: 16.41
Sensor Value: 136, Volts: 0.66, Degrees: 16.41
Sensor Value: 136, Volts: 0.66, Degrees: 16.41
Sensor Value: 137, Volts: 0.67, Degrees: 16.89
Sensor Value: 138, Volts: 0.67, Degrees: 17.38
Sensor Value: 136, Volts: 0.66, Degrees: 16.41
Sensor Value: 135, Volts: 0.66, Degrees: 15.92
Sensor Value: 134, Volts: 0.65, Degrees: 15.43
Sensor Value: 135, Volts: 0.66, Degrees: 15.92
Sensor Value: 135, Volts: 0.66, Degrees: 15.92

johnwasser

Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up