Shop OBEX P1 Docs P2 Docs Learn Events
LM34 Temperature Sensor — Parallax Forums

LM34 Temperature Sensor

I purchased several LM34 temperature sensors to use with my high school engineering classes. The LM34 has a great reputation for accurate temperature measurement (+/- 0.5 degree F) and provides a voltage signal that is a linear function of the Fahrenheit temperature (10mV per degree F, 0 v = 0 degrees F). My LM34 sensors seem to read about 5 degrees F (50 mV) higher than a thermometer placed next to the breadboard. I have tested the reference voltage to the LM34 and found it to be 4.96-4.97 v. Can anyone suggest what the problem might be? Many thanks as always for your incredible support!

Comments

  • 1. Do all the LM34's return the same temperature?

    2. Do you know the thermometer is correct?

    3 Is it just me or is it drafty in here?
  • Yes -- all five of my LM-34's return the same temperature which is about 5 degrees higher than actual room temperature. We verified the actual room temperature with multiple thermometers.
  • Hmm. TI guarantees +- 1 degree. How are you measuring the output of the LM34?

    And: Are you sure the LM34 and the thermometer are at the same temperature? Everything has had plenty of time to settle?
  • Originally I was measuring the output of the LM34 through an ADC0831 into a BS2. When I saw that the temperature measurement was off, I tested the LM34 output with a multimeter to be sure that my ADC and/or code wasn't the problem. The voltage reading on the multimeter agreed with the voltage reading through the ADC0831/BS2.

    Your second question is one that I also have. While all the parts had time to settle, I wondered if the local temperature on the board (or in the wires??) might be elevated vs ambient temp.
  • kwinnkwinn Posts: 8,697
    Sounds like there is an offset voltage in the measurement circuit. Can you post the schematic of the entire circuit including the lm34, adc0831, and anything in between them?

    If the 5 degree difference is constant over the entire temperature range you can always subtract it in the software.
  • The circuit I'm using is identical to the one on page 45 of the Parallax Basic Analog and Digital Text (https://www.parallax.com/downloads/basic-analog-and-digital-text) except I have the LM34 in place of the 10K pot. Can you say more about what would cause an offset voltage in the measurement circuit?

    If we can't get to the root cause, we'll make an offsetting correction in the code.

    Thanks for your help!
  • If you have vREF connected to 5V, then one step on a 8 bit DAC is about 20 mV (2 degrees).
  • If you can, measure both at the sensor and the ADC pin to make sure you don't have a voltage drop. Do you have a cap across the output? Is the reading steady or bouncing around?

    To increase resolution, use a lower Vref. What is the max temp. you need to read?

    When I need precision, I calibrate with ice/boiling water. LM34's fit perfectly into 1/4" brass tube. You can crimp and then solder the end for a quick submersible sensor housing.

    Good luck!

    Jonathan

  • kwinnkwinn Posts: 8,697
    edited 2016-04-16 21:58
    sjenny wrote: »
    The circuit I'm using is identical to the one on page 45 of the Parallax Basic Analog and Digital Text (https://www.parallax.com/downloads/basic-analog-and-digital-text) except I have the LM34 in place of the 10K pot. Can you say more about what would cause an offset voltage in the measurement circuit?

    If we can't get to the root cause, we'll make an offsetting correction in the code.

    Thanks for your help!

    A voltage offset can be caused by many things such as poor connections, leaky capacitors, circuit noise, and defective components. Because you are getting the same error with multiple LM34's it may be from the ADC, although having the multimeter verify the problem seems to rule that out. Another possible source of error is noise or voltage fluctuations on the power supply.

    What voltage are you applying to the LM34?
  • Thanks for your help. I've measured the voltage to the LM34 at 4.96-4.97 v.
  • In reply to Jonathan,

    (If you can, measure both at the sensor and the ADC pin to make sure you don't have a voltage drop. Do you have a cap across the output? Is the reading steady or bouncing around?)

    I seem to get the same voltage reading with the multimeter and the ADC and the reading seems to be steady. What do you mean by a "cap across the output?"

    (To increase resolution, use a lower Vref. What is the max temp. you need to read?)

    The maximum temperature we need is about 150 degrees F.

    (When I need precision, I calibrate with ice/boiling water. LM34's fit perfectly into 1/4" brass tube. You can crimp and then solder the end for a quick submersible sensor housing.)

    Thank you for this suggestion!!! I have a couple of students working on a project for which they'll need to immerse the LM34. They will be very grateful for your advice!


    (Good luck!
    Jonathan)

    Thank you, Jonathan!


  • The LM34 in TO92 package comes in several grades as calibrated at the factory.
    LM34CAZ +/- 1°F $10ea
    LM34CZ +/- 2°F $6ea
    LM34DZ +/-3°F $2ea

    My guess is that you have the D grade, and that could explain some of the spread. It sounds like they were all around the same value, 5° above your reference.

    I wouldn't trust the reference. There can be remarkable differences between locations (and thermometers!

    One thing with the LM34 happens when it is mounted on a cable or has a certain amount of capacitance in parallel with its output. It can become unstable and go into an oscillation that makes the output seem high. I doubt that is happening with yours, but it is something to be aware of.

  • Sjenny,

    By "a cap across the output" I mean a small (.1 to .01) cap connected between the LM34 output and the ground pin. If the signal you are reading changes slowly and the distance to the sensor is long, a small cap can help stabilize bouncy readings. An example of this was on my old hot hot tub setup. It was 30' from the tub to the controller and tub temperatures change slowly. I had a 2 degree difference between on and off for the heater and bouncy reading could cause the heater pump to cycle. The cap smoothed it out and solved the problem.

    Since you only need to read a max of 150 degrees, you could use a Vref as low as 1.5V. However, what I would do is use a 2.5 Vref as you can buy them easily. This will double your resolution. Be forewarned though that you will have to play with integer math to get it to add up correctly.

    The brass tube is good but will not stand up to water forever. The electrolysis will eventually corrode the tube and cause it to leak. Use silver solder for longest life. I actually use stainless steel tube and weld the end shut but it is kinda tricky to weld with the tube being so thin walled. In the hot tub I would get a couple of years out of the brass sensor housing before they failed. Now I use the stainless.

    Jonathan
  • If anything, let this be a lesson that the world isn't a perfect place, so build in analog adjustment or deal with scale and offset in the software program (a concept called calibration).
  • Sjenny,

    It's best if you show a photo of your setup and the code you are using.

    TomCrawford mentioned the TI datasheet.
    http://www.ti.com/lit/ds/symlink/lm34.pdf

    Kwinn mentioned power issues.
    Figure 13 (page 12) of the TI datasheet shows an optional 0.1 uF Bypass Capacitor connected between the + and - leads.
    Section 9 on page 16 also says that a bypass capacitor may be needed in a noisy environment.
  • I want to address an apparent contradiction between the messages from Jonathan and myself about a capacitor on the LM34 output. I said it could destablize, while Jonathan suggested adding one to make the reading more stable. It depends on the value of capacitance and on adding an extra resistor between the output and the capacitor. The instability comes from a capacitor on the order of 100pF to 1nF, which can happen on the end of a cable from 1 foot to several feet. It might also happen on a solderless breadboard, because of the stray capacitance between the rows of terminals. Add a resistor of 500 ohms between the output of the LM34 and the cable or capacitance and the instability (oscillations) will go away. A much longer cable or a much larger capacitance can swamp the oscillations, but an added resistor at the output can always help with stability. All this is described in detail in the LM34 data sheet linked above.

    Five degree difference is too much -- There is something wrong somewhere in the setup or the assessment.
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2016-04-19 16:09
    I've been using LM34 sensors for years, since soon after it was introduced by National Se iconductor around 1985. Take a look also at the app note http://www.ti.com/lit/an/snoa748c/snoa748c.pdf for a historical/technical perspective.

    Back then I had a similar question, my readings were not up to snuff and were coming in outside the ±1°F tolerance that National claimed for the LM34CAH. I called National and asked to speak to someone in technical support. To my surprise, Bob Pease took the call himself. To those not familiar with the pantheon of analog designers at National, Bob Pease along with Widlar and Dobkin were the gods, thus, wow!, my estimation of National went through the roof. Bob took a half hour to explain to me the care they had taken in their own lab to set up the packaged sensors inside a double insulated cardboard box with circulating air flow and lack of other heat sources conductive or radiative, matching thermal masses of test devices and their ASTM (American Society of Testing Materials traceable) reference. The effects of self-heating (minimal). Then on to difficulties of testing at the wafer level, before the chips were packaged. I thanked him for the education and sure enough, similar preparations on my part brought my readings into agreement with an ASTM thermometer, one that set me back a bundle of cash.

  • And let me just add that if Tracy and I disagree, go with what Tracy says! He actually knows what he is doing and I likely just got lucky!

    Jonathan
Sign In or Register to comment.