Arduino temperature sensor

Hey,

I keep getting an error with my temperature sensor. The sensor returns wrong values, temperatures above 100°C, and I have no idea why. Can you help me? My code:

    int sensorPin = 0; //using analog pin 3
                           
     

    void setup()
    {
      Serial.begin(9600);  
                          
    }
     
    void loop()                    
    {
     //getting the voltage reading from the temperature sensor
     int reading = analogRead(sensorPin);  
     
     // converting that reading to voltage
     float voltage = reading * 3.3;
     voltage /= 1024.0; 
     
     // print out the voltage
     Serial.print(voltage); Serial.println(" volts");
     
     // now print out the temperature
     float temperatureC = (voltage - 0.5) * 100 ;  

     Serial.print(temperatureC); Serial.println(" degrees C");

     
     delay(1000);                              
    }

I'm looking forward for your replies,

PowerMG

int sensorPin = 0; //using analog pin 3

Which pin have you got the sensor attached to ?

UKHeliBob:

int sensorPin = 0; //using analog pin 3

Which pin have you got the sensor attached to ?

To the analog pin 3.

This is preferred:

const int sensorPin = A3;

ArduinoNop:

int sensorPin = 0; //using analog pin 3

To the analog pin 3.

That's not what your program thinks !

...R

If the sensor is attached to A3 why are you reading A0 ?