Venetian Blinds over esp8266

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Venetian Blinds over esp8266

Post 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
Last edited by mojso on Friday 14 August 2020 15:25, edited 1 time in total.
jf2020
Posts: 10
Joined: Monday 12 December 2016 20:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266 and arduino uno

Post 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
jf2020
Posts: 10
Joined: Monday 12 December 2016 20:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266 and arduino uno

Post 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
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
Last edited by mojso on Friday 14 August 2020 18:16, edited 1 time in total.
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
Attachments
s1.jpg
s1.jpg (60.57 KiB) Viewed 1203 times
Last edited by mojso on Monday 21 December 2020 18:41, edited 4 times in total.
pietje1951
Posts: 11
Joined: Sunday 08 November 2020 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
Last edited by mojso on Monday 21 December 2020 18:40, edited 1 time in total.
pietje1951
Posts: 11
Joined: Sunday 08 November 2020 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post by mojso »

-- 2. In setup -> more option --> user variable
put in variable name dimmer ,
variable type string and update
Attachments
20201221_175749.jpg
20201221_175749.jpg (227.7 KiB) Viewed 944 times
pietje1951
Posts: 11
Joined: Sunday 08 November 2020 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post by pietje1951 »

Hi,

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

Pietje
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Venetian Blinds over esp8266

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest