Go Down

Topic: Project 3, negative temperatures also low temperatures (Read 1 time) previous topic - next topic

darthirule

I am getting very low temperature values. And also negative temperatures.

Quote
Sensor Value: 103Base Temp: 2.25 , Volts: 0.50, degrees C: 0.29
Sensor Value: 80Base Temp: 2.25 , Volts: 0.39, degrees C: -10.94
Sensor Value: 93Base Temp: 2.25 , Volts: 0.45, degrees C: -4.59
Sensor Value: 95Base Temp: 2.25 , Volts: 0.46, degrees C: -3.61
Sensor Value: 92Base Temp: 2.25 , Volts: 0.45, degrees C: -5.08
Sensor Value: 85Base Temp: 2.25 , Volts: 0.42, degrees C: -8.50
Sensor Value: 77Base Temp: 2.25 , Volts: 0.38, degrees C: -12.40
Sensor Value: 67Base Temp: 2.25 , Volts: 0.33, degrees C: -17.29
Sensor Value: 65Base Temp: 2.25 , Volts: 0.32, degrees C: -18.26
Sensor Value: 74Base Temp: 2.25 , Volts: 0.36, degrees C: -13.87
Sensor Value: 88Base Temp: 2.25 , Volts: 0.43, degrees C: -7.03
Sensor Value: 95Base Temp: 2.25 , Volts: 0.46, degrees C: -3.61
Sensor Value: 93Base Temp: 2.25 , Volts: 0.45, degrees C: -4.59
Sensor Value: 88Base Temp: 2.25 , Volts: 0.43, degrees C: -7.03
Sensor Value: 80Base Temp: 2.25 , Volts: 0.39, degrees C: -10.94
Sensor Value: 70Base Temp: 2.25 , Volts: 0.34, degrees C: -15.82
Code:

Code: [Select]

const int sensorPin = A0;
float baselineTemp;

void setup() {
  Serial.begin(9600);
 
  for(int pinNumber = 2; pinNumber < 5; pinNumber++)
  {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
 
  int sensorVal2 = analogRead(sensorPin);
  float voltage2 = (sensorVal2) * 5.0;
  float voltage3 = voltage2/1024.0;
  float initialTemperature = (voltage3 - .5) * 100;
  baselineTemp = initialTemperature;

}

void loop() {
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
  Serial.print("Base Temp: ");
  Serial.print(baselineTemp);
  float voltage = (sensorVal/1024.0) * 5.0;
 
  Serial.print(" , Volts: ");
  Serial.print(voltage);
 
  Serial.print(", degrees C: ");
  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(100);
}


I keep looking over the math and everything seems fine.

ahuss

the standard answer to this question is check you wires are all in correctly. check the pins for te tmp are connected to the right places.

the sensor can pick up negative temperatures so it would make sense.

also close the windows to get a stable room temp.

as for your code, you've decided to do your own way. thats fine but check if the supplied code works

darthirule

#2
Sep 11, 2015, 02:57 am Last Edit: Sep 11, 2015, 02:58 am by darthirule
I have figured it out.

I was not using the temperature sensor. The kit comes with 3 transistors that look extremely similar to the temp sensor. The transistor has its outer legs bent while the temp sensor has no bent legs. There is also only 1 temp sensor in the kit.

Go Up