LM35 gives very high values in room temperature, and decreases when we exposed i

So we bought five LM35DZ, in the previous days, when we use the mutlimeter to measure the voltage betewen Vout and GND, the results were correct and logic, and when we exposed LM35 to a heat source, the voltage increased, But the problem was with arduino, the results wer unstable and ilogical! We checked internet, and We found some possible reasons!

  • Sharing the GND was one of them, but we only use the LM35, so we don't share the GND with any other device!
  • Another possible reason is due to the unstable source, because we're feedig the arduino from the USB and this can lead to wrong results, because of the ADC converter, there are some ways to eliminate such problem, we chose to read the 3.3volt pin of arduino and use it as a reference!
unsigned int temp = 0;

unsigned long temptot = 0;
    
    unsigned int REFtemp = 0;
    unsigned long REFtemptot = 0;
    
    int x;
    
    int REFSensor=  A1,
        LMSensor=A0;
    
    void setup() {
        pinMode(REFSensor,INPUT);
        pinMode(LMSensor,INPUT);
        Serial.begin(9600);
      
     
    
    }
    
    void loop() {
         temptot = 0;
         REFtemptot = 0;
    
         for(x = 0; x < 64; x++) { analogRead(REFSensor);}
         
         
         for(x = 0; x < 64; x++) {REFtemptot += analogRead(REFSensor);}
         
         for(x = 0; x < 64; x++) {analogRead(LMSensor);}
    
         
        
         for(x = 0; x < 64; x++) {temptot += analogRead(LMSensor);}
         temp = temptot >> 6;   
         REFtemp = REFtemptot >> 6;  
         float y= (float(REFtemp)*3.3)/676.; 
         Serial.print("Vcc: " ); Serial.print(y*1023./676.); Serial.print("v  "); 
         Serial.print("REF: " ); Serial.print(y); Serial.print("v  "); 
         float volt= (float(temp)*3.3)/float(REFtemp);
        // Serial.print("V.LM: " ); Serial.print(volt*1000.);  Serial.print("mv   ");
         Serial.print("T.LM: " ); Serial.print(volt*100);   Serial.println("C " ); 
          
    }
  • Another problem is the noise and many propse to add a 100nF capasitor between Vcc and GND, we don't have 100nF
    so we used 10nF;
  • Also to smoth the results we add another capacitor (1pF to 10pF) between Vout and arduino pin( A0 in our case)!

So today and after making all these changes, what happen is that the results were stabl but ilogical; in room temprature we read 10C to 12C! and when we removed one or both capacitors the results go crazy (between 100C to 10C!) and the most stange event is that when we expose the LM35 to heat, the temprature decreeases

We checked the LM35 using the multimeter and here the surprise! the voltage between Vout and GND was between 1000mv to 3000mv! and when we expose the LM35 to heat it decreases to 200mv, I'm saying it is a surprise because all the five LM35 start acting in the same way! is it possible that we burn all of them at once? if this is the case! so how and when this happened! I remember we switched between the Vcc and GND of one of the LM35 which can cause damage, but as I said just one! not all of them!
So anyone can help! we decided to buy another LM35 and check it! who knows!

Post a complete wiring diagram of your setup!

Another possible reason is due to the unstable source, because we're feedig the arduino from the USB and this can lead to wrong results, because of the ADC converter, there are some ways to eliminate such problem, we chose to read the 3.3volt pin of arduino and use it as a reference!

Does that mean you connected A1 to 3V3?

Some info here may help: Reading LM34, LM35, LM335 (LM3x) Temperature Sensors Accurately – Arduino++

Try this test sketch with your LM35s (one at a time), do not connect anything to the VREF pin. You can adjust the "calValue" variable to correct. Connect pin 1 of LM35 to +5 or +3.3V, pin 2 to A0 and pin 3 to GND, nothing else until you test.

/*
 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 calValue = 0; // adjust for calibration 
const int kAref = 1100, // analog ref voltage * 1000
                        // measured with accurate DMM
          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 + calValue;
    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");
}