Esp-12 i.c.m Rotary encoder

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
19roland70
New user
Posts: 7
Joined: 18 Mar 2017, 12:22

Esp-12 i.c.m Rotary encoder

#1 Post by 19roland70 » 08 Apr 2017, 13:43

Is it possible to use a rotery encoder with the esp ?
I have written a script in Lua and Domoticz .
The script works and de led dims from 100 to 0 %.
Now I want the use an esp with a rotary encoder because i can use the as dimmer.
Are there more peolple that use the Rotary with the esp?
I think it's to slow because the most rotary's works with interups.
If this is to slow then I can Use a pic controller and connect this to the esp with rx/tx
what is the best I can do?

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

Re: Esp-12 i.c.m Rotary encoder

#2 Post by toffel969 » 08 Apr 2017, 21:25

It works with a 10k ohm potentiometer on analog input
For example led o gpio 12
In rules:

On analog#analog do
Pwm 12,[analog#analog]
Endon

Lag depends on sensor delayinI analog device + message delay in advanced tab
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

19roland70
New user
Posts: 7
Joined: 18 Mar 2017, 12:22

Re: Esp-12 i.c.m Rotary encoder

#3 Post by 19roland70 » 09 Apr 2017, 09:40

The problem with a potmeter is that when I used my Phone or iPad to dim the bulb that the state of the potmeter not chanched.
With a Rotary is the state not important .

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

Re: Esp-12 i.c.m Rotary encoder

#4 Post by toffel969 » 10 Apr 2017, 09:18

You can work around this though with a local button for example, then storing a auto value in Dummy device (in the example task 3)

Code: Select all

On analog#analog do
if [dummy#local]=1 
pwm 12,[Analog#Analog]
endif 
Endon


on button#switch=1 do
if [dummy#local]=1
taskvalueset 3,1,0
else 
taskvalueset 3,1,1
endif
endon

On toggle_auto do 
if [dummy#local]=1
taskvalueset 3,1,0
else 
taskvalueset 3,1,1
endif
endon
Now in domoticz, you need to read and if necessary toggle the dummy for local(=poti) or remote (=domoticz) control
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

19roland70
New user
Posts: 7
Joined: 18 Mar 2017, 12:22

Re: Esp-12 i.c.m Rotary encoder

#5 Post by 19roland70 » 07 May 2017, 10:02

This is how I want it to do:
Image
Below is the switch state of the Rotary-encoder.
Image
If I read input A then check what is the status of input B is.
Then I know of the Rotary is turned left or right.
Then for left can I set output - 1, and for right output +1
But now the only problem there is :
How can I do this in "rules" ?

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

Re: Esp-12 i.c.m Rotary encoder

#6 Post by toffel969 » 07 May 2017, 11:24

19roland70 wrote: 07 May 2017, 10:02 This is how I want it to do:
Image
Below is the switch state of the Rotary-encoder.
Image
If I read input A then check what is the status of input B is.
Then I know of the Rotary is turned left or right.
Then for left can I set output - 1, and for right output +1
But now the only problem there is :
How can I do this in "rules" ?
i dont think this can be done in rules, the timing is too tight so you will need interupts.

this goes beyond my prgramming skills, but imho the following route should have the best chances of succes:

1. rotary encoder will need to be its own plugin.
2. the rotary encoder is a "double pulse counter" with the timing of the flanks determining the direction. the best starting point for such a plugin should be the pulse counter plugin. intrupt flank detection, as well as counting should be "there". whats missing is the "second gpio" part and detection of direction. this should ne available as ardui
3. unless the delays are reduced , the rotary encoder will still remain a bit laggy.

you could also use arduino to decode the two pulses and transfer data via serial into dummy device. this is probably the easiest if you cant code(like me)
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Martinus

Re: Esp-12 i.c.m Rotary encoder

#7 Post by Martinus » 10 May 2017, 20:46

I guess that there are plenty rotary encoder sketches available that were created for classic Arduino (ATMega platform), so one might question if you need the invent the wheel again...
Just needs to be ported to ESP.

Who is online

Users browsing this forum: Anthropic Claude Bot [bot] and 17 guests