I have an LM35DZ which is temperature sensor, properly connected and reading strange values... like 1023.

I've tried almost any code I could find regarding LM35DZ and Arduino, with the same results every time.

After several attempts I tried to measure voltage with multimeter on 2nd pin (Vout) and it was 4.16V. Using this code I also got 4.16V precisely :

float voltage0 =   analogRead(A0) * (5.0 / 1023.0);

By mistake I ordered 5 pieces instead of one so I tried with all of them and they all give me same result (both on Arduino and voltage measured).

Now I'm confused what is going on and why all of them return the same value?

Here are pictures:

LM35DZ wiring Arduino wiring Schematic used http://blog.rastating.com/content/images/2014/Feb/lm35_schem_1_.jpg Update: Sorry on my Bad English, I'll try to explain even more what I've done. As Ricardo told I've tried to remove Arduino out of picture and still got 4.16V, on all 5 of them. (bought them from Ebay- maybe got defective/miscalibrated ones? ) Will buy one in local electronics shop and try with it. Attached schematic picture.

  • \$\begingroup\$ Post an actual schematic. Those pictures tell us nothing. \$\endgroup\$ – Matt Young Jun 18 '14 at 13:17
  • \$\begingroup\$ Here's a post of somebody with the same problem as you. \$\endgroup\$ – Ricardo Jun 18 '14 at 13:42
  • \$\begingroup\$ Disconnect the blue/white wire and measure the voltage from the LM35 wrt GND without the connection to the PCB present. \$\endgroup\$ – Spehro Pefhany Jun 18 '14 at 15:06
  • \$\begingroup\$ As a side note, this: 5.0 / 1023.0 should be defined as a compile-time constant. You don't want to be doing unncessary division at run-time. Of course this application is not a time-sensitive project, but increased efficiency should always be realized where possible. \$\endgroup\$ – sherrellbc Jun 18 '14 at 15:46
  • \$\begingroup\$ What is the source of your +5V? Do you have a scope you can look at it with to be sure it's not noisy? Alternately, try putting a 10uF capacitor across V+ & GND and see if that improves things any. \$\endgroup\$ – lyndon Jun 20 '14 at 0:29

I don't have an answer for your question, but I'll write down what I could tell from your setup.

In spite of the low quality of your second picture, with a bit of hard work (and maybe some faith), I can tell that your connections are correct:

  • The gray/orange/brown wire goes from \$5V\$ to \$+V_S\$;
  • The gray/blue wire goes from \$A0\$ to \$V_{OUT}\$;
  • The gray wire with large black stripes goes from \$GND\$ to \$GND\$.

LM35DZ pinout

The LM35DZ (datasheet) output follows the formula below:

$$V_{out} = 0 mV + 10.0 mV/°C$$

That means you'll get the following results, approximately:

 Temp |  Vout
  0°C |    0mV
 10°C |  100mV
 50°C |  500mV
100°C | 1000mV

So, right there, there seems to be a problem with your setup. I can't explain why you're getting LM35DZ output voltages above 1V (100°C). There's got to be something in your hardware, but I don't know what it is.

Just to check: did you configure your \$A0\$ pin to input? It's a long shot because that may already be the default, and also because the analogRead() call probably does that for you.

Another thing to try: if you heat up the sensor a few degrees by holding the TO92 case with your fingers for a few seconds, do you get a small increase in the \$V_{OUT}\$ voltage? If so, maybe that means the batch of LM35 you got is miscalibrated. If that's the case, you may be able to compensate for that and calibrate them yourself, by adjusting the temperature formula in your code. There's some information on how to do it in the related question, How to calibrate a temperature sensor.

That's cheating, admittedly, but who cares as long as it works? We're Engineers, not Scientists :D

Finally, I would suggest you to isolate the variables: remove the Arduino board from the setup and power the LM35DZ separately on the breadboard. Watch out for the \$+V_S\$ absolute maximum of 35V. Then measure \$V_{OUT}\$ again. If you get the same 4.16V, then the problem is with the sensor. If you get something around 300mV, then the problem is related to your Arduino board.

  • 1
    \$\begingroup\$ AVR microcontroller pins default to input, as you have said. I also second your recommendation - I remove the Arduino and measure the output as a function of varying lengths of time you heat the device with your hands. Plot this information and see if you get a somewhat constant slope (10mV/C approx.). \$\endgroup\$ – sherrellbc Jun 18 '14 at 15:52
  • 1
    \$\begingroup\$ Hey Ricardo! I did exactly that (my English is bad and I know it)! Hooked up 5V and GND, than measured output of Vout and still got 4.16V. I'll buy tomorrow one LM35DZ in local electronics shop and try again. Maybe I really got miscalibrated ones. Will update tomorrow! Thanks guys! \$\endgroup\$ – nordashi Jun 19 '14 at 20:20

As Ricardo suggested it was problem with LM35DZ - they are uncalibrated. Bought LM35DZ in local electronics shop and everything is working as it should.

Its funny, they are same, all markings and everything. Thanks on your help guys!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.