LM35DZ sensor gives 0 value

Hello. I am new to using the LM35DZ sensor and I just unpacked it. I believe I connected the cables correctly. But for some reason the sensor starts to give a value in a certain range and then slowly drops to 0. I have the same problem with 2 LM35DZ sensors that I just unpacked.

Code:

#define LM35_Pin A0


void setup() {
  Serial.begin(9600);
  pinMode(LM35_Pin, INPUT);
}
void loop() {
  Serial.print("Value: ");
  Serial.println(analogRead(LM35_Pin));
  delay(1000);
}

Output (9600)

Value: 11
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 1
Value: 3
Value: 5
Value: 5
Value: 5
Value: 8
Value: 10
Value: 11
Value: 11
Value: 10
Value: 12
Value: 12
Value: 10
Value: 8
Value: 6
Value: 4
Value: 3
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 16
Value: 47
Value: 73
Value: 77
Value: 75
Value: 75
Value: 73
Value: 70
Value: 68
Value: 64
Value: 64
Value: 60
Value: 48
Value: 26
Value: 5
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
Value: 0
...


Set-up

What am i doing wrong?

Two things: not errors, but opportunities for improvement.

  1. You don't need to configure an analog input pin as INPUT.
  2. Always start at a much higher serial rate and reduce if needed. I suggest 115,200bps

Your code looks fine so it's probably a wiring error. Show a schematic. A photo of what you have done isn't very useful.

To debug, remove shield and plug cables direct to arduino.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.