serialprintln "created with esp basic 1.76"
interrupt 0 [check]
wait
[check]
serialprintln io(pi,0)
if io(pi,0) = 1 then io(po,d4,0)
if io(pi,0) = 0 then io(po,d4,1)
if io(pi,0) = 1 then wget("172.16.0.112/msg?stat=0")
if io(pi,0) = 0 then wget("172.16.0.112/msg?stat=1")
wait
This works much smoother. Remember to adjust the IP on the last 2 lines.
And with a small adjustment on the receiving-side it works as a on-off remote switch.
serialprintln "created with esp basic 1.76"
let status2 = 0
po 2 status2
msgbranch [doit]
wait
[doit]
msgget stat s
if s=1 then goto [doit_exit]
if status2 = 0 then goto [doit_make_hi]
let status2 = 0
po 2 status2
goto [doit_exit]
[doit_make_hi]
let status2 = 1
po 2 status2
[doit_exit]
msgreturn s
wait