Millis instead of delays

Hi everyone!

I'm trying to put Millis instead of delays in my code, following the 'Bink without delay' example. I'm using it with a temperature sensor. This was my first code, with delays:

int tempC;      
int tempPin = 2;  

void setup() 
{ 
 Serial.begin(9600); 
}

void loop() 
{     
       
    tempC = analogRead(tempPin);         
    tempC = (5.0 * tempC * 100.0)/1024.0; 
    Serial.print(tempC);
    delay (1000);
    }

And this is the second code, with millis:

int tempC;      
int tempPin = 2;  

int tempState = LOW;
long previousMillis =0;
long interval = 1000;

void setup() 
{ 
 Serial.begin(9600); 
}


void loop() 
{     
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis > interval2){
      previousMillis = currentMillis;
      if (tempState == LOW)
      tempState = HIGH;
      else
      tempState = LOW;
      
      digitalWrite(tempPin, tempState);
    }
    
    tempC = analogRead(tempPin);         
    tempC = (5.0 * tempC * 100.0)/1024.0; 
    Serial.print(tempC);
    }

It compiles well, with no errors, but the temperature sensor doesn't work. It gives the first temperature value right, but after that it gets frozen and that value doesn't change.
I don't know what I'm making bad, please check out the codes and let me know it!

The temperature sensor code should be within the if, otherwise it'll run in a tight
loop rather than once a second. That doesn't explain why it doesn't change, but
it will be outputing continuously to the serial port.

Be consistent with your types, currentMillis and previousMillis are inconsistent.