MATLAB libraries of DHT11 sensor

88 views (last 30 days)
Sadiq Akbar
Sadiq Akbar on 20 Nov 2021
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 Comment
MathWorks MATLAB Hardware Team
Hi Sadiq,
Kindly reach out to MathWorks Technical Support to get help in resolving your query

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Nov 2021
  2 Comments
Sadiq Akbar
Sadiq Akbar on 20 Nov 2021
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by