Help read temperature data from MAX6675 sensor connected to Arduino
We have a k-type thermocouple that is connected to the MAX6675 board that is then connected to our arduino mega 2560 which is connected to matlab. The SO pin is in D42, the SCK is in D52, the CS pin is in D50, the VCC is connected to the 5Volts and the GND is connected to the ground. The code we were using so far only is outputting 0 no matter what we try. We know the sensor is working after testing it on the arduino ide software, so there is something wrong with our code and how we are sending/recieving data from the arduino. Any help is apperciated. This code was from another post here on matlab, we think the issue is with datOut, it only has been 0 the whole time we have been testing with it.
% KTYPE.m This example is based on the reference manual of the MAX6675 amplifier
% LED Versuch
clear all, close all
%ComPort = getAvailableComPort
a = arduino(‘COM3′,’Uno’,’Libraries’,’SPI’);
dev = device(a,’SPIChipSelectPin’,’D8′);
MAX6675 = device(a,’SPIChipSelectPin’,’D10′);
tmax= 30;
fs = 1;
dt = 1/fs;
t = [dt:dt:tmax];
il = length(t);
T = zeros(il,1);
dummy = [uint8(0),uint8(0)];
for i=1:il
datOut = writeRead(MAX6675,dummy); % Read MAX6675
pause(0.5)
BINR = [dec2bin(datOut(1),8), dec2bin(datOut(2),8)]; % Show the bits of the read
DECR = bin2dec(BINR);
DECT = bitshift(DECR,-3); % Shift by 3 bits to the right
BINT = dec2bin(DECT); % Just to show the change
MP = 255/1023.75; % Reading 0 means 0°C,
% Reading 255 its hot as 1023.75°C
T(i,1) = MP*DECT; % Factor to get °C
disp(T(i,:))
endWe have a k-type thermocouple that is connected to the MAX6675 board that is then connected to our arduino mega 2560 which is connected to matlab. The SO pin is in D42, the SCK is in D52, the CS pin is in D50, the VCC is connected to the 5Volts and the GND is connected to the ground. The code we were using so far only is outputting 0 no matter what we try. We know the sensor is working after testing it on the arduino ide software, so there is something wrong with our code and how we are sending/recieving data from the arduino. Any help is apperciated. This code was from another post here on matlab, we think the issue is with datOut, it only has been 0 the whole time we have been testing with it.
% KTYPE.m This example is based on the reference manual of the MAX6675 amplifier
% LED Versuch
clear all, close all
%ComPort = getAvailableComPort
a = arduino(‘COM3′,’Uno’,’Libraries’,’SPI’);
dev = device(a,’SPIChipSelectPin’,’D8′);
MAX6675 = device(a,’SPIChipSelectPin’,’D10′);
tmax= 30;
fs = 1;
dt = 1/fs;
t = [dt:dt:tmax];
il = length(t);
T = zeros(il,1);
dummy = [uint8(0),uint8(0)];
for i=1:il
datOut = writeRead(MAX6675,dummy); % Read MAX6675
pause(0.5)
BINR = [dec2bin(datOut(1),8), dec2bin(datOut(2),8)]; % Show the bits of the read
DECR = bin2dec(BINR);
DECT = bitshift(DECR,-3); % Shift by 3 bits to the right
BINT = dec2bin(DECT); % Just to show the change
MP = 255/1023.75; % Reading 0 means 0°C,
% Reading 255 its hot as 1023.75°C
T(i,1) = MP*DECT; % Factor to get °C
disp(T(i,:))
end We have a k-type thermocouple that is connected to the MAX6675 board that is then connected to our arduino mega 2560 which is connected to matlab. The SO pin is in D42, the SCK is in D52, the CS pin is in D50, the VCC is connected to the 5Volts and the GND is connected to the ground. The code we were using so far only is outputting 0 no matter what we try. We know the sensor is working after testing it on the arduino ide software, so there is something wrong with our code and how we are sending/recieving data from the arduino. Any help is apperciated. This code was from another post here on matlab, we think the issue is with datOut, it only has been 0 the whole time we have been testing with it.
% KTYPE.m This example is based on the reference manual of the MAX6675 amplifier
% LED Versuch
clear all, close all
%ComPort = getAvailableComPort
a = arduino(‘COM3′,’Uno’,’Libraries’,’SPI’);
dev = device(a,’SPIChipSelectPin’,’D8′);
MAX6675 = device(a,’SPIChipSelectPin’,’D10′);
tmax= 30;
fs = 1;
dt = 1/fs;
t = [dt:dt:tmax];
il = length(t);
T = zeros(il,1);
dummy = [uint8(0),uint8(0)];
for i=1:il
datOut = writeRead(MAX6675,dummy); % Read MAX6675
pause(0.5)
BINR = [dec2bin(datOut(1),8), dec2bin(datOut(2),8)]; % Show the bits of the read
DECR = bin2dec(BINR);
DECT = bitshift(DECR,-3); % Shift by 3 bits to the right
BINT = dec2bin(DECT); % Just to show the change
MP = 255/1023.75; % Reading 0 means 0°C,
% Reading 255 its hot as 1023.75°C
T(i,1) = MP*DECT; % Factor to get °C
disp(T(i,:))
end arduino, max6675, thermocouple MATLAB Answers — New Questions