Page 1 of 1

Venetian Blinds over esp8266

Posted: Wednesday 01 January 2020 23:42
by mojso
how to create a script to send commands from domoticz switches via http: //.
using this setup on arduino, esp8266 and servo motor:
https://www.hackster.io/igorF2/wi-servo ... ors-66176e

i plan to use only tilt for the blinds

Re: Venetian Blinds over esp8266 and arduino uno

Posted: Thursday 02 January 2020 8:41
by jf2020
If you want to control one (or two) servo motors over Wifi you can do this directly from the ESP8266! The Arduino is completely useless!! You simply have to connect it to one of the GPIO. Then you can control it like this https://www.letscontrolit.com/wiki/inde ... itle=Servo using ESpEasy (v1) or the newer EspEasy V2 https://espeasy.readthedocs.io/en/lates ... motor.html

Re: Venetian Blinds over esp8266 and arduino uno

Posted: Thursday 02 January 2020 8:55
by jf2020
BTW in addition to the above, you should soon find out (if not already ;) ) that the difficulty is not in the electronics or the command script, but in the mechanical integration of the servo with the blinds (there it really depends of your blinds and the torque required) and in bringing power to the servo / electronics (you normally do not want ugly wires there).

I would recommend that you start by this end of the project 8-) See https://www.youtube.com/watch?v=q0-QmbT0SrQ for an example

Re: Venetian Blinds over esp8266

Posted: Thursday 02 January 2020 15:53
by mojso
except servo motors i plan to put a potentiometer to manually adjust the blinds using the current adjustment mechanism. i need it, 4 gpio for 2 blinds. but for now I'm interested in how to send a command via http: for example blinds in 90 degree position

Re: Venetian Blinds over esp8266

Posted: Friday 14 August 2020 15:21
by mojso
still in test phase but works great
Wemos d1 mini - Espeasy firmware
Servo sg90
Cardan joint - home made :)


[youtube] https://youtu.be/bK5VLNLT7_g [/youtube]


Control from Domoticz (open , close , servo position from 0 to 100%)

Code: Select all

-- Blinds dimmer script using ESPEasy by mojso
-- 1. put the script in Events as Lua script
-- 2.in setup -> more option --> user variable put in variable name dimmer -- , variable type string and update
-- 3.Setup -> Hardware  dymmy device 
--create virtual device,  Select rgb switch,  
-- Then in Switches find the created device end click edit. -- then in switch type select blinds precentage and save

commandArray = {}
DomDevice = 'Blinds';   -- device name
IP = '192.168.1.149';
Stopsignal = '9000';
PIN = "12"; -- D6 WEMOS PIN 12

if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then
        print ("OFF dim = "..uservariables['dimmer']);
        CalcValue = 0;  -- default 0
    else if(devicechanged[DomDevice]=='On') then
        DomValue = uservariables['dimmer'];
        print ("ON dim = "..uservariables['dimmer']);
        CalcValue = DomValue;
    else
        print("Other");
        DomValue = otherdevices_svalues[DomDevice];
        CalcValue = math.floor(DomValue / 100 * 180);
        commandArray['Variable:dimmer'] = tostring(CalcValue);
        print ("dim Level = "..uservariables['dimmer']);
    end
    end
    runcommand = "curl 'http://" .. IP .. "/control?cmd=Servo,1,"  ..PIN.. "," .. CalcValue .. "'";
    os.execute(runcommand);
    print("Servo value= "..CalcValue);
    local delay = 2
  runcommand2 =  "curl 'http://" .. IP .. "/control?cmd=Servo,1,"  ..PIN.. "," .. Stopsignal .. "'";
   os.execute('(sleep '..delay..';' ..runcommand2.. ')');
end
return commandArray

Re: Venetian Blinds over esp8266

Posted: Saturday 12 December 2020 21:03
by pietje1951
Hi mojso,

That looks great.
I think you made switches in Domoticz.
I am a absolutely beginner.
Could you explain how you made it work with Domoticz ?
I plan to use this principe to operate a valve for our woodstove.
Thank you in advance !

Piet

Re: Venetian Blinds over esp8266

Posted: Sunday 13 December 2020 0:00
by mojso
-- 1. Put the script in Events as Lua script
-- 2. In setup -> more option --> user variable
put in variable name dimmer ,
variable type string and update
-- 3.Setup -> Hardware dymmy device create virtual device, Select rgb switch, Then in Switches find the created device end click edit. then in switch type select blinds precentage and save

Re: Venetian Blinds over esp8266

Posted: Monday 21 December 2020 17:35
by pietje1951
Hello mojso,

Thank you for your help. But with me it doesn't work, maybe I do something stupid.
The ESP and the servo work perfectly.
Within Domoticz it doesn't work.
I tried to follow your advice.
Maybe you can see what I do wrong.

-- Blinds dimmer script using ESPEasy by mojso
-- 1. put the script in Events as Lua script
-- 2.in setup -> user variable put in variable name dimmer -- , variable type string and update
-- 3.Setup -> Hardware dymmy device
--create virtual device, Select rgb switch,
-- Then in Switches find the created device end click edit. -- then in switch type select blinds precentage and save

commandArray = {}
DomDevice = 'Klep kachel'; -- device name
IP = '192.168.178.147';
Stopsignal = '9000';
PIN = "4"; -- D6 WEMOS PIN 12

if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
print ("OFF dim = "..uservariables['dimmer']);
CalcValue = 0; -- default 0
else if(devicechanged[DomDevice]=='On') then
DomValue = uservariables['dimmer'];
print ("ON dim = "..uservariables['dimmer']);
CalcValue = DomValue;
else
print("Other");
DomValue = otherdevices_svalues[DomDevice];
CalcValue = math.floor(DomValue / 100 * 180);
commandArray['Variable:dimmer'] = tostring(CalcValue);
print ("dim Level = "..uservariables['dimmer']);
end
end
runcommand = "curl 'http://" .. IP .. "/control?cmd=Servo,2," ..PIN.. "," .. CalcValue .. "'";
os.execute(runcommand);
print("Servo value= "..CalcValue);
local delay = 2
runcommand2 = "curl 'http://" .. IP .. "/control?cmd=Servo,2," ..PIN.. "," .. Stopsignal .. "'";
os.execute('(sleep '..delay..';' ..runcommand2.. ')');
end
return commandArray

The log says:

2020-12-21 17:33:37.031 Status: User: Admin initiated a switch command (189/Klep kachel/Set Level)
2020-12-21 17:33:37.156 Status: LUA: Other
2020-12-21 17:33:37.157 Error: EventSystem: in Script #17 ven blinds: [string "-- Blinds dimmer script using ESPEasy by mojs..."]:27: attempt to concatenate a nil value (field 'dimmer')


I hope you can help me !

Greetings, Pietje

Re: Venetian Blinds over esp8266

Posted: Monday 21 December 2020 17:55
by mojso
-- 2. In setup -> more option --> user variable
put in variable name dimmer ,
variable type string and update

Re: Venetian Blinds over esp8266

Posted: Monday 21 December 2020 21:43
by pietje1951
Hi,

It Works!
I didn't read properly, sorry !
Thank you very much!
Have a Nice christmas

Pietje

Re: Venetian Blinds over esp8266

Posted: Monday 21 December 2020 22:07
by mojso
pietje1951 wrote: Monday 21 December 2020 21:43 Hi,

It Works!
I didn't read properly, sorry !
Thank you very much!
Have a Nice christmas

Pietje
I'm glad it works, have a nice Christmas too