SPI and Max6675

Hello, im new to IMP microcontrollers platform in general but
the thing is i have to build this project for my school, wich consists of max6675 spi based thermo couple sensor, and electricimp as microcontroller. The main task is to read sensor value, and then based on
the readings turn an led , for example. I found pretty good instruction in imps user guides about SPI’s, and how to work with them using imp. But things are not workig well for me.

Code:

/// Config
spi <- hardware.spi257;
spi.configure(SIMPLEX_RX| MSB_FIRST |CLOCK_IDLE_LOW|CLOCK_2ND_EDGE,400);
local cs = hardware.pin1; // selecting pin for chipselect
cs.configure(DIGITAL_OUT,1);

function read8bytes() {
cs.write(0); // set cs LOW to start reading values

// Read some data...
local s = spi.readblob(8);

    cs.write(1);  //  set cs HIGH  to stop reading values

return s;                       

}

server.log(read8bytes().tostring());

read8bytes();

The values are -
02 e0 02 e0 02 e0 02 e0

MAX6675 holds its values in 12 bits, where FFF is 1023 degrees.
So how do i can convert those values in degrees? and check if they are accurate ?
Thanks!

The code below is taken from an Arduino website. Maybe that will help.

 // Read in 16 bits,
  //  15    = 0 always
  //  14..2 = 0.25 degree counts MSB First
  //  2     = 1 if thermocouple is open circuit  
  //  1..0  = uninteresting status
  
  v = shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
  v <<= 8;
  v |= shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
  
  digitalWrite(MAX6675_CS, HIGH);
  if (v & 0x4) 
  {    
    // Bit 2 indicates if the thermocouple is disconnected
    return NAN;     
  }

  // The lower three bits (0,1,2) are discarded status bits
  v >>= 3;

  // The remaining bits are the number of 0.25 degree (C) counts
  return v*0.25;
}

So it looks like this might be the answer:
Temperature (celsius)= max6675 output (12bit)* 0.25

(swap2(read8bytes().readn('w')) >> 3)*0.25

but note you only need to read two bytes, not eight.

Peter