Love-o-meter baselineTemp problem

Hi all,

I try to understand why my Love-o-meter have this strage issue.
At the beginning of code there is a line to declare a baselineTemp const. By default the value is 20.0 and whit this value I can see this type of output:

Sensor value: 178, Volts: 0.87, degrees C: 36.91

But if I change the baselineTemp to 30.0 i see this type of output

Sensor value: 163, Volts: 0.80, degrees C: 29.59

So how it can be possible that baselineTemp value change the Sensore value that is recognize directly from the sensor?

Here my complete code also if is default from book

// utilizzo del sensore di temperatura TMP36 e di LED per indicare il grado di calore

const int sensorPin = A0;
const float baselineTemp = 30.0;

void setup(){
  Serial.begin(9600);
  
  // con un ciclo for dichiaro i pin dei led e li inizializzo nello stato LOW
  for(int pinNumber =2; pinNumber < 5; pinNumber++){
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor value: ");
  Serial.print(sensorVal);
  
  // converte le lettura ADC in tensione
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  
  // converte la tensione in temperatura
  float temperature = (voltage - .5) * 100;
  Serial.print(", degrees C: ");
  Serial.println(temperature);
  
  // in base al valore della temperatura accendiamo più o meno led
  if (temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } else if (temperature >= baselineTemp + 2 && temperature < baselineTemp + 4){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } else if (temperature >= baselineTemp + 4 && temperature < baselineTemp + 6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  } else if (temperature >= baselineTemp + 6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }

delay(2);

}

Hi,

looking at your code, the baseline temp is not used anywhere in the calculations of what is output to the serial monitor. It is only used later to decide when to turn the LEDs on, so changing the baseline temp should have no effect on what is getting output to the serial monitor.

Maybe check to make sure that your circuit is set up correctly and there are no loose connections.