Lm 35 sensor not giving correct reading - giving different reading each time

Hi everyone.Being newbie to amazing arduino world ,I want help from you guys in getting my temperatue measurement system with Lm35 sensor to get properly work. I want to design a system to measure water temperature in tank with lm35 and arduino.As a first step I browse through many tutorial in making lm 35 as water proof one and found one on youtube with following https://www.youtube.com/watch?v=iXbKNJTj6Po I tried to sealed my sensors as shown in vedio but instead of plastic case I attached to it copper tube case and started with general code as available on various links.

float temp; int tempPin = 0;

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

void loop() { temp = analogRead(tempPin); temp = temp * 0.48828125; Serial.print("TEMPRATURE = "); Serial.print(temp); Serial.print("*C"); Serial.println(); delay(1000); }

But to my surprise I found sensor giving different values each time :slightly_frowning_face: .Now I am cluless for any problem in not getting correct reading with the system. I came across many articles suggesting to use 1023 instead of 1024 but that also didn't work.Can anyone suggest me more proper code for lm 35 and necesary changes required to make.also my tank is at distance of around 10m from my computer would that create any problem.

are you sure using right value here

float tempC;
int reading;
int tempPin = 0;

void setup()

void loop()
reading = analogRead(tempPin);
tempC = reading / 9.31;
you can try above code.

Hi ishan318

As a quick thing to try, change your definition of tempPin ...

int tempPin = A0;

Please post some of the output from the program so we can see how much the readings are changing (copy and paste the output from serial monitor into a post).

Can you post a diagram of how you have the LM35 connected to the Arduino? A photo of a hand-drawn diagram is fine.

With a 10m connection to the sensor, the changes may be due to electrical noise being picked up on the cable.