Making a working liquid thermometer

Hello everyone, thanks for the replies. I wanted to point out that the serial communication is (mostly) fine for my application, which means that it receives data correctly (temperature is temperature and humidity is humidity, and I see this from the console). My problem lies in the graphical part: the red rectangle inside the thermometer doesn’t always rise when the temperature increases (when confronting it with the previous temperature value) even though the temperature is received fine. The code I’m having trouble with is this part:

  noStroke();
  fill(255);
  rect(1460, 565, 150, 400);
  fill(255,0,0);
  ellipse(1460, 840, 260, 260);
  fill(0);
  text(t+"°C", 1400, 900);
  T = float(t);
  noStroke();
  fill(255,0,0);
  rect(1460, 700, 100, PrevW+150); 
  if (T != PrevT) {
    w = T - PrevT;
    W = 1/w;
    noStroke();
    fill(255);
    rect(1460, 565, 150, 400);
    fill(255,0,0);
    ellipse(1460, 840, 260, 260);
    fill(0);
    text(t+"°C", 1400, 900);
    fill(255,0,0);
    rect(1460, 700, 100, 150+W); } 

I thought that confronting the temperature with the previous one received and using the reciprocal of the variation (to make a .1 temperature variation into a 10) to change the size of the rectangle would work, but apparently it doesn’t. That’s what I’m trying to figure out