Push button Dimmer

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Push button Dimmer

#1 Post by Patou » 21 May 2018, 11:13

Hello
I want to use an espeasy board to replace existing push button dimmer and be able to control also the lights from remote by Domoticz
I understood good how to do it from Domoticz (write to a GPIO defined as "PWM"), but I want to have the dimmer also working from one push button locally.
This means :
Short push on button (0.25sec) : On at the latest programmed level, second short push on button : Off
Long push on button : Light up from existing level to max level in 1 ... 2 sec seconds, long push on button : light down from existing level to zero When switch is released stay at the level.
In basic like language i can create a loop and increment/decrement a variable ... and send this variable to a GPIO defined as a pwm output but we cannot created loops in rules !!
I saw on the "Devices" the possibility to configure a switch input as a dimmer with a dim level but found no explanation about this in the forum or tutorials
Can somebody help in starting this project ?
Patou

Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Re: Push button Dimmer

#2 Post by Patou » 13 Feb 2019, 23:00

Hello
I have posted this in may last year and get no answer
Probably what i want to do is not so easy with rules based on events
But maybe somebody reads this again and knows how to do
Patou


I want to use an espeasy board to replace existing push button dimmer and be able to control also the lights from remote by Domoticz
I understood good how to do it from Domoticz (write to a GPIO defined as "PWM"), but I want to have the dimmer also working from one push button locally.
This means :
Short push on button (0.25sec) : On at the latest programmed level, second short push on button : Off
Long push on button : Light up from existing level to max level in 1 ... 2 sec, second long push on button : light down from existing level to zero When switch is released stay at the level.
In basic like language i can create a loop and increment/decrement a variable ... and send this variable to a GPIO defined as a pwm output but we cannot created loops in rules !!
I saw on the "Devices" the possibility to configure a switch input as a dimmer with a dim level but found no explanation about this in the forum or tutorials
Can somebody help in starting this project ?

Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Re: Push button Dimmer

#3 Post by Patou » 15 Feb 2019, 21:16

Hello all,
This rules works but the timerset on 1 sec is too slow is there a plan to have an instruction timerset in msec or even in 100 msec ?
Or is there an other way to introduce a delay in the rules ?

On BP-Up#State=1 do
if [BP-Up#State]=1
event,up
timerset,1,1
endif
endon

On Rules#timer=1 do
if [BP-Up#State]=1
let,2,[var#2]+100
timerset,1,1
endif
endon

Thanks in advance for a reaction

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

Re: Push button Dimmer

#4 Post by grovkillen » 15 Feb 2019, 21:46

You could use double click or long push for the button.
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:

Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Re: Push button Dimmer

#5 Post by Patou » 15 Feb 2019, 22:06

Hello
Thanks for your reaction
But I do not see how long pulse or double click will increment a variable from 0 to 4000 in let's say 100 increments ( 0,100,200,300, ... 4000) in a controlable time of about 2 to 10 sec
Please explain
Patou

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

Re: Push button Dimmer

#6 Post by grovkillen » 16 Feb 2019, 10:44

The double click will trigger faster than once a second I think.
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:

Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Re: Push button Dimmer

#7 Post by Patou » 18 Feb 2019, 01:25

Hello
I found a solution with an external NE 555 to clock a frequency of about 2... 4 Hz.
When Bp is pushed at every clock puls a variable is incremented and the result is used in a pwm command.
If the internal pwm is used range : 0-1024 and step 32 gives about 10 sec from min to max with a reasonnable resolution ( total 30 steps)
For the external multiplexer the steps are of 128 because the max is 4096 (12bit)
The unit works on the internal pwm I am waiting for the multiplexer to text

Dimmer-project.png
Dimmer-project.png (565.73 KiB) Viewed 1174 times
Rules :
On SystemBoot do
timerset,1,5
endon

On Rules#timer=1 do
let,1,0 // 1=On/down, 0=Off/Up
let,2,0 // counter max value 1024
pwm,14,0
endon

On Pulse#State=1 do
If [Bp#State]=1 and [var#2]<1024 and [var#1]=1
let,2,[var#2]+32
endif
If [Bp#State]=1 and [var#2]>0 and [var#1]=0
let,2,[var#2]-32
endif
pwm,14,[var#2]
endon

On Bp#State=1 do
If [var#1]>0
let,1,0
event,LightOff
pwm,14,0
else
let,1,1
event,LightOn
pwm,14,[var#2]
endif
endon

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

Re: Push button Dimmer

#8 Post by grovkillen » 18 Feb 2019, 05:35

Thanks for that info! :)
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests