DHT11 Matlab code help not simulink
Show older comments
clc; clear;
s1 = serial('COM3'); time=1000; i=1;
while(i<time)
fopen(s1); fprintf(s1, 'Your serial data goes here'); out = fscanf(s1);
i=bin2dec(out(1:4));
figure; subplot(211); plot(i,'g'); axis([0,time,20,50]); title('Parameter: DHT11 Temperature'); xlabel('---> time in x*0.02 sec'); ylabel('---> Temperature'); grid
i2=bin2dec(out(5:9));
subplot(212); plot(i2,'m'); axis([0,time,25,100]); title('Parameter: DHT11 Humidity'); xlabel('---> time in x*0.02 sec'); ylabel('---> % of Humidity '); grid
fclose(s1); i=i+1; drawnow; end delete(s1); clear s;
My code is above and i bought the DHT11 sensor for an arduino project. I am getting a read out of ^$#% or something along that, differs from each reading. The DHT11 sensor is suppose to read out the temperature and the humidity. How do i get the DHT11 sensor to read out data, in what form does it read out in(binary or characters?) and how am i supposed to convert it to readable temperature and humidity levels?
Thanks, Michael M
Answers (0)
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!