Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
systemprogramming-4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eunchae Lee
systemprogramming-4
Commits
5b72395a
Commit
5b72395a
authored
1 year ago
by
Eunchae Lee
Browse files
Options
Downloads
Patches
Plain Diff
Update DHT11.c
parent
b28bc641
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DHT11.c
+28
-30
28 additions, 30 deletions
src/DHT11.c
with
28 additions
and
30 deletions
src/DHT11.c
+
28
−
30
View file @
5b72395a
...
...
@@ -117,9 +117,8 @@ void read_data()
delayMicroseconds
(
40
);
// 센서가 준비될 때까지 40ms 대기
pinMode
(
PIN
,
INPUT
);
// 센서로 부터 데이터를 받기 위한 준비가 되었음을 PIN을 input으로 설정
// 데이터 읽기
for
(
int
i
=
0
;
i
<
85
;
i
++
)
for
(
int
i
=
0
;
i
<
MAX_READING
;
i
++
)
{
count
=
0
;
// count the duration of each state
...
...
@@ -143,10 +142,9 @@ void read_data()
break
;
}
/* ignore the first 3 state changes and process every second state change to capture data bits
처음 3번은 연결상태 확인하는 handshake부분
DHT11 센서의 각 비트는 HIGH, LOW 상태 변화 페어로 전달됨
/*
처음 3번은 연결상태 확인하는 handshake부분 - 무시
DHT11 센서의 각 비트는 HIGH, LOW 상태 변화 페어로 전달함
홀수 - HIGH, 짝수 - LOW -> LOW 신호의 길이를 측정해 비트를 결정함
LOW는 비트의 시작을 알림, HIGH의 상태 길이는 비트 값을 나타냄(26-28ms:0, 70ms:1)
=> LOW 상태 이후 HIGH 상태 길이 측정하여 비트 값 결정함
...
...
@@ -187,7 +185,7 @@ void read_data()
}
// 체크섬 확인 및 데이터 출력
if
((
bit_
count
>=
40
)
&&
(
data
[
4
]
==
((
data
[
0
]
+
data
[
1
]
+
data
[
2
]
+
data
[
3
])
&
0xFF
)))
if
((
bit_
index
>=
40
)
&&
(
data
[
4
]
==
((
data
[
0
]
+
data
[
1
]
+
data
[
2
]
+
data
[
3
])
&
0xFF
)))
{
float
humidity
=
(
float
)
data
[
0
]
+
(
float
)
data
[
1
]
*
0
.
1
;
float
temperature
=
(
float
)
data
[
2
]
+
(
float
)
data
[
3
]
*
0
.
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment