LM35 degrees always wrong

hi,

i connect a Lm35 to my arduino and use this code
but i always get the same nubers in my room is it 25C and its give me much more any help ?

Thnks !!

int analogPin = 0;
int readValue = 0;
float temperature = 0;
float temperatureF = 0;

void setup() {
 Serial.begin(9600);
}

void loop() {
 readValue = analogRead(analogPin);
 //Serial.println(readValue);
temperature = (readValue * 0.49);
 temperatureF = (temperature * 1.8) + 32;
 Serial.print("Temperature: ");
 Serial.print(temperature);
 Serial.print("C ");
 Serial.print(temperatureF);
 Serial.println("F");
 delay(1000);
}

The code can't explain the delta's
How did you connect the sensor? Can you post a drawing?

elganzomc91:
hi,

i connect a Lm35 to my arduino and use this code
but i always get the same nubers in my room is it 25C and its give me much more any help ?

Thnks !!

void loop() {
 readValue = analogRead(analogPin);
 //Serial.println(readValue);

float voltage = (float(readValue) *5.0)/1024.0;  //10bit adc with 5v scale
float tempC = voltage /0.010;      // LM35 outputs C*(0.010V/C) 

//temperature = (readValue * 0.49);
 temperatureF = (tempC * 1.8) + 32;
 Serial.print("Temperature: ");
 Serial.print(tempC);
 Serial.print("C ");
 Serial.print(temperatureF);
 Serial.println("F");
 delay(1000);
}

Try this code
Chuck

This code uses many samples and the internal reference voltage for higher accuracy.
LM35 connected to A1, +5volt, and ground.
Leo..

// LM35 temp sensor connected to A1
// ~2 to ~102 degrees C
//
float Aref = 1.063; // calibration, change this to the actual Aref voltage of ---YOUR--- Arduino
unsigned long total; // A/D output
float tempC; // Celcius
float tempF; // Fahrenheit
//
void setup() {
  analogReference(INTERNAL); // use the internal ~1.1volt reference, change (INTERNAL) to (INTERNAL1V1) for a Mega
  Serial.begin(115200); // ---set serial monitor to this value---
}
//
void loop() {
  analogRead(1); // one unused reading to clear old sh#t
  for (int x = 0; x < 100; x++) { // 100 readings for averaging
    total = total + analogRead(1); // add each value
  }
  // convert value to temp
  tempC = total * Aref / 1024; // value to temp conversion
  tempF = tempC * 1.8 + 32; // Celcius to Fahrenheit conversion
  // print to serial monitor
  Serial.print("The temperature is  ");
  Serial.print(tempC); // default two decimal places
  Serial.print(" Celcius  ");
  Serial.print(tempF, 1); // one decimal place
  Serial.println(" Fahrenheit");
  delay(1000); // slows readings
  total = 0; // reset value
}