ip 192.168.178.200:8080
Wemos D1 firmware v2.0.0-dev12 test image with rotary
with Rotary KY-040 encoder connected to D3 GPIO(0) and D2 GPIO(2)
Ip 192.168.178.110 and at the device tab the rotary switch.
Mqtt:
192.178.178.200:1883
Hi All.
I like to controle my dimmer via a rotary switch KY-040 encoder.
Dimmer is working via the slider via a dummy dimmer via lua script.
So in short terms how can i controle a dimmer via a rotary encoder connected to a Wemos ESP8266.
Code: Select all
commandArray = {}
DomDevice = 'Dimmer-Veranda-110';
IP = '192.168.178.110';
PIN = "16";
if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
print ("OFF dimm = "..uservariables['dimm']);
CalcValue = 800;
else if(devicechanged[DomDevice]=='On') then
DomValue = uservariables['dimm'];
print ("ON dimm = "..uservariables['dimm']);
CalcValue = DomValue;
else
print("Other");
DomValue = otherdevices_svalues[DomDevice];
CalcValue = 900-(DomValue*9);
commandArray['Variable:dimm'] = tostring(CalcValue);
print ("dimm Level = "..uservariables['dimm']);
end
end
runcommand = "curl 'http://" .. IP .. "/control?cmd=PWM," ..PIN.. "," .. CalcValue .. "'";
os.execute(runcommand);
print("PWM calculated value= "..CalcValue);
end
return commandArray
I have seen some articles :
For home assist:
https://community.home-assistant.io/t/a ... mqtt/29448
Domoticz:
viewtopic.php?t=17348
Image of wemos esp8266 where you can see that the rotary encoder is counting up and down.