Re: Adafruit MAX31855 With MATLab
So I know this is a reply to a fairly old post, but after searching the entire web I didn't find an answer to this problem, which was how to read the Max31855 from a matlab script. I provided the Matlab code I used in order to plot the temperature in real time.
dev = spidev(a,'D10'); %Chip select pin D10, MISO is ICSP-1, SCK is ICSP-3, MOSI(not used)
dataIn = [1 1]; %write 2 pieces of info in order to receive 2 pieces of info
dataOut = writeRead(therm,dataIn,'uint16'); %uint16 is the largest integer you can use with this function therefore you need 2
bytepack=uint32(dataOut(1)); %since there are two separate pieces you need to combine them to a 32-bit integer
bytepack=bitshift(bytepack,16); %data(1) is the 1st half and is converted to uint32 and the data is shifted to the correct side.
z = bitor(bytepack,uint32(dataOut(2))); %data(2) is the 2nd half and bitor() is used to place this into the correct side of uint32
z = dec2bin(z,32); %create a 32-bit binary number
centigrade=bin2dec(z(2:14))*0.25; %from the MAX31855 datasheet, bits 18-31 is the temperature in celcius. These number are referenced backwards in matlab.
% I left out the 1st bit because it was the signed integer, which I didn't need.
% Multiplied by 0.25 since the datasheet says the LSB is 0.25°C.
%Check the adafruit Max31855 library for an in-depth look at processing these bits.
temp = [temp, centigrade];
time = [time, t];