PWM output with automatic fade

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

PWM output with automatic fade

#1 Post by nygma » 12 Jan 2017, 10:27

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

mkotek
Normal user
Posts: 116
Joined: 15 Dec 2015, 10:58
Location: Lomianki, Poland
Contact:

Re: PWM output with automatic fade

#2 Post by mkotek » 08 Feb 2017, 09:26

Sure, PWM command has the last parameter, that defines time for fade:
/control?cmd=PWM,<gpio>,<level>,<fade_time>
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: PWM output with automatic fade

#3 Post by nygma » 08 Feb 2017, 09:40

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

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: PWM output with automatic fade

#4 Post by nygma » 12 Feb 2017, 08:47

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?

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: PWM output with automatic fade

#5 Post by nygma » 22 Feb 2017, 11:45

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?

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: PWM output with automatic fade

#6 Post by paxi » 22 Feb 2017, 16:45

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

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: PWM output with automatic fade

#7 Post by bobbybeans » 03 Mar 2017, 12:39

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

MikeA
New user
Posts: 2
Joined: 06 Sep 2017, 07:08

Re: PWM output with automatic fade

#8 Post by MikeA » 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?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: PWM output with automatic fade

#9 Post by toffel969 » 21 Dec 2017, 20:14

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
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: PWM output with automatic fade

#10 Post by toffel969 » 21 Dec 2017, 20:17

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
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

jbishop129
New user
Posts: 5
Joined: 04 Jan 2018, 17:05

Re: PWM output with automatic fade

#11 Post by jbishop129 » 04 Jan 2018, 17:49

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.

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

Re: PWM output with automatic fade

#12 Post by grovkillen » 04 Jan 2018, 18:16

Aren't you using the command topic?

https://www.letscontrolit.com/wiki/inde ... _Reference
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:

jbishop129
New user
Posts: 5
Joined: 04 Jan 2018, 17:05

Re: PWM output with automatic fade

#13 Post by jbishop129 » 04 Jan 2018, 20:26

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")
 

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests