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)
rules: delay
Moderators: grovkillen, Stuntteam, TD-er
Re: rules: delay
I can guess the Delay suring system boot process is not working as it should...
Have you tried with a timer?
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
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: rules: delay
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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: rules: delay
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.
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.
Re: rules: delay
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
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
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: rules: delay
I used Dev10 back when I made that blog post. Thanks for the feedback
You don't need that delay command in latest releases. It was used to make the timer work but that bug was later fixed.

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

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Who is online
Users browsing this forum: No registered users and 22 guests