Code entering wrong if sentences

Hi everyone, I’m trying to do a Bluetooth based temperature and humidity reader, with this measurements the Arduino activates or deactivates a rele. The problem is that when I add other if inside the if from the bluetooth availability, I get all the print, even the ones that aren’t supposed to show.

#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

#include <SoftwareSerial.h>
SoftwareSerial BT(10,11);

int pin_rele = 4;

float t_set = 25;

char in_char;

void setup() {
  BT.begin(9600);
  Serial.begin(9600);
  Serial.println(F("Inicializando DHT 11"));

  dht.begin();

  pinMode(4,OUTPUT);

  
}

void loop() {
  delay(1000); 
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  if (BT.available()){
    delay(10);
    in_char = BT.read();
    if (in_char = 'l'){
    
      Serial.print("Temperatura: ");
      Serial.print(t);
      Serial.println("°C");
      Serial.print("Humedad: ");
      Serial.print(h);
      Serial.println("%");
      delay(20);
      BT.print("Temperatura: ");
      BT.print(t);
      BT.println("°C");
      BT.print("Humedad: ");
      BT.print(h);
      BT.println("%"); 
    }
    
    if (in_char = 's' ){
      BT.print("t_set es: ");
      BT.print(t_set);
      BT.println("°C");
    }
  }
    if (t>t_set+2 || t<t_set-2){
      digitalWrite(pin_rele,HIGH);
  }
  
    else{
      digitalWrite(pin_rele,LOW);
  }
}

So, if I enter a l I should get the print of Temperature and Humidity from the first if sentence, but I’m getting also the second one, that’s supposed to show when I type an s.
I don’t know what’s happening here, so any clue will be good recieved.
Thanks.

At the very least, you are using assignment

=

when what you want is comparison

==

in you if statements.

HTH

a7

You are confusing between assignment operator (=) and compassion operator (==) in if statement

Haha, yes C/C++ really could use a compassion operator.

a7

newbie issues... jajajaja thanks to you all.