Arduino Locking up - IR Temp sensor

All,
I’m trying to use the mlx90614 IR temperature sensor with my Arduino Uno, and also with a knock-off nano. I’m using a sensor module like this. The code is directly from “Peter Fleury” as shown at this website. The only thing I added to the code is an LCD print. Here’s the code:

#include <LiquidCrystal.h>
#include <i2cmaster.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  i2c_init(); //Initialise the i2c bus
  PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
}

void loop() {

  int dev = 0x5A << 1;
  int data_low = 0;
  int data_high = 0;
  int pec = 0;

  i2c_start_wait(dev + I2C_WRITE);
  i2c_write(0x07);

  // read
  i2c_rep_start(dev + I2C_READ);
  data_low = i2c_readAck(); //Read 1 byte and then send ack
  data_high = i2c_readAck(); //Read 1 byte and then send ack
  pec = i2c_readNak();
  i2c_stop();

  //This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
  double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
  double tempData = 0x0000; // zero out the data
  int frac; // data past the decimal point

  // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
  tempData = (double)(((data_high & 0x007F) << 8) + data_low);
  tempData = (tempData * tempFactor) - 0.01;

  float celcius = tempData - 273.15;
  float fahrenheit = (celcius * 1.8) + 32;


  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(fahrenheit);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("F");

  delay(1000);
}

Everything works great for a few minutes (10-20), then it freezes. If I reset the arduino (uno or nano) with the reset button it will start working again for a few seconds, then freeze again. If I leave it off for a day and come back, it will all repeat (works for a few minutes, then freezes). I’m no expert in programming or circuit design, so I have no idea what the problem can be. Any help would be greatly appreciated.

A couple more notes - the sensor is on about 20 ft of speaker wire, and currently the max temp it has seen is about 140 degrees F.

Thanks

May look like 'out of memory'

Try declare the 'ints' to top.. make them gloabal

Thanks I think that fixed it; been running for several hours now.