Warning: Unsuccessful read: A timeout occurred before the Terminator was reached..

5 views (last 30 days)
delete(instrfindall);
close(instrfindall);
clear all;
clear s;
global s;
s =serial('COM3','BaudRate',9600,'DataBits',8);
set(s,'timeout',2)
% --- Outputs from this function are returned to the command line.
function varargout = dht111_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
x1 = [];
x2 = [];
global s;
time=100;
i=1;
fopen(s)
while(i<time)
fprintf(s, 'Your serial data goes here')
out = fscanf(s);
Temp(i)=str2double(out(1:4));
% disp(Temp);
x1 = [x1 Temp(i)];
plot(handles.axes1,x1);
grid on;
xlabel(handles.axes1,'Time(seconds)');
ylabel(handles.axes1,'Temperature');
title(handles.axes1,'Real Time Temperature Graph');
pause(1)
grid;
Humi(i)=str2double(out(5:9));
% disp(Humi);
x2 = [x2 Humi(i)];
plot(handles.axes5,x2);
grid on;
xlabel(handles.axes5,'Time(seconds)');
ylabel(handles.axes5,'humi');
title(handles.axes5,'Real Time Humidity Graph');
pause(1)
set(handles.edit1,'String',num2str(Temp(i)));
set(handles.edit2,'String',num2str(Humi(i)));
drawnow;
i=i+1;

Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!