Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
02669c0bb5 | ||
![]() |
b688303694 | ||
46da9841f5 |
4
init.lua
4
init.lua
@ -1,6 +1,6 @@
|
||||
-- Constants
|
||||
SSID = "Kinderland"
|
||||
APPWD = "test1234"
|
||||
SSID = "MessWLAN"
|
||||
APPWD = "UNVmpwbr6heQnMQ7ykXT"
|
||||
CMDFILE = "mqtt.lua"
|
||||
|
||||
-- Some control variables
|
||||
|
12
mqtt.lua
12
mqtt.lua
@ -1,12 +1,12 @@
|
||||
BROKER = "192.168.87.100"
|
||||
BROKER = "172.16.2.15"
|
||||
BRPORT = 1883
|
||||
BRUSER = ""
|
||||
BRPWD = ""
|
||||
CLIENTID = "ESP8266-" .. node.chipid()
|
||||
|
||||
SWITCH_PIN = 0
|
||||
SWITCH_PIN = 3
|
||||
|
||||
SWITCH_ID = 0
|
||||
SWITCH_ID = 1
|
||||
|
||||
topics = {"IoT/Watchdog", "IoT/Switch" .. SWITCH_ID}
|
||||
TOPIC_WATCHDOG = 1
|
||||
@ -82,7 +82,7 @@ function run_main_prog()
|
||||
switch_state = false
|
||||
elseif (topic == topics[TOPIC_SWITCH] and data == "switch toggle") then
|
||||
switch_state = not switch_state
|
||||
elseif (topic == topics[TOPIC_WATCHDOG] and data == "wauwau") then
|
||||
elseif (topic == topics[TOPIC_WATCHDOG] and data == "WauWau!") then
|
||||
print("9")
|
||||
tmr.alarm(4, 60000, 1, alarm)
|
||||
end
|
||||
@ -90,9 +90,9 @@ function run_main_prog()
|
||||
if (switch_state ~= old_switch_state) then
|
||||
old_switch_state = switch_state
|
||||
if (switch_state) then
|
||||
gpio.write(SWITCH_PIN, gpio.HIGH)
|
||||
else
|
||||
gpio.write(SWITCH_PIN, gpio.LOW)
|
||||
else
|
||||
gpio.write(SWITCH_PIN, gpio.HIGH)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user