E2 Is there a way to apply interval to a specific part of code?

Hello:) I need to ping E2 chip or chips every 5 seconds. I tried doing it like:

interval(5000)
dsSend(“pingchip”, “group”, “”)
if(dsClk) {e2 online} else {offline}
But this code is strange, cause it affects another part of code. What is another way to go around it? Maybe something with functions? Or separate chip, that will ping chips? Thanks in advance!


interval(5000)

if (clk()) {
    dsSend(“pingchip”, “group”, “”)
} elseif(dsClk) {
    e2 online
} else {
    offline
}

Anything in clk() only happens when the e2 is run by interval. I’m not sure E2s are triggered by data signals from themselves, though.

I may be wrong, but you can use timers


timer("5sec", 5000)
if (clk("5sec")) {
    # code
    timer("5sec", 5000)
}

(last time touched E2 ~2 years ago)

Just tested it and it works