Chat freely about anything...

User avatar
By Wjflier2
#33141 For reference, this seems to do the trick for long tmr.delay(time) where time is 900000000=about 15 minutes.
my code cycles 4 relays for lawn sprinkler control.

--turn relay on
gpio.write(led4, gpio.HIGH);
--hold program for set period of time
tmr.delay(time)
--turn relay off
gpio.write(led4, gpio.LOW);
--reconnect wifi
tmr.wdclr()
wifi.setmode(wifi.STATION)
wifi.sta.config("xxxxxx","xxxxxxxxxxx")
print(wifi.sta.getip())
User avatar
By freekenzo
#43051 My solution to the same problem


if(_GET.pin == "ON1")then

gpio.write(Relay1, gpio.HIGH);
timestamp = 0
tmr.alarm(0, 5000, 1, function() timestamp = timestamp + 1

if timestamp >=1 and timestamp < 2 then

gpio.write(Relay1, gpio.LOW);
gpio.write(Relay2, gpio.HIGH);

elseif timestamp >=2 and timestamp < 3 then print("2")

gpio.write(Relay2, gpio.LOW);
gpio.write(Relay3, gpio.HIGH);

elseif timestamp >=3 and timestamp < 4 then print("3")

gpio.write(Relay3, gpio.LOW);
gpio.write(Relay4, gpio.HIGH);

elseif timestamp >=4 and timestamp < 5 then print("4")

gpio.write(Relay4, gpio.LOW);

end
end )



elseif(_GET.pin == "OFF1")then
tmr.stop(0);
gpio.write(Relay1, gpio.LOW);
gpio.write(Relay2, gpio.LOW);
gpio.write(Relay3, gpio.LOW);
gpio.write(Relay4, gpio.LOW);