image thumbnail
from Read LM73 Temperature Sensor by lazaro camargo
reading a LM73 Temperature Sensor using a microcontroller PIC16F877 and display the plot with Matlab

lm73.m
% Reading of a LM73 sensor temperature
% using a microcontroller PIC16F877 
% Starting: August 16, 2007
% Author's Data: Lazaro Aparecido Pires de Camargo

% National Institute of Research Space (INPE)
% Sao Jose dos Campos, Brasil
% Email: lazaro@dae.inpe.br

s1 = serial('COM1');                            %define serial port
s1.BaudRate=9600;                               %define baud rate

fopen(s1);                                      %open serial port

clear data;

for i= 1 :60                                    %acquisition of 100 points
    
    data(i)=(str2double(fscanf((s1)))/100);     %read sensor
    
    disp(sprintf('Temperature= %3.2f oC' ,data(i)))      
  
end

plot(data);                                     %plot 100 points
title('LM73 Temperature Sensor');
xlabel('number of points');
ylabel('Temperature oC');
axis([0 60 10 40]);


fclose(s1);                                     %close serial port

Contact us at files@mathworks.com