-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfff.m
More file actions
46 lines (33 loc) · 838 Bytes
/
fff.m
File metadata and controls
46 lines (33 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% DHT11TemperatureHumidity.mlx
% Author: Isaac Tipping
% Date: Oct 7, 2025
clc
clear
close all
% Connect to Arduino (adjust COM port if needed)
a = arduino("/dev/ttyACM0", "Uno", 'Libraries', 'Adafruit/DHTxx');
% Create DHT sensor object on digital pin D3
dhtSensor = addon(a, 'Adafruit/DHTxx', 'D3', 'DHT11');
% Initialize data storage
Time = [];
Temperature = [];
Humidity = [];
disp("Starting measurements...");
tic();
for i = 1:50
% Read data from the sensor
[tempC] = readTemperature(dhtSensor);
% Store data
Time(i) = toc();
Temperature(i) = tempC;
pause(1); % wait 1 second between readings
end
disp("Measurements complete.");
% Plot results
figure;
subplot(2,1,1);
plot(Time, Temperature, 'r-o');
title('Temperature over Time');
xlabel('Time [s]');
ylabel('Temperature [°C]');
grid on;