MATLAB libraries of DHT11 sensor

조회 수: 56(최근 30일)
Sadiq Akbar
Sadiq Akbar 2021년 11월 20일
If the DHT11 sensor is connected to my Arduino and I want to read the temperature and humidity data directly from that pin of Arduino to which it is attached without the help of any arduino code, is there any Matlab library available for that?
  댓글 수: 1
MathWorks MATLAB Hardware Team
MathWorks MATLAB Hardware Team 2021년 11월 22일
Hi Sadiq,
Kindly reach out to MathWorks Technical Support to get help in resolving your query

댓글을 달려면 로그인하십시오.

답변(1개)

Walter Roberson
Walter Roberson 2021년 11월 20일
  댓글 수: 2
Sadiq Akbar
Sadiq Akbar 2021년 11월 20일
I have modefied that code like below:
clc
clear all
delete(instrfindall);
close(instrfindall);
s = serial('COM5');
time=100;
i=1;
while(i<time)
fopen(s)
fprintf(s, 'Your serial data goes here')
out = fscanf(s)
Temp(i)=str2double(out(1:4));% Temp(i)=str2num(out(1:4));
subplot(211);
disp(Temp(i))% By Me
plot(Temp(i),'g');% plot(Temp,'g');
axis([0,time,10,50]);
title('Parameter: DHT11 Temperature');
xlabel('time');
ylabel('Temperature');
grid
Humi(i)=str2double(out(5:9));
subplot(212);
disp(Humi(i))% By Me
plot(Humi(i),'m');
axis([0,time,10,100]);
title('Parameter: DHT11 Humidity');
xlabel('time');
ylabel('% of Humidity');
grid
fclose(s)
i=i+1;
drawnow;
end
delete(s)
clear s
But when I execute it in debugger mode, and I check the variable out, tooltp shows: out: 1 x 20 char=
Temperature: 18.00
Likewise when I check Temp(i), the debgger shows in tooltip as:
Temp: 1 x 20 double=
NaN
Also no any graph is displayed.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by