LM35 temperature sensor doesn't work properly while using it with other sensors.

I’m trying to use LM35 and HCSR04 sensors together but as soon as I set up the HCSR04 LM35 starts calculating temperature wrongly (Room temperature is 21 C LM35 calculates 135 C).
I tested LM35 itself alone and it works fine, HCSR04 works fine with other sensors and alone but LM35 doesn’t work. There seems no short circuits or anything. Is there anyway to fix it?

Here’s the code I’m using, it is turkish but you can understand it easily and nothing seems wrong with the code but I’m putting it just in case.

const int lm35 = A0;

const int echo = 2;

const int trig = 4;

float gelen_veri;

float voltaj_deger;

float sure;

float mesafe;

float sicaklik;

float formul;

float hiz;

const int sag_i = 8;

const int sag_g = 9;

const int sol_i = 10;

const int sol_g = 11;

void setup(){

  pinMode(echo, INPUT);

  pinMode(trig, OUTPUT);

  pinMode(sag_i, OUTPUT);

  pinMode(sag_g, OUTPUT);

  pinMode(sol_i, OUTPUT);

  pinMode(sol_g, OUTPUT);

  Serial.begin(9600);

}

void loop()

{

  gelen_veri = analogRead(lm35);

  voltaj_deger = (gelen_veri / 1023.0) * 5000;

  sicaklik = voltaj_deger / 10.0;

  Serial.println(gelen_veri);

  Serial.println(voltaj_deger);

  Serial.println(sicaklik);

  digitalWrite(trig, HIGH);

  delayMicroseconds(1000);

  digitalWrite(trig, LOW);

  sure = pulseIn(echo,HIGH);

  formul = sqrt(1+(sicaklik/273));

  mesafe = (sure/2)*formul;

  hiz = mesafe*0.03;

  Serial.print("mesafe = ");

  Serial.println(hiz);

  Serial.println  (sicaklik);

  Serial.print("sure = ");

  Serial.println(sure);

  delay(1000);



  if (hiz < 15) {

    digitalWrite(sag_i, HIGH);

    digitalWrite(sag_g, LOW);

    digitalWrite(sol_i, HIGH);

    digitalWrite(sol_g, LOW);

  }

  else {

    digitalWrite(sag_g, HIGH);

    digitalWrite(sag_i, LOW);

    digitalWrite(sol_i, LOW);

    digitalWrite(sol_g, HIGH);

  }

}

An LM35 should be read with the internal 1.1volt Aref (assuming Uno) for stability and resolution.
The LM35 should have it’s own (not shared) ground wire to the Arduino.

Modified the code for the internal 1.1volt Aref.
Code is untested.
Leo…

const byte lm35 = A0;
const int echo = 2;
const int trig = 4;
int gelen_veri;
float sure;
float mesafe;
float sicaklik;
float formul;
float hiz;
const int sag_i = 8;
const int sag_g = 9;
const int sol_i = 10;
const int sol_g = 11;

void setup() {
  Serial.begin(9600);
  analogReference(INTERNAL); // use internal 1.1volt Aref
  pinMode(echo, INPUT);
  pinMode(trig, OUTPUT);
  pinMode(sag_i, OUTPUT);
  pinMode(sag_g, OUTPUT);
  pinMode(sol_i, OUTPUT);
  pinMode(sol_g, OUTPUT);
}

void loop() {
  gelen_veri = analogRead(lm35);
  sicaklik = gelen_veri * 0.1039; // calibrate temp by changing the last digit(s) of 0.1039
  // removed the intermediate voltage step for simplicity
  Serial.print("A/D:");
  Serial.print(gelen_veri);
  Serial.print("\tSicaklik: ");
  Serial.println(sicaklik, 1); // one decimal place
  digitalWrite(trig, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trig, LOW);
  sure = pulseIn(echo, HIGH);
  formul = sqrt(1 + (sicaklik / 273));
  mesafe = (sure / 2) * formul;
  hiz = mesafe * 0.03;
  Serial.print("mesafe = ");
  Serial.println(hiz);
  Serial.println(sicaklik);
  Serial.print("sure = ");
  Serial.println(sure);
  delay(1000);
  if (hiz < 15) {
    digitalWrite(sag_i, HIGH);
    digitalWrite(sag_g, LOW);
    digitalWrite(sol_i, HIGH);
    digitalWrite(sol_g, LOW);
  } else {
    digitalWrite(sag_g, HIGH);
    digitalWrite(sag_i, LOW);
    digitalWrite(sol_i, LOW);
    digitalWrite(sol_g, HIGH);
  }
}

This may help you understand the issue Reading LM34, LM35, LM335 (LM3x) Temperature Sensors Accurately – Arduino++