Go Down

### Topic: Displaying temperature using LM35 sensor (Read 2371 times)previous topic - next topic

#### nella400

##### Apr 18, 2012, 04:49 am
I have hooked up my LM35 properly. I cant figure out where to go to read the temperature results. Also I need to know how to upload the program i have written properly to the arduino

#### Docedison

#1
##### Apr 18, 2012, 05:54 am
Ummm, read the book... maybe like the rest of us did...

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

#### robtillaart

#2
##### Apr 18, 2012, 08:08 pm

it works similar as the lm34 one , there are different algorithms compared in this sketch, have fun

Code: [Select]
`////    FILE: lm34.pde//  AUTHOR: Rob Tillaart//    DATE: 2012-01-24// PURPOSE: showing LM34 fahrenheit temp sensor// VERSION: 0.1// HISTORY: 2012-01-24 initial version (2 diff loops//          quite a difference between 3 sensors//float raw = 0;float t = 0;void doPrint(){  Serial.print(raw);  Serial.print("\t");  Serial.print(t, 4);  Serial.print("\t");  Serial.println((t-32)*0.555555555555, 4);}void setup(){  Serial.begin(115200);  Serial.println("START....");}void loop1(){  raw = raw * 0.9 + 0.1 * analogRead(A0);  t = 5 + raw * 500.0/1023.0;  doPrint();  delay(10);}void loop3(){  raw = 0;  for (int i=0; i<100; i++) raw += analogRead(A0);  t = 5 + raw*5.0/1023.0;  doPrint();  delay(10);}void loop2(){  raw = 0;  for (int i=0; i<500; i++) raw += analogRead(A0);  t = 5 + raw/1023.0;  doPrint();}`
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Docedison

#3
##### Apr 20, 2012, 12:05 am
Thank You Sir for a most useful sketch, I am a noob here and this is good insight for analog sensors in general and the LM series specifically. I have used them for years as they are accurate out of the box, a check of 200 devices I used in a production run were all within 1 - 2% of correct temp and that error might well be the granularity of the A/D conversion, an 8 bit conversion is +/- 4 MV or +/- 1/2 deg F.  This combined with the stated accuracy of the sensor would make the LM34/5 parts a very good deal and easier to use than the Dallas/Maxim parts. As a side note the temp measurement chips usually described, the DS18B20 are in my opinion much harder to use, even with the library's written for them as the A\/D conversion is direct @ 10 Mv / deg with the standard 10 bit resolution the error is 1 part in 124 or less than 1 Mv unless I am seriously mistaken.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

#### Docedison

#4
##### Apr 20, 2012, 12:25 am
My math is wrong in the above post ii the error is 10MV (1 deg) parts in 1024 = 1/102 about 4.8%, and it is readily possible to have an inaccuracy of 2 or 3 counts due to ground potential differences, a common failing in using any analog device. Still good accuracy though... IMO

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

#### robtillaart

#5
##### Apr 20, 2012, 07:12 am

Although I allways use Celsius I prefer the LM34 which counts degrees Fahrenheit as its step size is ~ 0.56 C  (5/9) which is almost twice the stepsize of LM35.

The math is typical

C = (F -32) * 5 / 9;

times 2 and some reshuffle

C = (F *10 - 320)/18

int C = (F * 10 - 311)/18;
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Constantin

#6
##### Apr 20, 2012, 02:55 pm

This combined with the stated accuracy of the sensor would make the LM34/5 parts a very good deal and easier to use than the Dallas/Maxim parts.

Allow me to disagree. While I use the LM35, TMP36, etc. I would not consider them superior to the 1-Wire temperature devices out there like the DS18B20. Unlike 1-Wire sensors, the LM35 et al produce a analog signal which can easily pick up noise. Additionally, they are very dependent on a stable voltage source. So while they are significantly less expensive than the 1-Wire sensors out there, they come with significant caveats... just scan the boards here for the many HELP! questions relating to LM35's producing erratic readings.

The 1-Wire devices use a digital bus that can be over 100' long, yet suffer no ill effect, and over a hundred 1-wire devices can operate off of one power source. Additionally, 1-wire sensors are available in all sorts of neat packages like waterproof assemblies. The major downsides are the 12-bit resolution (if you need more) and the cost.

Aces in their places and all that. I use the LM35 on PCBs where I can control voltage, minimize noise pickup with careful trace design, etc. while using DS18B20 for off-board applications where noise resistance, convenience, etc. trumps all other considerations. For even better resolution, I skip LM35's and use 2k52 thermistors and a dedicated 16-bit ADC in a bridge circuit to maximize the resolution of the thermistors across the temperature range that is of interest.

#### Docedison

#7
##### Apr 20, 2012, 06:07 pm
And you are correct in ALL respects, however it is not too much difficulty to provide a stable 5V source that is noise free and properly bypassed. It is a requirement for stable operation of the Arduino. Power Supply instability is of paramount importance for a well designed device and as to 100" of wire and multi-drop measurements, yes of course the Dallas parts are the only way to go. You forgot to mention the Alarm capabilities. The routines for the digital sensors are a part of the Arduino environment... Native , so to speak. It is best, in my opinion to apply the best part for the job and the job here is education as much as building things to add to ones environment, so I advocate the LM34/5 as an accurate and easy to use part, provided that the total environment is good which means an accurate and well bypassed power supply. Fully half of the issues I see here could be a poor power supply.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Go Up

Please enter a valid email to subscribe