LM35DZ shows wrong values

Hi,

I have a problem with my LM35DZ which show me values that aren't the ones I expected.
I tried different codes and change the PIN but it's still the same.

Here is the code I'm using

float tempC; 
int pinLM35 = A1; 
 
void setup() {
  Serial.begin(9600);
 
}
 
void loop() {
  tempC = analogRead(pinLM35);
  Serial.print("Temp before multiplication "); 
  Serial.println(tempC);
   
  tempC = ((5.0 * tempC * 100.0)/1024.0) / 10; 
 

  Serial.print("Temp after multiplication "); 
  Serial.println(tempC);
  Serial.print("\n");
  

  delay(1000);
}

And on the image below I show you what I notice

[img]https://imgur.com/AMhQw6H[/img]

The values in the red rectangles are the ones that I think are accurate and the ones in the blue rectangles are those that are confusing me...

(I know that is an equation not just a multiplication, a little mistake there, nothing to do with the problem anyways)

Hope you can help me, thanks in advance

Alanlxv's picture:


It's better to post images directly to the forum, rather than providing a link to an external website. Some forum members will not bother to visit an external site and so you will have a lesser chance of getting help. Best practice is to attach and embed the image following these instructions:
http://forum.arduino.cc/index.php?topic=364156
You can also embed images from an external host. The problem with that is it tends to result in the image disappearing after some time as it is no longer available from the external host. This means that the forum thread will not be as useful a reference for other people with the same question who find it in the future.

Which Arduino?

outsider:
Which Arduino?

It's Arduino UNO.

I was about to post a reply just after I posted this because I forgot but the site said that I have to wait 5 minutes and then I fell asleep. Sorry for replying three days late, I thought that when someone answered me it would arrive in my gmail but it didn't. And sorry if my grammar is not correct.
Thankss

I also found that notifications weren't enabled by default when I first signed up for a forum account. You might want to check the your notification settings:
Here's how you can find your previous posts:

  • Hover the mouse pointer over your avatar in the top right corner of any arduino.cc page.
  • Click "Profile".
  • Click "Forum Settings > Edit".
  • Click the "Settings" tab.
  • Click "Notifications".

There, you will see several important notification settings.

I tried this code. The values drop to zero and I didn't even touch it, I checked the wiring multiple times, it's not that difficult indeed so I'm almost sure that's not the problem

const int sensorPin= A0;
 
void setup()
{
  Serial.begin(9600);
}
 
void loop()
{
  int value = analogRead(sensorPin);
  float millivolts = (value / 1023.0) * 5000;
  float celsius = millivolts / 10; 
  Serial.print(celsius);
  Serial.println(" C");
  delay(1000);
}

Looks like loose connection to me, are you SURE the LM35 is connected correctly? Datasheet page 3. At room temperature (23C) the ADC value should be around 47.

outsider:
Looks like loose connection to me, are you SURE the LM35 is connected correctly? Datasheet page 3. At room temperature (23C) the ADC value should be around 47.
http://www.ti.com/lit/ds/symlink/lm35.pdf

Here it is, I think it's correct.

This is a genuine part, not a knock-off from eBay?

MarkT:
This is a genuine part, not a knock-off from eBay?

I bought an starter pack for Arduino, all the other stuff seems to work properly, I only have problems with this.