フィルターのクリア

Accurate Measurements with DHT11 and Arduino via MATLAB

29 ビュー (過去 30 日間)
B
B 2013 年 5 月 10 日
編集済み: Victor 2023 年 6 月 29 日
I have a DHT11 sensor connected to an Arduino UNO. I can get consistent (and expected) data values through the Arduino software by following this tutorial. However, I'd like to replicate the same data collection with MATLAB.
I'm stuck on how I can take the DHT11's digital signal and "break it down" into its component bits so that they can be identified and used properly. From my understanding, the DHT11's signal is 40 bits, and is set up so that the first 16 relate to the humidity detected, the following 16 are for temperature, and the last 8 are the checksum.
Is it possible to separate a digital signal into a collection of bits? How can I use MATLAB to get measurements from this sensor?
  4 件のコメント
Ishaan Chandratreya
Ishaan Chandratreya 2017 年 9 月 24 日
I am wishing to read DHT11 using a raspberry pi on MATLAB. Could anyone help me with that? I have already tried reading GPIO pin as sensor transmits data, and have tried connecting rx to data, and using serialdev of raspberry pi package
Jan Schäfer
Jan Schäfer 2023 年 1 月 30 日
You must load the Adafruit/DHTxx library in to Matlab. After this you can write a = arduino('COM12', 'Uno', 'Libraries', 'Adafruit/DHTxx');
readHumdity(a,Pin)
readTemperature(a,Pin)
good luck

サインインしてコメントする。

採用された回答

B
B 2013 年 5 月 17 日
My final code, for readings once a minute:
s = serial('COM3'); %Connected to COM3
set(s,'BaudRate',9600);
set(s,'Timeout', 65); %sensor will timeout after 65 seconds
fopen(s);
x = 1:1:60; %readings over the span of one hour
for i=1:length(x)
y(i) = fscanf(s, '%f', 6);
z(i) = fscanf(s, '%f', 6);
i
end
fclose(s);
% Plot data from arduino
plot3(x,y,z)
title('temperature v. humidity v. time');
xlabel('time');
ylabel('humidity');
zlabel('temperature');
  1 件のコメント
Philip Nahmias
Philip Nahmias 2018 年 7 月 24 日
I am faced with a similar situation like you and I am a bit confused on how you were able to resolve your situation. First of all did you have an arduino package on matlab or did you just define the connection as serial? Cause I was under the impression I had to download some arduino package and I haven't managed to make it work.

サインインしてコメントする。

その他の回答 (1 件)

Victor
Victor 2023 年 6 月 29 日
編集済み: Victor 2023 年 6 月 29 日
clear
s = serialport('COM3',9600)
time=100;
subplot(211)
h1=animatedline('Color','r');axis([1,time,10,40]),grid on
ylabel('Temperatura (°C)')
subplot(212)
h2=animatedline('Color','b');axis([1,time,40,80]),grid on
xlabel('iteraciones'),ylabel('Humedad (%)')
for i=1:time
out = read(s,7,'string');
if rem(i,2) == 0
Humi=str2double(out);
addpoints(h2,i,Humi)
else
Temp=str2double(out);
addpoints(h1,i,Temp)
end
end

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by