Data Sheet

23
gpio.write(1,gpio.LOW)
end
end
Lesson12: One Wire Waterproof Temperature Sensor
This sealed digital temperature probe lets you precisely measure temperatures in wet
environments with a simple 1-Wire interface.
Material:
Crowtail- ESP8266 NodeMCU x 1
Crowtail- One wire Waterproof Temperature Sensor x 1
Hardware Connection
Open the LuaLoader, click the “Upload File…” to choo se ESP8266 NodeM CU kit demo
code -> P12_DS18B20_One_Wire_Waterproof_Temperature_Sensor -> ds18b20.lua. After the
upload completed then click “Download to download the ds18b20.lua file. Then click the
“Upload File…”choose the init .lua in the same fol der, downlo ad it.
Dem o Code:
Ds18b20 .lua:
-- Se t mo du l e na m e as pa r a m e t e r of re q u i re
lo c a l mo dn a m e = .. .
lo c a l M = {}
_G [ m o d n a m e ] = M
-- - - - - - - - - - - - - - - - - - -- - -- - -- - -- - -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - -- - -- - -
-- Lo c a l us e d va r i a b l e s
-- - - - - - - - - - - - - - - - - - -- - -- - -- - -- - -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - -- - -- - -
-- DS 1 8 B 2 0 dq pi n
lo c a l pi n = ni l
-- DS 1 8 B 2 0 de f a u l t pi n
lo c a l de f a u lt P i n = 1
-- - - - - - - - - - - - - - - - - - -- - -- - -- - -- - -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - -- - -- - -
-- Lo c a l us e d mo du l e s
-- - - - - - - - - - - - - - - - - - -- - -- - -- - -- - -- - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - -- - -- - -
-- Ta b l e mo du l e
lo c a l ta b l e = ta b le
-- St r in g mo du l e
lo c a l st r i ng = st r i ng
-- On e wi re mo du l e