LM35 sensor Shows wrong temperatures

I use this code

int lm35Pin = A0;
 
void setup()

{ 
  Serial.begin(9600);

  } 
void loop()

{ 
  int analogValue;
 float temperature;
  analogValue= analogRead(lm35Pin);
 temperature = float(analogValue)/1023.00;
 temperature = temperature*500.00;
 Serial.print("TEMP: ");
 Serial.print(temperature);
 Serial.println("C");
 delay(1000);
}

and this With the same results! Does not show the correct temperatures What is the problem?

float tempC;
int tempPin = A0; 

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

void loop()                            
{
  tempC = analogRead(tempPin);          
  tempC = (5.0 * tempC * 100.0)/1024.0; 
  Serial.print((byte)tempC);
  delay(1000);
}

look the serial

xenofon: I use this code

int lm35Pin = A0;

void setup()

{   Serial.begin(9600);

  } void loop()

{   int analogValue; float temperature;   analogValue= analogRead(lm35Pin); temperature = float(analogValue)/1023.00; temperature = temperature*500.00; Serial.print("TEMP: "); Serial.print(temperature); Serial.println("C"); delay(1000); }





and this With the same results! Does not show the correct temperatures What is the problem? 


float tempC; int tempPin = A0;

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

void loop()                            {   tempC = analogRead(tempPin);            tempC = (5.0 * tempC * 100.0)/1024.0;   Serial.print((byte)tempC);   delay(1000); }





look the serial

The first code mine too is not working......not getting the accurate results.......

Seems there are lots of FAKE LM35s from Chinese suppliers going around, try this anyway:

/*
 LM35 thermometer, no floats, no delays

  http://www.ti.com/lit/gpn/lm35
*/
const byte sampleBin = 8, // number of samples for smoothing
           aInPin = A0;
const int fudge = 170; // adjust for calibration 
const int kAref = 1090, // analog ref voltage * 1000
          kSampleBin = sampleBin * 1000,
          tEnd = 5000; // update time in mS
int tempC,
    tempF;
uint32_t total,  // sum of samples
         tStart; // timer start
void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL); // use 1.1V internal ref
  analogRead(aInPin);
  for(int i = 0;i < sampleBin;i++) // for smoothing, fill total
    total += analogRead(aInPin);   // with sampleBin * current
                                   // reading
}
void loop()
{
  if(millis() - tStart > tEnd)
  {
    tStart = millis(); // reset timer 
    total -= (total / sampleBin); // make room for new reading
    total += analogRead(aInPin); // add new reading
    tempC = total * kAref / (kSampleBin + fudge);
    tempF = (tempC * 18 + 3200) / 10;
    Serial.print(analogRead(aInPin));
    Serial.print("\t");
    Serial.print(total); // sum of samples
    Serial.print("\t");
    prntTemp(tempC);
    prntTemp(tempF);
    Serial.println();
  }
}
void prntTemp(int temp){
  Serial.print(temp / 10); // whole degrees
  Serial.print(".");
  Serial.print(temp % 10); // tenths
  Serial.print("\t");
}

edgemoron i use this codenot working correctly again.

I bought it from here

https://www.aliexpress.com/item/Free-Shipping-10PCS-LOT-LM35DZ-LM35D-TO-92-LM35-Precision-Centigrade-Temperature-Sensors-100-NEW-and/32713937810.html?spm=a2g0s.9042311.0.0.xU6M0Z

edgemoron.PNG

vishal_3: The first code mine too is not working......not getting the accurate results.......

You try the second?

xenofon: You try the second?

Both seems to be same....

xenofon: I use this code

int lm35Pin = A0;

void setup()

{  Serial.begin(9600);

 } void loop()

{  int analogValue; float temperature;  analogValue= analogRead(lm35Pin); temperature = float(analogValue)/1023.00; temperature = temperature*500.00; Serial.print("TEMP: "); Serial.print(temperature); Serial.println("C"); delay(1000); }





and this With the same results! Does not show the correct temperatures What is the problem? 


float tempC; int tempPin = A0;

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

void loop()                             {  tempC = analogRead(tempPin);            tempC = (5.0 * tempC * 100.0)/1024.0;  Serial.print((byte)tempC);  delay(1000); }





look the serial

I am facing difficulty like i am getting two fluctuating values with this type of code which may be can be kept constant by taking average or something but i am not sure whether the temperature it is showing is correct or not because i tried a different code suggested by someone else that is giving a different value...you can see my post below in the sensor section on LM35 not much older....

xenofon: You try the second?

xenofon: You try the second?

vishal_3: I am facing difficulty like i am getting two fluctuating values with this type of code which may be can be kept constant by taking average or something but i am not sure whether the temperature it is showing is correct or not because i tried a different code suggested by someone else that is giving a different value...you can see my post below in the sensor section on LM35 not much older....

the sensors that we have it is Fake that is the problem!! i just try one sensor that is have from my charger and it is work With both codes correctly! i open and i read the Small letters on the sensor that he is works it is writes (653J5 LM35 DZ) the sensor Who does not work writes (62AB LM35 DZ) Whoever reads the thread do not buy 62AB LM35 DZ it not working!

xenofon: the sensors that we have it is Fake that is the problem!! i just try one sensor that is have from my charger and it is work With both codes correctly! i open and i read the Small letters on the sensor that he is works it is writes (653J5 LM35 DZ) the sensor Who does not work writes (62AB LM35 DZ) Whoever reads the thread do not buy 62AB LM35 DZ it not working!

Get the temperature of your place by some other way(credible source) and then compare that with the reading of your new LM35 and old LM35 with this code then the authenticity will be tested.....

vishal_3: Get the temperature of your place by some other way(credible source) and then compare that with the reading of your new LM35 and old LM35 with this code then the authenticity will be tested.....

This is what I did before answering last message

xenofon: This is what I did before answering last message

I don't know what these letters written on LM35 refers to? I have a LM35 on which 620GG LM35 DZ is written???

vishal_3: I don't know what these letters written on LM35 refers to? I have a LM35 on which 620GG LM35 DZ is written???

I do not know what the letters mean.

DZ is the package code (TO92) - this is described in the datasheet.

The 620GG means week 20 of year 6 (could be 2016, 2006...), GG is the die run code.

I just googled "TI datecodes"

The central power supply is important to show Correct temperatures?