4
\$\begingroup\$

I am really new to electronics and I am just experimenting at the moment with a breadboard.

My question here is related to the LM35 temperature sensor and Arduino micro controller. I am getting a very high reading through the sensor of 448 degrees Celsius. Obviously this is way off. The conversion formula I am using is:

inputvoltage = (5.0*inputvoltage*100.0)/1024.0;

I am feeding 5V into the sensor from the Arduino and I am getting a 0.50 voltage reading on my multimeter between 5V in and output. Do you think the sensor might be faulty? Any help on this issue would be great!

EDIT: Some people have asked for my code from the arduino so here it is:

int tempPin = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  float temp = (5.0 * analogRead(tempPin) * 100.0) / 1024;
  Serial.print(temp,1);
  Serial.println(" degrees C   ");
  delay(1000);
  }

enter image description here This schematic shows the really simple configuration I have.

enter image description here

I have added a picture of my setup if anybody can spot something I can't.

\$\endgroup\$
  • \$\begingroup\$ Sure, I have added it now :) \$\endgroup\$ – Lane George Sep 29 '14 at 21:37
  • \$\begingroup\$ How about disconnecting the Vout from A0 and see what the voltage reading is from GND to Vout. How long are the wires? \$\endgroup\$ – Spehro Pefhany Sep 29 '14 at 21:46
  • \$\begingroup\$ I am getting a reading 4.15V +- 1 from GND to Vout after it is disconnected. The wires are about 6 inches long. \$\endgroup\$ – Lane George Sep 29 '14 at 21:53
  • \$\begingroup\$ Can you post the program (sketch) you're using? \$\endgroup\$ – Ricardo Sep 29 '14 at 22:00
  • \$\begingroup\$ Can you also tell us what's the variable inputvoltage before and after it gets its value assigned in the line you posted? \$\endgroup\$ – Ricardo Sep 29 '14 at 22:04
5
\$\begingroup\$

4.15V from Vout to GND with short wires and 5V supply is totally wrong. Either you have the connections wrong or the LM35 is toast. Please double-check the connection vs. the datasheet.

I suspect just because of that particular voltage reading that you may have the connections mixed up.

Edit: Thanks for the photo. Looking at the part from the front (the part with the markings) from left to right, the pin order is:

enter image description here

Vs, Vout, GND = +5, Vout, GND

In your photo I see +5, Vout, GND as it should be. So it it's reading more than 10mV/°C at Vout with the blue wire disconnected from the Arduino (and 5V/0V on the orange and black wires respectively) I would say it's dead. Perhaps the power got momentarily reversed on it?

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I am pretty sure there in nothing wrong with the connections so I have come to the conclusion that there is something wrong with the sensor. I have included a photo of my setup in my post if you can spot anything that I can't. \$\endgroup\$ – Lane George Sep 30 '14 at 18:55
  • \$\begingroup\$ Yep, I'm getting a reading if 80mV so I assume its dead. I have ordered a new one so I'll try again with that and report back if there are any problems. Thank's again for your help! \$\endgroup\$ – Lane George Sep 30 '14 at 19:33
  • \$\begingroup\$ 80mV? What happened to your 4.15V reading? Sure it isn't an LM34? \$\endgroup\$ – Spehro Pefhany Sep 30 '14 at 20:07
  • \$\begingroup\$ Woops, I apologise there... 80mV from Vs to Vout 4.15V Vout to GND. It's definitely a LM35. \$\endgroup\$ – Lane George Sep 30 '14 at 21:48
3
\$\begingroup\$

You say you "measure 0.5V between 5V input and the output". If you mean it exactly as you say it: There's something wrong with your sensor or your setup, because then the output is 4.5V from ground, which is 450degrees Centigrade, which would indeed mean the sensor is very close to smoking, regardless of the fact it doesn't work at all any more at that point.

If you mean you are measuring 0.5V at the output relative to ground, that would be about 50 degrees Centigrade, which is possible if you've been soldering recently or have intentionally heated it up.

Then we come to the math: This seems acceptable to me, assuming Arduino measures in 10bit accuracy mode. I think that's safe to assume. I am not knowledgeable about Arduino, but the Atmels inside do support 8bit and 10bit mode. As to 16bit int and/or float issues I defer to someone who knows more about the Arduino standards.

It is programatically/semantically advisable to not use "inputvoltage" to store the result, as it is not the inputvoltage. This will cause confusion if you start building this test out into something more serious and eventually forget to change it, because it now suddenly is fully integrated into all of your coding.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I was indeed referring to the measurement between 5V and output. I've double and triple checked my connections and also tried them out using a variable resistor from which I got the exact reading I wanted. I am only reading room temp with the sensor so I have come to the conclusion that it must be faulty. Thank you for the tips on variable names, I will bare that in mind from now on. \$\endgroup\$ – Lane George Sep 30 '14 at 18:48
  • \$\begingroup\$ @LaneGeorge You're welcome. I hope you take it as the friendly advice it was intended to be, we all take the short path in our initial steps into the world of programming, but learning early about the risks can help you hours of confusion in a later project. \$\endgroup\$ – Asmyldof Sep 30 '14 at 21:53
0
\$\begingroup\$

Without the code you're using, it's difficult to tell, but I would hazard a guess that you may be using a voltage reference of 1.1V (INTERNAL) instead of 5V. That's the case if you have the following line in your code somewhere before you take the temperature value:

analogReference(INTERNAL);

Can you verify if that's the case? If it is, then the correct code for extracting the temperature from your sensor is this:

temp = (1.1 * analogRead(tempPin) * 100.0) / 1024;

That difference would bring your temperature reading to about 98°C, which is better but still a bit high (if you are not measuring temp in a pot of boiling water).

If you are not using the INTERNAL analog reference of 1.1V, I suggest you do it. Add the analogReference(INTERNAL); line to your code (inside the setup() function) and use the temp calculation I give above and check again if the temp reading gets better. That will usually give you the best resolution for temperature reading with LM35 and the ATmega328 (most common Arduino microcontroller) in the 0 to 100°C range.

There's more info here: Arduino Playground - LM35 with higher resolution.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ As you can see from the code I just added, I wanted to keep it really basic initially just to try and get a reading I was happy with. Thank you for the tips there, I will bare that in mind in the future, however using the internal analog reference of 1.1v at this point is still giving me an absurdly high reading. The link was an interesting read. \$\endgroup\$ – Lane George Sep 30 '14 at 19:05
  • \$\begingroup\$ No problem. Checked your picture and your connections seem fine. The program seems ok, too. Maybe your sensor is toast. I'll give your program a go tonight on my Arduino/LM35 to see if there's anything else wrong. I'll check the float assignment and the print lines and will report back here. \$\endgroup\$ – Ricardo Sep 30 '14 at 19:20
  • \$\begingroup\$ Gave it a try on your program and it reports 30.8°C here (which is the correct ambient temperature). \$\endgroup\$ – Ricardo Sep 30 '14 at 21:04
  • \$\begingroup\$ Cheers for checking. I've ordered a new sensor so I'll that that a try when it arrives. \$\endgroup\$ – Lane George Sep 30 '14 at 21:35
0
\$\begingroup\$

I had the same issue (in my case the reading was 446 degrees).

I solved it by switching the wires connecting to power and to ground.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

It's a cold case, but I had a similar issue just now. I solved it by grounding the temp sensor through one of the ground pins next to the 5V out on my arduino, instead of using the gnd pin next to pin13.

Unsure why that worked, but it did. I have a stepper motor and some other components running off the same board.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Vs and GND are reversed, the diagram states Bottom View so you must flip the Vs and GND when looking from the top of the LM35. I made same mistake, and I think mine is dead now.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The connection doesn't look inverted to me. Black is GND, orange is Vs. \$\endgroup\$ – Dmitry Grigoryev Oct 17 '16 at 10:04

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.