# Excessively high temperature reading with LM35

I am really new to electronics and I am just experimenting at the moment with a breadboard.

My question here is related to the LM35 temperature sensor and Arduino micro controller. I am getting a very high reading through the sensor of 448 degrees Celsius. Obviously this is way off. The conversion formula I am using is:

inputvoltage = (5.0*inputvoltage*100.0)/1024.0;


I am feeding 5V into the sensor from the Arduino and I am getting a 0.50 voltage reading on my multimeter between 5V in and output. Do you think the sensor might be faulty? Any help on this issue would be great!

EDIT: Some people have asked for my code from the arduino so here it is:

int tempPin = 0;

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

void loop() {
float temp = (5.0 * analogRead(tempPin) * 100.0) / 1024;
Serial.print(temp,1);
Serial.println(" degrees C   ");
delay(1000);
}


This schematic shows the really simple configuration I have.

I have added a picture of my setup if anybody can spot something I can't.

• Sure, I have added it now :) – Lane George Sep 29 '14 at 21:37
• How about disconnecting the Vout from A0 and see what the voltage reading is from GND to Vout. How long are the wires? – Spehro Pefhany Sep 29 '14 at 21:46
• I am getting a reading 4.15V +- 1 from GND to Vout after it is disconnected. The wires are about 6 inches long. – Lane George Sep 29 '14 at 21:53
• Can you post the program (sketch) you're using? – Ricardo Sep 29 '14 at 22:00
• Can you also tell us what's the variable inputvoltage before and after it gets its value assigned in the line you posted? – Ricardo Sep 29 '14 at 22:04

## 6 Answers

4.15V from Vout to GND with short wires and 5V supply is totally wrong. Either you have the connections wrong or the LM35 is toast. Please double-check the connection vs. the datasheet.

I suspect just because of that particular voltage reading that you may have the connections mixed up.

Edit: Thanks for the photo. Looking at the part from the front (the part with the markings) from left to right, the pin order is:

Vs, Vout, GND = +5, Vout, GND

In your photo I see +5, Vout, GND as it should be. So it it's reading more than 10mV/°C at Vout with the blue wire disconnected from the Arduino (and 5V/0V on the orange and black wires respectively) I would say it's dead. Perhaps the power got momentarily reversed on it?

• I am pretty sure there in nothing wrong with the connections so I have come to the conclusion that there is something wrong with the sensor. I have included a photo of my setup in my post if you can spot anything that I can't. – Lane George Sep 30 '14 at 18:55
• Yep, I'm getting a reading if 80mV so I assume its dead. I have ordered a new one so I'll try again with that and report back if there are any problems. Thank's again for your help! – Lane George Sep 30 '14 at 19:33
• 80mV? What happened to your 4.15V reading? Sure it isn't an LM34? – Spehro Pefhany Sep 30 '14 at 20:07
• Woops, I apologise there... 80mV from Vs to Vout 4.15V Vout to GND. It's definitely a LM35. – Lane George Sep 30 '14 at 21:48

You say you "measure 0.5V between 5V input and the output". If you mean it exactly as you say it: There's something wrong with your sensor or your setup, because then the output is 4.5V from ground, which is 450degrees Centigrade, which would indeed mean the sensor is very close to smoking, regardless of the fact it doesn't work at all any more at that point.

If you mean you are measuring 0.5V at the output relative to ground, that would be about 50 degrees Centigrade, which is possible if you've been soldering recently or have intentionally heated it up.

Then we come to the math: This seems acceptable to me, assuming Arduino measures in 10bit accuracy mode. I think that's safe to assume. I am not knowledgeable about Arduino, but the Atmels inside do support 8bit and 10bit mode. As to 16bit int and/or float issues I defer to someone who knows more about the Arduino standards.

It is programatically/semantically advisable to not use "inputvoltage" to store the result, as it is not the inputvoltage. This will cause confusion if you start building this test out into something more serious and eventually forget to change it, because it now suddenly is fully integrated into all of your coding.

• I was indeed referring to the measurement between 5V and output. I've double and triple checked my connections and also tried them out using a variable resistor from which I got the exact reading I wanted. I am only reading room temp with the sensor so I have come to the conclusion that it must be faulty. Thank you for the tips on variable names, I will bare that in mind from now on. – Lane George Sep 30 '14 at 18:48
• @LaneGeorge You're welcome. I hope you take it as the friendly advice it was intended to be, we all take the short path in our initial steps into the world of programming, but learning early about the risks can help you hours of confusion in a later project. – Asmyldof Sep 30 '14 at 21:53

Without the code you're using, it's difficult to tell, but I would hazard a guess that you may be using a voltage reference of 1.1V (INTERNAL) instead of 5V. That's the case if you have the following line in your code somewhere before you take the temperature value:

analogReference(INTERNAL);


Can you verify if that's the case? If it is, then the correct code for extracting the temperature from your sensor is this:

temp = (1.1 * analogRead(tempPin) * 100.0) / 1024;


That difference would bring your temperature reading to about 98°C, which is better but still a bit high (if you are not measuring temp in a pot of boiling water).

If you are not using the INTERNAL analog reference of 1.1V, I suggest you do it. Add the analogReference(INTERNAL); line to your code (inside the setup() function) and use the temp calculation I give above and check again if the temp reading gets better. That will usually give you the best resolution for temperature reading with LM35 and the ATmega328 (most common Arduino microcontroller) in the 0 to 100°C range.

There's more info here: Arduino Playground - LM35 with higher resolution.

• As you can see from the code I just added, I wanted to keep it really basic initially just to try and get a reading I was happy with. Thank you for the tips there, I will bare that in mind in the future, however using the internal analog reference of 1.1v at this point is still giving me an absurdly high reading. The link was an interesting read. – Lane George Sep 30 '14 at 19:05
• No problem. Checked your picture and your connections seem fine. The program seems ok, too. Maybe your sensor is toast. I'll give your program a go tonight on my Arduino/LM35 to see if there's anything else wrong. I'll check the float assignment and the print lines and will report back here. – Ricardo Sep 30 '14 at 19:20
• Gave it a try on your program and it reports 30.8°C here (which is the correct ambient temperature). – Ricardo Sep 30 '14 at 21:04
• Cheers for checking. I've ordered a new sensor so I'll that that a try when it arrives. – Lane George Sep 30 '14 at 21:35

I had the same issue (in my case the reading was 446 degrees).

I solved it by switching the wires connecting to power and to ground.

It's a cold case, but I had a similar issue just now. I solved it by grounding the temp sensor through one of the ground pins next to the 5V out on my arduino, instead of using the gnd pin next to pin13.

Unsure why that worked, but it did. I have a stepper motor and some other components running off the same board.

Vs and GND are reversed, the diagram states Bottom View so you must flip the Vs and GND when looking from the top of the LM35. I made same mistake, and I think mine is dead now.

• The connection doesn't look inverted to me. Black is GND, orange is Vs. – Dmitry Grigoryev Oct 17 '16 at 10:04