Go Down

Topic: LM35 thermometer (Read 9781 times) previous topic - next topic

JB

OK, after going round and round in circles for the last few days, I'm not getting any closer to getting acceptable results out of this LM335 chip - see http://www.jaycar.com.au/products_uploaded/LM135.pdf for the datasheet. I'm getting SOME change in voltage at the sensor, but it's nowhere near the measured change in temperature.

For example, just sitting on the desk at 21.6 deg C, the sensor is passing 2.970 volts. Cranking up a small heater, the measured temp is 50.6 degrees and the voltage has increased to 3.210 volts, an increase of 240 millivolts. Since each 10mV represents 1 degree, the LM335 is measuring a 24 degree increase, as opposed to the actual 29 degrees. 5 degrees is a fairly big discrepancy but it's probably one that I can live with.

What's confusing me is trying to work out why, over the above temperature range, the analog pin readings only move from 590 to 626? My board's 5V output is actually 5.22V, hence there should be 5.22/1024=5.098 millivolts per ADC value, correct? So, 626-590 = 36, times by the step value of 5.098, gives 183.5 or so millivolts, nowhere near the 240mV I measured with the multimeter.

This is how I've got my sensor wired up:

<GND>------<LM335>------+------<2K2 resistor>------<+5.22V>
                                        |
                                        |
                              <Analog pin 0>

I've searched everywhere I can think of for this LM335 interface, so if anyone has any ideas or can see where I've gone wrong, please let me know!

I'm not past trying something else either - initially I tried using some thermistors instead of the LM335, but I think that they may not be quite up to the task. If anyone can recommend exactly which type of thermistor I should be using that would also be appreciated...

Thanks for reading, again!! :)
JB

JB

Hi again...  :-[

Just a quick note to say that I've managed to get a 1k thermistor working - hooray! So, don't spend too much time thinking about the LM335 I've been on about... even though it would be nice to know what I was doing wrong with them, I'm not all that fussed about it with another solution working just fine.

Cheers,

JB.
JB

appaxster

Hey,

Could u share the info on the thermistor. I am also stuck with an LM335. Its not sensitive at all.

Bob

JB

Hi Bob,

I haven't touched on this subject for quite a long time! At the moment, I don't have the information/part numbers at hand; they are in the field at a location some 200km from my office. I will have to make a special trip out there to check this out for you, so I just wanted to warn you that it could be quite some time (maybe 2 months) before I'm able to give you any more info... sorry!

I loved working with the Arduino, but for this project it was over-kill. No, scratch that: it provided a great environment for development and testing, which then proved that having the microcontroller was like re-inventing the wheel, only exceedingly more complicated than the original design! :)

I'll do my best to get the details for you ASAP - I may be out that way before 2 months is up, but I make no promises... ;)

Regards,

JB
JB

flyboy

Bob,

I have used a 10k NTC thermistor and it works well.  My sketch below (actually, someone else's sketch that I modified and built on).  Happy coding!

Code: [Select]
// (Ground) ---- (10k-Resister) -------|------- (Thermistor) ---- (+5v)
//                                     |
//                                Analog Pin 0

#include <math.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15;            // Convert Kelvin to Celcius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}






void setup()
{
 pinMode(14, OUTPUT);
 pinMode(16, OUTPUT);
 digitalWrite(14, HIGH);
 digitalWrite(16, LOW);
}

void loop()
{
 lcd.clear();
//  lcd.setCursor(3, 1);
 lcd.print("Temp = ");
 lcd.print(int(Thermister(analogRead(1))));  // display Fahrenheit
 lcd.write(0b11011111);                      //This line is important lcd.write sends data and not ascii to the LCD (for special characters)
 lcd.print(" F");
 delay(1000);
}

ioniser

did anyone get the LM335 working? ive wired it up like the example in the data-sheet. but the readings i get out aren't what im expecting after conversion to Celsius.

davekw7x

#21
Jul 09, 2010, 05:50 pm Last Edit: Jul 09, 2010, 09:19 pm by davekw7x Reason: 1
Quote
did anyone get the LM335 working

An answer: Yes.  (See Footnote.)

Quote
aren't what im expecting


Two questions:

1. What were you expecting?

2. What are you getting?

Three more questions:

3. What ADC readings are you getting?

4. Are you doing any kind of "averaging" or "filtering" or other calculations on the ADC readings that just might be clobbering/corrupting/truncating any of the 10-bit integer values?

5. How are you converting the 10-bit integer values from the ADC to numbers representing the temperature?


Regards,

Dave

Footnote:


I don't have a thermometer in sight, so I don't know the exact ambient temperature, but It's "room temperature comfortable."

Anyhow...

1. With a measured analog reference voltage of 5.09 on the Arduino I get an ADC reading of 598, which converts to 2.97 Volts, which is precisely what I measure on the sensor.  That voltage value corresponds to 297 K according to the LM335 data sheet (plus or minus a degree or two, since I haven't calibrated the sensor).  This calculates out to 24.1 C or 75.4 F.  That seems "about right."

2. When I move a desk lamp (with an old-fashioned incandescent bulb) close to the sensor the readings increase, but I won't bore you with the details.

Therefore, I pronounce it to be "working."   YMMV!

Go Up