As the title says... Chat on...

User avatar
By VikingGuy
#44838 NODEMCU Board Running NodeMCU

I am controlling a relay. I can tun on the relay by interrupt into a pin or by UDP server /client. Regardless of what of the two ways turn it on (or off), the ESP sets an output that drives the relay.

GPIO setting for input pin:

gpio.mode(6, gpio.INT, gpio.PULLUP)
gpio.trig(6, 'both', debounce(onChangeLight) )

All works well.

I have an alarm set to 'timeout' after 30 minutes. At this time, the relay is switched off.

For some reason, it then ignores the GPIO input pin from that point forward (until I reset the device).

The only way to turn the relay on (or off) from that point forward is by the client /server (over the network).
The input pin is ignored.
User avatar
By TerryE
#44873 What's your debounce code??
User avatar
By VikingGuy
#44923
TerryE wrote:What's your debounce code??



function debounce (func)

return function (...)
now = tmr.now()
if now - last < 200000 then
return end

last = now
return func(...)
end
end

function onChangeLight ()

buttonIn = gpio.read(6)

if(buttonIn == 0) then

if (_G.LightStatus == 1) then
TurnOff()
else
dofile("ON.lua")
SetTimer()

end

end
end
User avatar
By TerryE
#45006 Same reason as another GPIO Q that I just answered. Triggers are now delivered at user task level not ISR. The old ISR approach broke all the rules. Use a recent dev build either your own make or a cloud builder one and don't state in a loop for 200mSec. You have to return control to the SDK for any triggers to be delivered. Have a read of my FAQ below to seee how the event system works.