# LM35 not showing expected temperature.

Hello,
I’ve been using a LM35 temperature sensor for a simple circuit but it seems to be showing a reading of 417 degrees. I’m pretty sure the formula is correct … temp = (500*analogRead(1))/1024 … the sensor is connected to the breadboard so the problem isn’t there. It will most likely be a simple answer as i am relatively new to the arduino, any help would be much appreciated!

is Pin 1 an analogue pin on your arduino?

yes it is, should of mentioned that

You sure you're on analog 1?- the first pin is 0.

Yeah I definitely am, its connected to A1.

Then perhaps it’s warmer than you think

And you have it powered from the 5v? Might be an idea to post a circuit diagram and even a photo of the setup.

Warm but not quite 417 degrees! yeah I have it connected to the 5V and to ground, cant figure out whats up with it. Here’s a few pictures of the breadboard, the LEDs can be ignored because they act according to the reading from the sensor.

MatthewScollay: Yeah I definitely am, its connected to A1.

Yes "A1" is an analog input but "1" is a shortcut for "D1" which is a digital input.

You have to write : analogRead(A1) ;

My working code is:

``````// read the temp
temp=(500 * rawVal) /1024;
``````

I found another LM35 and connected it up and its working well. Should of checked this before i posted but just presumed that it would work since it had never been used before! thanks for the help anyway.

Good for you but even there are many controls in arduino library and it works it is neither logical nor a good practice to write analogRead (5) instead of analogRead (A5)

``````int sensorPin = A0;
.................
void loop() {
// read the value from the sensor:
................
}
``````

68tjs: it is neither logical nor a good practice to write analogRead (5) instead of analogRead (A5)

That may be true, but it's not what you said earlier....

You have to write : analogRead(A1) ;

.... which is not true.

JimboZA:

68tjs: it is neither logical nor a good practice to write analogRead (5) instead of analogRead (A5).

That may be true, but it's not what you said earlier....

You have to write : analogRead(A1) ;

.... which is not true.

A little short as affirmation ! Could you explain why ?

I knew there were errors in the site arduino as 40 mA per outputs which are ABSOLUTE RATING : it is confirmed by reading the micro's datasheet. Atmel guaranteed permanent service only up to 20 mA But I never thought that writing analogRead(A1) ; as they do in their examples was a mistake. Unless you meant I would had to write int test; test =analogRead(A1) ;

But if this is the case it would be hair-splitting Especially when the claim is not accompanied by any comments.

Have a good day.

JimboZA:

68tjs: it is neither logical nor a good practice to write analogRead (5) instead of analogRead (A5)

That may be true, but it's not what you said earlier....

You have to write : analogRead(A1) ;

.... which is not true.

The 'controversy' is a shame because it it taught in a fashion that can easily lead to confusion; not taking that moment to differentiate the pin numbers and possibly lead to later issues. But, what was taught, works and that is ultimately what matters even though it may not be consistent with out own personal paradigm or preference. ;)

Be happy that the temperature cooled, we were all worried :)