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
ce96564b
Commit
ce96564b
authored
Feb 03, 2015
by
Vowstar
Browse files
Merge pull request #166 from javieryanez/patch-3
Support for versions of NodeMCU with float point
parents
cd49b767
a3e51872
Changes
1
Show whitespace changes
Inline
Side-by-side
lua_modules/dht22/dht22.lua
View file @
ce96564b
...
@@ -77,15 +77,17 @@ function M.read(pin)
...
@@ -77,15 +77,17 @@ function M.read(pin)
end
end
end
end
checksumTest
=
((
humidity
/
256
)
+
(
humidity
%
256
)
+
(
temperature
/
256
)
+
(
temperature
%
256
))
%
256
checksumTest
=
(
bit
.
band
(
humidity
,
0xFF
)
+
bit
.
rshift
(
humidity
,
8
)
+
bit
.
band
(
temperature
,
0xFF
)
+
bit
.
rshift
(
temperature
,
8
))
checksumTest
=
bit
.
band
(
checksumTest
,
0xFF
)
if
temperature
>
0x8000
then
if
temperature
>
0x8000
then
-- convert to negative format
-- convert to negative format
temperature
=
-
(
temperature
-
0x8000
)
temperature
=
-
(
temperature
-
0x8000
)
end
end
if
checksum
~=
checksumTest
then
-- conditions compatible con float point and integer
humidity
=
-
1
if
(
checksumTest
-
checksum
>=
1
)
or
(
checksum
-
checksumTest
>=
1
)
then
humidity
=
nil
end
end
end
end
...
...
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