Page 1 of 1

PWM output with automatic fade

Posted: 12 Jan 2017, 10:27
by nygma
Hi All,

I know this has been ask before, but I did not get a clear answer on the topic.
I would like to use ESP Easy to control LED strip using the PWM output of the ESP. Is it possible to set up ESP Easy to automatically fade to a new value instead of setting it immediately on the output?

Regards,
Csongor

Re: PWM output with automatic fade

Posted: 08 Feb 2017, 09:26
by mkotek
Sure, PWM command has the last parameter, that defines time for fade:
/control?cmd=PWM,<gpio>,<level>,<fade_time>

Re: PWM output with automatic fade

Posted: 08 Feb 2017, 09:40
by nygma
mkotek wrote:Sure, PWM command has the last parameter, that defines time for fade:
/control?cmd=PWM,<gpio>,<level>,<fade_time>
Thank you very much, I did not know about this. If I have an RGB strip connected to the ESP, can I just send out 3 messages for the 3 pins to get a color fade?

Csongor

Re: PWM output with automatic fade

Posted: 12 Feb 2017, 08:47
by nygma
mkotek wrote:Sure, PWM command has the last parameter, that defines time for fade:
/control?cmd=PWM,<gpio>,<level>,<fade_time>
I am using this with a long delay know, like /control?cmd=pwm,12,1023,10000. But it seem this command keeps the ESP locked and if I send another pwm command it is not getting executed. Any suggestions?
The ESP is controlling some LED strips and I use this long delay to fade some individual strips in and out. But when I send a pwm,12,0 out, it takes time until the LED goes out. Also how can I use this to control a RGB strip?

Re: PWM output with automatic fade

Posted: 22 Feb 2017, 11:45
by nygma
Hi All,

I am posting this again hopeing somebody reads it and can answer:
I am using the pwm fade with a long delay know, like /control?cmd=pwm,12,1023,10000. But it seem this command keeps the ESP locked and if I send another pwm command it is not getting executed. Any suggestions? Is there a way to tell ESP Easy to stop a current pwm cycle?
The ESP is controlling some LED strips and I use this long delay to fade some individual strips in and out. But when I send a pwm,12,0 out, it takes time until the LED goes out. Also how can I use this to control a RGB strip?

Re: PWM output with automatic fade

Posted: 22 Feb 2017, 16:45
by paxi
Espeasy is a single threaded system and the fade runs in a simple loop, indeed it can't do anything else until the fade is done.

But there has been something worked out for RGBs, you want to read this:
viewtopic.php?f=6&t=2395&hilit=Rgbw
viewtopic.php?f=2&t=2582
https://github.com/ddtlabs/ESPEasy-Plugin-Lights

Re: PWM output with automatic fade

Posted: 03 Mar 2017, 12:39
by bobbybeans
what build is this in? I would assume this works with milight plugin? also is there a max time for it in seconds? because I would most likely have this setup for an alarm clock for fade in within 10 minutes

Re: PWM output with automatic fade

Posted: 21 Dec 2017, 20:01
by MikeA
The <fade-time> seems to be ignored for me??

For example;
http://192.168.1.105/control?cmd=pwm,2,512 and
http://192.168.1.105/control?cmd=pwm,2,512,10
both take the led up to half brightness instantaneously.

Any suggestions?

Re: PWM output with automatic fade

Posted: 21 Dec 2017, 20:14
by toffel969
MikeA wrote: 21 Dec 2017, 20:01 The <fade-time> seems to be ignored for me??

For example;
http://192.168.1.105/control?cmd=pwm,2,512 and
http://192.168.1.105/control?cmd=pwm,2,512,10
both take the led up to half brightness instantaneously.

Any suggestions?
10= 10msec, I doubt you can see the difference, try values from 1000=1 sec

Re: PWM output with automatic fade

Posted: 21 Dec 2017, 20:17
by toffel969
Maybe somebody ( with more coding abilities than me) can adapt the logic used for long pulse command to make a non-blocking pwm fade command

Re: PWM output with automatic fade

Posted: 04 Jan 2018, 17:49
by jbishop129
Sorry to resurrect an old thread. Discovered here that you can pass the fade-time parameter... that saved me a ton of ugly code doing it externally, thank you! I have this working just fine from an http request, i.e:

Code: Select all

http://ipaddress/control?cmd=pwm,14,1023,10000
will fade on my strip LEDs over 10 seconds. Works beautifully. Is there any way to pass that fade-on parameter via MQTT? I have no trouble passing an INT value to control that PWM pin via MQTT, but have yet to figure out if it's possible to send the fade. I tried sending the string via

Code: Select all

ESP/PWM/14 1023,10000
but the LEDs just pop on immediately, and in the ESPeasy log, I see it only interpreted the "1023" portion. I presume this is because it's only able to receive an INT, so it just parsed it. But, if there's a way, please let me know! I find MQTT to be more robust and faster than sending http GETs.

Re: PWM output with automatic fade

Posted: 04 Jan 2018, 18:16
by grovkillen
Aren't you using the command topic?

https://www.letscontrolit.com/wiki/inde ... _Reference

Re: PWM output with automatic fade

Posted: 04 Jan 2018, 20:26
by jbishop129
Thanks @grovkillen with a little fiddling I got it right. Here's my answer in case anyone else has the same question:
for my example, my ESP is "ESPdimmer", and I am sending to GPIO 14 to fade to 100% (pwm 1023), over 5 seconds time

Publish to topic: ESPdimmer/cmd
Payload: "pwm,14,1023,5000"

For additional verbose in context, I'm sending this from OpenHAB. So, my .items file has:

Code: Select all

String LEDstripDim {mqtt=">[mosquitto:ESPdimmer/cmd:command:*:default]"} 
and my .rules has:

Code: Select all

then
   LEDstripDim.sendCommand("pwm,14,1023,5000")