Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
4ac5aba2
Commit
4ac5aba2
authored
Apr 06, 2015
by
Vowstar
Browse files
Merge pull request #338 from MarsTechHAN/patch-1
Really Fix the BUGs, add come comment
parents
560ad8e0
9df94c7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lua_modules/dht_lib/dht_lib.lua
View file @
4ac5aba2
...
@@ -8,10 +8,15 @@
...
@@ -8,10 +8,15 @@
-- ***************************************************************************
-- ***************************************************************************
--Support list:
--Support list:
--DHT11 Tested ->read11
--DHT21 Not Tested->read22
--DHT22 Tested->read22
--DHT11 Tested
--DHT21 Not Test yet
--DHT22(AM2302) Tested
--AM2320 Not Test yet
--Output format-> Real temperature times 10(or DHT22 will miss it float part in Int Version)
--For example, the data read form DHT2x is 24.3 degree C, and the output will be 243
---------------the data read form DHT1x is 27 degree C, and the output will be 270
--==========================Module Part======================
--==========================Module Part======================
local
moduleName
=
...
local
moduleName
=
...
local
M
=
{}
local
M
=
{}
...
@@ -99,7 +104,12 @@ local function bit2DHT11()
...
@@ -99,7 +104,12 @@ local function bit2DHT11()
if
(
checksum
~=
humidity
+
temperature
)
then
if
(
checksum
~=
humidity
+
temperature
)
then
humidity
=
nil
humidity
=
nil
temperature
=
nil
temperature
=
nil
else
humidity
=
humidity
*
10
-- In order to universe the DHT22
temperature
=
temperature
*
10
end
end
end
end
---------------------------Convert the bitStream into Number through DHT22 Ways--------------------------
---------------------------Convert the bitStream into Number through DHT22 Ways--------------------------
...
@@ -144,7 +154,7 @@ local function bit2DHT22()
...
@@ -144,7 +154,7 @@ local function bit2DHT22()
end
end
---------------------------Check out the data--------------------------
---------------------------Check out the data--------------------------
----Auto Select the DHT11/DHT22
B
y check the byte[1] && byte[3]
AND
---
----Auto Select the DHT11/DHT22
b
y check
ing
the byte[1]
==0
&& byte[3]
==0
---
---------------Which is empty when using DHT11-------------------------
---------------Which is empty when using DHT11-------------------------
function
M
.
read
(
pin
)
function
M
.
read
(
pin
)
...
@@ -172,7 +182,7 @@ function M.read(pin)
...
@@ -172,7 +182,7 @@ function M.read(pin)
end
end
end
end
--------------API for geting the data out------------------
function
M
.
getTemperature
()
function
M
.
getTemperature
()
return
temperature
return
temperature
...
@@ -181,5 +191,5 @@ end
...
@@ -181,5 +191,5 @@ end
function
M
.
getHumidity
()
function
M
.
getHumidity
()
return
humidity
return
humidity
end
end
-------------Return Index------------------------------------
return
M
return
M
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment