Temp sensor is incorrect?

Hello, I am quite a noob with arduino as ive only had it for a month. I built a tempature teller to say, it would take the tempature a put it on a lcd display. All was fine and well, I got bored with it and took it apart. Now here I am I built it again with the same design and its showing way high readings, as it wasnt before. Could someone explain or help me.

float tempF;
int tempPin = 0;

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);



void setup()
{
Serial.begin(9600); 
lcd.begin(16, 2);
lcd.print("Tempature:");
}

void loop()
{
tempF = analogRead(tempPin);          
tempF = (5.0 * tempF * 100.0)/1024.0;  
Serial.println((byte)tempF);
lcd.setCursor(0, 1);
lcd.print((byte)tempF);




delay(1000);
}

(deleted)

Are saying that this code worked before you took the hardware to pieces and the exact same code is now giving incorrect readings with the reassembled hardware?

Where do you suppose the problem is?

Is it any use posting working code and expecting advice about how to fix it?

...R

spycatcher2k:
What sensor? how have you got it connected? Datasheet? Anything????

Im not sure what it is but it comes from a starter kit..... sorry for not being helpful

Robin2:
Are saying that this code worked before you took the hardware to pieces and the exact same code is now giving incorrect readings with the reassembled hardware?

Where do you suppose the problem is?

Is it any use posting working code and expecting advice about how to fix it?

...R

Sorry my mistake I posted it just in case someone needed to know...

If you don't know what kind of sensor it is, how did you arrive at the formula for converting the reading to temp? (The formula looks same as for an LM35, but that's C not F.)

You sure it's plugged into the right pin hole?

Yeah its plugged in to the correct pin. It shows the temp but its super high like 200 degrees

I had rather hoped that my earlier post would prompt you to post information about the part of your project that has problems - a diagram of how everything is wired.

...R

@BetterGamer,

It is good that you posted the code, so we can see that is not the problem. Further more it makes clear you use an analog sensor.
Because you use Fahrenheit it might be the LM34

Does the sensor becomes hot?

*@JimboZA, the LM35 and LM34 both have similar formula 10mVolt/degree *
but as the LM34 does Fahrenheit it is almost twice (1.8) as sensitive as the LM35 which does Celsius!

Sorry, here you go Robin. It might not help due to the quality though.

And no it doesnt get hot, it feels the same as when its in my box.

Picture0002.JPG

Shouldn't the sensor rather be connected to an analog pin? I.e A0. Applies to both code and board.

Code's correct... analog pins don't need the "A" when they're being used for analogReads, only when they're used for digital.

But yeah.... it's plugged into a digital pin so that's wrong.

I asked y'day if it was in the right hole- I should have been more specific.

Right, since which pin 0 is meant is obvious by the use. Still it can be confusing for newbies like me...

Find your component.

lm35.jpg

All back to normal!! Thanks so much guys and or gals you were so helpful!!!! :slight_smile: Have a great day!
It wasnt connected to the A0 pin

Lesson learned: within 5 minutes of showing the system, you had the answer.