Data Sheet
41
there is not occupied. This lesson is designed primarily a remote indicator toilet, do not need to
go to the toilet can also know whether someone is using the toilet, this greatly facilitates our
daily life. Of course, this design idea can be applied in many other occasions of life.
Material:
Crowtail- ESP8266 NodeMCU x 2
Crowtail- Magnetic Switch x1
Crowtail- LED x1
Hardware Connection
Open the LuaLoader, click the “Upload File…”cho ose ESP826 6 No deMCU kit demo code
-> P19_Wireless_Toliet_LED_Idicator-> Client->init.lua. After the upload completed then click
“Download ” to download the init.lua file.
Note!!! This init.lua file uploaded should choose the NodeMCU which connect with Magnetic
Switch.
Then open the LuaLoader, choose the correct serial port for the NodeMCU which connect with
two indicator LED click the “Upload File…”choo se ESP8266 NodeM CU kit demo code ->
P19_Wireless_Toliet_LED_Idicator-> Server->init.lua. After the upload completed then click
“Download ” to download the init.lua file.
Client:
-- ESP8266 Client
print("ESP8266 Client1")
wifi.sta.disconnect()
wifi.setmode(wifi.STATION)
wifi.sta.config("test","12345678") -- connecting to server
wifi.sta.connect()
print("Looking for a connection")
pin=1
gpio.mode(pin, gpio.INPUT,gpio.FLOAT)
pin_value=0
tmr.alarm(1, 2000, 1, function()
if(wifi.sta.getip()~=nil) then
tmr.stop(1)
tmr.start(2)
print("Connected!")
print("Client IP Address:",wifi.sta.getip())