Hello
I've been trying to make a PWM output based on seconds counting 0-59 gradually increasing the PWM output as the seconds count increases.
In rules, I tried (for example)
On %syssec% do
if [%syssec%]=10
PWM,16,100
elseif [%syssec%]=30
PWM,15,512
endif
endon
So far I cannot make it dance - gpio16 does not output any voltage.
By contrast, I can do plenty with
On temperature#temp do
etc,
etc
Can you please guide me as to where I have gone wrong?
I'm using NTP time - is that an issue? Can I capture seconds another way?
Thanks
Use %syssec% to increment PWM Output
Moderators: grovkillen, Stuntteam, TD-er
Re: Use %syssec% to increment PWM Output
You can't act on such events as there will not be any event named "12" or whatever the current seconds value is.
I think you should start a looptimer.
See: https://espeasy.readthedocs.io/en/lates ... oop-timers
N.B. the system variables (wrapped in %...%) do not need []
N.B.2
Not sure if GPIO 16 (on ESP8266) can do PWM as it is a special pin with limited capabilities.
I think you should start a looptimer.
See: https://espeasy.readthedocs.io/en/lates ... oop-timers
Code: Select all
On System#Boot do //When the ESP boots, do
looptimerset_ms,1,1000 // Start loop timer 1, 1000 msec interval
endon
On Rules#Timer=1 do
if %syssec%=10
PWM,16,100
elseif %syssec%=30
PWM,15,512
endif
Endon
N.B.2
Not sure if GPIO 16 (on ESP8266) can do PWM as it is a special pin with limited capabilities.
Re: Use %syssec% to increment PWM Output
@TD-er
Thanks so much for your reply
The output (to a voltmeter) works as expected. It's perfect.
I'll read up on looptimers, I'm sure I will have plenty of applications for it.
I have noted your comment about system variables.
Also PWM works with ESP8266 / GPIO16 output. This is the only GPIO that has a pulldown, so I'm glad it works.
Again thanks so much, it is appreciated.
Thanks so much for your reply
The output (to a voltmeter) works as expected. It's perfect.
I'll read up on looptimers, I'm sure I will have plenty of applications for it.
I have noted your comment about system variables.
Also PWM works with ESP8266 / GPIO16 output. This is the only GPIO that has a pulldown, so I'm glad it works.
Again thanks so much, it is appreciated.
Re: Use %syssec% to increment PWM Output
Good to know PWM still is working on GPIO 16. (on ESP8266)
However it isn't the only one with a pull-down resistor on ESP8266.
GPIO-15 also has a pull-down resistor (and needs to be kept pulled-down during boot)
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266
However it isn't the only one with a pull-down resistor on ESP8266.
GPIO-15 also has a pull-down resistor (and needs to be kept pulled-down during boot)
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266
Re: Use %syssec% to increment PWM Output
Of course - I should have remembered, It's actually more logical to use GPIO15 as a pulldown, especially at Hardware Boot because there is no high pulse.
PWM works nicely with GPIO15 as well.
GPIO16 can be set as pull-down in your Hardware Menu. I find it a good visual reminder.
PWM works nicely with GPIO15 as well.
GPIO16 can be set as pull-down in your Hardware Menu. I find it a good visual reminder.
Re: Use %syssec% to increment PWM Output
That's because there are pull-up and -down resistors inside the ESP8266
On the Hardware tab I only added those options that are available as internal pull resistor.
However there is a number of boot state pins which need to be in a specific state to boot the ESPEasy 'sketch'.
- GPIO-0 needs to be high
- GPIO-2 needs to be high
- GPIO-15 needs to be low
So these 3 pins will have external pull resistors soldered to the ESP8266.
Either on the PCB or in the encapsulated module (e.g. the ESP-12S has them in the encapsulated module)
But these resistors must be present or else the ESP will not boot.
Whatever is configured on the Hardware tab is set after booting by ESPEasy.
GPIO-1 (TX pin) is a bit odd as it might prevent the ESP8266 from booting if it is pulled low during boot.
On the Hardware tab I only added those options that are available as internal pull resistor.
However there is a number of boot state pins which need to be in a specific state to boot the ESPEasy 'sketch'.
- GPIO-0 needs to be high
- GPIO-2 needs to be high
- GPIO-15 needs to be low
So these 3 pins will have external pull resistors soldered to the ESP8266.
Either on the PCB or in the encapsulated module (e.g. the ESP-12S has them in the encapsulated module)
But these resistors must be present or else the ESP will not boot.
Whatever is configured on the Hardware tab is set after booting by ESPEasy.
GPIO-1 (TX pin) is a bit odd as it might prevent the ESP8266 from booting if it is pulled low during boot.
Re: Use %syssec% to increment PWM Output
@TD-er Thank you - I appreciate the additional comments above.
Who is online
Users browsing this forum: No registered users and 34 guests