1

I have a question regarding the LM35. The sensor is supposed to have values that are to be directly proportional. But instead of the temperature increasing, the sensor values decrease.

This is my setup below. It seems to be a standard setup in different LM35 tutorial pages.

LM35 Breadboard configuration

const int sensor= A0; // Assigning analog pin A0 to variable 'sensor'

void setup() {
  pinMode(sensor,INPUT); // Configuring sensor pin as input
  Serial.begin(9600);
}

void loop() {

  float reading=analogRead(sensor); //Reading the value from sensor
  float vout= (reading*5000)/1024;
  float temp= vout/10;
  
  Serial.print("in DegreeC= ");
  Serial.print(temp);
  Serial.println("");
  
  delay(500); //Delay of 1 second for ease of viewing 
  
}

These are the results. From room temperature, I applied heat through the use of a lighter and it went lower instead of higher.

Heat up results

I read somewhere that it has something to do with the power supplied by the Arduino. However, when I used a 12V supply to power the Arduino, the readings became very erratic and unstable.

UPDATE:

I have finally returned from the city (Took a long time because of Quarantine Restrictions) and I brought 3 LM35 from another shop. All 3 of the new LM35 worked as intended and didn't lower its temp reading when exposed to heat (With the same configuration). I could rule out these possibilities as to the reason why the LM35 didn't work.

1. Manufacturing Defect - all three of the LM35 didn't work as intended. They all had their temperature lowered when exposed to heat. There could be a defect in the manufacturing process because it doesn't work as advertised. (Leaning towards this)

2. Static Electricity - I remember receiving the LM35 in a plastic bag as packaged by the shop. It could have been affected by static electricity and damaged the circuit inside (on all three though?). The LM35s I received recently had been packaged in those electrostatic discharge protection packaging so it could have probably contributed to it? I need more insight on this I apologize for not being able to properly word it out.

There could be more but these are the most I could come up with as a conclusion.

3
  • 1
    Do not configure the analog pin as an digitial input pin. If you want to use it as an analog pin.you don't need any setup. An lm35 is like a complicated zener diode. Perhaps it help to put a resistor (say 10 kOhms) from Vout to GND to stabilize the output voltage of the LM35. Just two guesses. Dec 3 '20 at 10:26
  • @PeterPaulKiefer I added the 10kOhms however the temperature reading became 0 celsius. Changed the resistor to 1k Ohms, still 0 celsius reading. Changed to 100kOhms, still 0 celsius reading. I had also set my code and removed the pinMode however still the same output. The temperature always scales down when exposed to heat (even with my 3 other spare LM35 but they are from the same shop tho). I will go and buy a capacitor tomorrow to do more testing on the sensor. Dec 3 '20 at 13:25
  • If the GND with a 10k resistor leads to zero Volt, then the LM35 does not output any voltage. It might be broken. (All three are broken?; perhaps from a fake parts store ;-( ). There is a (really low) probabillity that the arduino analog ports are broken. If you have two simple resistors (>= 1000Ohms) you can put them in series, add VCC and GND each at an end and connect the middle (where the resistors are put together) to the analog port. If both resistors are the same value, it should result in about 512 +- 20. Dec 3 '20 at 14:12
1

You are reading A5 but in your diagram you show it hooked up to A0:

enter image description here

Change your code to this and I believe it will work:

const int sensor= A0; // Assigning analog pin A0 to variable 'sensor'

void setup() {
  pinMode(sensor,INPUT); // Configuring sensor pin as input
  Serial.begin(9600);
}

void loop() {

  float reading=analogRead(sensor); //Reading the value from sensor
  float vout= (reading*5000)/1024;
  float temp= vout/10;
  
  Serial.print("in DegreeC= ");
  Serial.print(temp);
  Serial.println("");
  
  delay(500); //Delay of 1 second for ease of viewing 
  
}

The data you are reading from A5 is indeterminate and just happens to decrease as A0 increases.

================================================================================ UPDATE:

Ok, so you corrected yourself and are reading the correct pin in spite of what your schematic shows. Please explain this:

float vout= (reading*5000)/1024;
float temp= vout/10;

I think you want:

float vout = (reading/1024.0) * 5000.0;
float temp = vout/10.0;

You are carelessly mixing floating point and integer math.

3
  • I'm so sorry I forgot to change the code to A0 but the output is still the same. Temperature goes down when exposed to heat :( Dec 3 '20 at 13:19
  • 1
    Do you have a voltmeter? Your next step is to determine what the voltage on pin 2 of the LM35 is doing when you apply heat. If it actually goes down then you probably have a bad LM35. If it goes up as it should, then you have an issue with your Arduino or the code.
    – jwh20
    Dec 3 '20 at 13:25
  • I will update once I go out tomorrow to get myself a multimeter. The thing is, I have 3 other spare LM35 and all of them have the same behavior. They are however from the same shop so I think I'll find another LM35 from a local shop tomorrow and compare. Dec 3 '20 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.