[SOLVED] problem calculating with thermistor arduino starter kit

I've bought the arduino starter kit after wanting to work with hardware for a long time.
I've never before worked with sensors or such.

I have what I believe is a thermistor, BC547B Dropbox - 20130506_214212.jpg - Simplify your life.
I tried calculating the temperature with it, but failed.
It came with the arduino starter kit. In the book that came with the kit it says it is an TMP36, but I did not find this to be the case.

this is the best datasheet I could find http://alltransistors.com/pdfview.php?doc=bc546_bc547_bc548_bc549_bc550.pdf&dire=_fairchild_semi

my setup:


the code

const int sensorPin = A0;
float baselineTemp = 20.0;

//setup 3 LEDs
void setup(){
  Serial.begin(9600);
  for(int pinNumber =2;pinNumber<5;pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber,LOW);
  }
}
void loop(){
  //read the sensor A0 value
  //A0 is the output from the BC547B is connected
  int sensorVal = analogRead(sensorPin);
  Serial.print("sensor value: ");
  Serial.print(sensorVal);

  //calculate temperature
  //something must be wrong here
  float temperature = (sensorVal/1024.0)*215;
  Serial.print(", degrees C: ");
  Serial.println(temperature);

  //lights go on depending on temperature
  //no problem seems to be here
  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(1);
}

serial monitor output output http://arduino.cc/forum/index.php?action=post;board=1 - Pastebin.com

It's not the thermistor I have multiple and tried them al.
It's not the sensor pin I also tried multiple.

the letters on the thermistor say:
on the flat side

BC547
B
-C27

on the other side:
K4

I really appreciate all help,
thank you

A thermistor (temperature-sensitive resistor) is a two-terminal device. What you have there appears to be a BC547 NPN transistor.

A thermistor is not easy to read. It's not linear so you need the values that define the resistance curve. You can calculate those values if you get readings at three known temperatures.

If you want to measure temperature I recommend the DS18B20 (a OneWire device) or the TMP36 or LM35 which are three-terminal devices that output a voltage that varies linearly with temperature:

johnwasser:
A thermistor (temperature-sensitive resistor) is a two-terminal device. What you have there appears to be a BC547 NPN transistor.

A thermistor is not easy to read. It's not linear so you need the values that define the resistance curve. You can calculate those values if you get readings at three known temperatures.

If you want to measure temperature I recommend the DS18B20 (a OneWire device) or the TMP36 or LM35 which are three-terminal devices that output a voltage that varies linearly with temperature:

Overview | TMP36 Temperature Sensor | Adafruit Learning System

thanks for the clearing up. I did actually found a TMP36, so I will be using that.
just a question those BC547 transistors seem like a real pain. Is there any reason I would really want to use it or should I just forget about them?

I finally understand how those things work now!

thank you,

p.s people who found the same strange data as I (who on the internet seem to be a lot) you are using the wrong component. somewhere lose in your kit there is a TMP36 it looks like the BC547, but the legs are together!

saikia81:
Just a question. Those BC547 transistors seem like a real pain. Is there any reason I would really want to use it or should I just forget about them?

NPN transistors are very handy if you want to control something that requires more than 30 mA or more than 5V (or both). Typical uses are small DC motors, solenoids, or large collections of LEDs.