Go Down

Topic: Arduino + LM35 (Read 7857 times) previous topic - next topic

Wouterk

Nov 03, 2009, 03:45 pm Last Edit: Nov 03, 2009, 03:46 pm by Wouterk Reason: 1
Hello,

I'm just a starter so excuse me for lame questions/mistakes  ;)

I'm trying to interface a LM35 Temperature Sensor (datasheet: [link]http://www.libelium.com/squidbee/upload/b/bd/Temperatura-LM35.pdf [/link])
I'm using the T0-92 plastic package version.

When I connect the sensor's +Vs and GND pin to arduino's 5V and GND pin the arduino seems to short-circuit (the power LED goes from bright to almost out)
When I switch the +5v and GND pins this behaviour doesn't occure.

But if i use it like this and connect the Vout pin of the sensor too an analog input of the arduino, I get an adc value of 146.
according to the datasheet the sensor's output is 10mV for every degrees. So this would be 71.7 °C (if an adc value of 0 is 0 °C..), which is a bit high for temperature  :P

This value does change if the temperature changes though...

So to summarize:

My two questions are:
1 - did I connect the sensor wright in the first place?
2 - If i did connect it wright, is my conversion from adc too °C correct?

Thanks in advance,

An arduino beginner :)



Grumpy_Mike

#1
Nov 03, 2009, 03:55 pm Last Edit: Nov 03, 2009, 03:59 pm by Grumpy_Mike Reason: 1
Quote
But if i use it like this

Not sure what 'this' is. You need a connection between +5V, ground and the arduino input. It sounds like you connected them wrong at first. This could explain why it is not working right.

have you seen this:- http://pscmpf.blogspot.com/2008/12/arduino-lm35-sensor.html

Wouterk

Quote
Quote:
But if i use it like this

Not sure what 'this' is. You need a connection between +5V, ground and the arduino input. It sounds like you connected them wrong at first. This could explain why it is not working right.


if i use it like this the arduino doesn't short circuit:

Sensor -- Arduino
+Vs -- GND
GND -- 5V

I know it's far from logical but if I switch those two it short circuits  :-?

Grumpy_Mike

Quote

Sensor -- Arduino
+Vs -- GND
GND -- 5V

No that's not right. Are you sure you are identifying the pins correctly?

Wouterk

Quote
Quote:
No that's not right. Are you sure you are identifying the pins correctly?.


Well I'm 99% sure, I hope this picture makes it clearer (excuse me for bad photo quality)


PaulS

Looks to me like you've got +5 and Gnd swapped. The photo says top view and the drawing says bottom view.
The art of getting good answers lies in asking good questions.

Wouterk

Oh jeez how stupid is that *hits head with hammer*  :P

Can I blame the time (end of the day) for that? :P

Anyway, I just tried a brand new LM35, still gives me the same ADC values so can anyone help me on my way a bit with the conversion?

sylvie369

You're something like the 4th person I've seen in the last week who made that mistake. I would have made it myself, except that I'm used to reading datasheets for TO-92 parts. The side view is always (as far as I know) an illustration of the pins when you look straight at the flat side of the casing.

Grumpy_Mike

Try using:-

temperature = (5.0 * val * 100.0)/1024.0;

Where val is what you read and temperature is a float.

retrolefty

#9
Nov 03, 2009, 08:13 pm Last Edit: Nov 03, 2009, 08:14 pm by retrolefty Reason: 1
That wiring mistake is not unlike a frequent one made by some when using 79XX TO-220 voltage regulators, the pin out is different then with 78XX positive voltage regulators in the same package style. People sometimes quickly look at a positive regulator data sheet and assume the negitive regulators are wired the same.

The devil is always in the details.  ;)

Lefty

Wouterk

Quote
Try using:-

temperature = (5.0 * val * 100.0)/1024.0;

Where val is what you read and temperature is a float.


I tried that, it still gives me way to high temperatures (±70 °C at room temperature)   :(

Wouterk

I've connect the LM35 like this to my arduino:



And i use this code to convert the ADC value to °C

Code: [Select]
temperature = ( 5.0 * analogRead(0) * 100.0) / 1024.0;

I've checked the output voltage of the sensor by hooking up a voltage meter between the gnd and the Vout of the LM35, wich gave me 0,73 Volts, wich would be 73 °C... :-?
Also checked the supply voltage (between +Vs and GND) wich was 5,03V.

this is a brand new LM35, and all the previously tested LM35 gave the same results, could someone please point out the my what it is that i'm doing wrong?

mem

If the actual temperature is around 22 degrees Celsius then perhaps you have an LM34 which is calibrated in Fahrenheit

Wouterk

#13
Nov 04, 2009, 10:42 am Last Edit: Nov 04, 2009, 10:50 am by Wouterk Reason: 1
Hmm ofcourse that would explain it!

Is there any way to check that? there is no text on the casing

edit: typo

mem

#14
Nov 04, 2009, 11:30 am Last Edit: Nov 04, 2009, 11:30 am by mem Reason: 1
Quote
Is there any way to check that?

Put the sensor on an ice cube or heat it up and if you get a valid readings in Fahrenheit then you have an LM34

Go Up