lm35 sensor anomally

I got so many different variable on serial monitor

I dont know whats wrong :frowning:


int lm35Pin = A0;
int led = 8;
#define buzzer 9

int zaman = 100;
int okunan_deger = 0;
float sicaklik_gerilim = 0;
float sicaklik = 0;

void setup() {
pinMode(led,OUTPUT);
pinMode(buzzer,OUTPUT);
Serial.begin(9600);

}

void loop() {

okunan_deger = analogRead(lm35Pin);
sicaklik_gerilim = (5000.0/1023.0) * okunan_deger;
sicaklik = sicaklik_gerilim /10.0 ;

Serial.println(sicaklik);

if(sicaklik >= 30) {
digitalWrite(led,HIGH);
digitalWrite(buzzer,HIGH);
delay(zaman);
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
delay(zaman);

}

else{
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
}
}


SERIAL MONITOR VARIABLES

24.44
22.48
21.51
19.55
18.57
16.62
16.62
16.13
15.64
15.15
14.66
22.97
24.44
15.15
26.88
18.08
16.62
25.90
15.64
20.04
24.93
15.15
25.42
23.46
15.64
26.39
18.08
16.62
26.39
15.15
20.04
24.93
15.64
25.90
24.93
16.13
26.39
17.60
17.11
26.39
15.64
20.53
24.93
14.66
25.90
23.95
16.13
26.39
18.57
16.62
25.42
14.66
20.53
24.44
15.15
24.93
22.97
16.13
26.39
17.60

I was hoping your picture was of a hand drawn schematic of your setup. But disappointed, again.

Paul

I wasnt send schematics because i dont think problem is there
I can send schematics if you want
Thanks for your attention btw

This may help you understand the types of things that go wrong. I can see a few of them in your code.

Unstable supply voltage can cause fluctuations.

The sensor produces a voltage so is best read using the 1.1V internal analog reference. Do a search on this forum, it's a regularly returning problem.

Thank you very much

FurkanAcar:
I wasnt send schematics because i dont think problem is there
I can send schematics if you want
Thanks for your attention btw

Its pretty obvious the schematic and circuit layout are important details for any analog sensor. Please post code and circuit and datasheet links so all the information is available with which to analyze the problem. If you knew where the problem was you wouldn't be asking for help....