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
56daed7b
Commit
56daed7b
authored
Jan 11, 2015
by
zeroday
Browse files
Merge pull request #88 from baracudaz/master
DS18B20 module examples
parents
a0f5559a
65257478
Changes
2
Hide whitespace changes
Inline
Side-by-side
lua_modules/ds18b20/ds18b20-example.lua
0 → 100644
View file @
56daed7b
t
=
require
(
"ds18b20"
)
-- ESP-01 GPIO Mapping
gpio0
=
3
gpio2
=
4
t
.
setup
(
gpio0
)
addrs
=
t
.
addrs
()
if
(
addrs
~=
nil
)
then
print
(
"Total DS18B20 sensors: "
..
table
.
getn
(
addrs
))
end
-- Just read temperature
print
(
"Temperature: "
..
t
.
read
()
..
"'C"
)
-- Don't forget to release it after use
t
=
nil
ds18b20
=
nil
package.loaded
[
"ds18b20"
]
=
nil
lua_modules/ds18b20/ds18b20-web.lua
0 → 100644
View file @
56daed7b
require
(
'ds18b20'
)
port
=
80
-- ESP-01 GPIO Mapping
gpio0
,
gpio2
=
3
,
4
ds18b20
.
setup
(
gpio0
)
srv
=
net
.
createServer
(
net
.
TCP
)
srv
:
listen
(
port
,
function
(
conn
)
conn
:
send
(
"HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n"
..
"<!DOCTYPE HTML>"
..
"<html><body>"
..
"<b>ESP8266</b></br>"
..
"Temperature : "
..
ds18b20
.
read
()
..
"<br>"
..
"Node ChipID : "
..
node
.
chipid
()
..
"<br>"
..
"Node MAC : "
..
wifi
.
sta
.
getmac
()
..
"<br>"
..
"Node Heap : "
..
node
.
heap
()
..
"<br>"
..
"Timer Ticks : "
..
tmr
.
now
()
..
"<br>"
..
"</html></body>"
)
conn
:
on
(
"sent"
,
function
(
conn
)
conn
:
close
()
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