PWM output with automatic fade

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
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 71 guests