rules: delay

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
kenkoknz
Normal user
Posts: 64
Joined: 03 Jul 2018, 23:46
Location: New Zealand

rules: delay

#1 Post by kenkoknz » 08 Sep 2018, 05:17

Hi, I cant seems to get delay to work. On boot, I want the onboard blue led on a nodemcu to be on for 3 sec before doing anything, so just a simple delay or pause for 3 sec.


on System#Boot do
GPIO,0,1 // set gpio0 high
GPIO,2,0 // turn on blue led
Delay 3000
GPIO,2,1 //turn off blue led
endon

The led only flash for about half sec, not 3sec. Tested with just command gpio,2,0 and gpio,2,1 and the blue led works as expected.

Whats wrong with the code? (I am assuming that the Delay function is similar to arduino c delay function)

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: rules: delay

#2 Post by papperone » 08 Sep 2018, 13:25

I can guess the Delay suring system boot process is not working as it should...
Have you tried with a timer?
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules: delay

#3 Post by grovkillen » 08 Sep 2018, 14:13

Yes that is probably the case (also, what version are you using?).
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: rules: delay

#4 Post by TD-er » 09 Sep 2018, 21:25

And don't use delay in rules.
At this moment it is not doing what you think it does.
You should start another timer and on that timer make the pin go low again.

kenkoknz
Normal user
Posts: 64
Joined: 03 Jul 2018, 23:46
Location: New Zealand

Re: rules: delay

#5 Post by kenkoknz » 10 Sep 2018, 00:57

Hi, thanks for advice, after much investigation and head scratching:
1. Delay function does not work for me in rules as TD-er said (I was using mega-20180903), however I followed with interest @Grovkillen garage door project https://testoftimes.com/2017/09/29/horm ... h-esp8266/ which uses the Delay in rules so delay obviously worked before (not sure what version he used)

on System#Boot do
Publish %sysname%/status,Booted
Publish %sysname%/IP,%ip%
pcfgpio,69,0
pcfgpio,70,0
pcfgpio,71,0
pcfgpio,72,0
Delay,5000
endon


2. Re using timer
Finally got it to work with timer:

on System#Boot do
gpio,2,0
timerSet,1,10
endon

On Rules#Timer=1 do
gpio,2,1
endon

At first the code do not work, what confused me was, I has some code further down the rules that uses gpio2, I assume it started excuting the code with gpio2 while timer 1 is still set, only way it works was when i removed the code with gpio2 downstream.

Is there like a "pause" command, ie do nothing for x seconds?

Thanks,
Ken

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules: delay

#6 Post by grovkillen » 10 Sep 2018, 07:46

I used Dev10 back when I made that blog post. Thanks for the feedback :D

You don't need that delay command in latest releases. It was used to make the timer work but that bug was later fixed.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 31 guests