Difference between revisions of "ESP8266 Controlled Door Operator"
Line 99: | Line 99: | ||
[[Image:Door_operator_iphone_webbrowser.png|200px]] | [[Image:Door_operator_iphone_webbrowser.png|200px]] | ||
== FHEM automation | == FHEM automation setup == | ||
To make this setup of any practical use, it would be great to integrate the new web capability of the ESP8266 with other sensors and handler. | To make this setup of any practical use, it would be great to integrate the new web capability of the ESP8266 with other sensors and handler. | ||
FHEM is a open "home automation suite" and is very flexible in what you can do with it. | FHEM is a open "home automation suite" and is very flexible in what you can do with it. Edit fhem.cfg and put these lines into the file: | ||
<pre> | |||
define dooroperator dummy | |||
attr dooroperator devStateIcon open:signal_Fenster_Offen.on | |||
attr dooroperator setList open | |||
attr dooroperator webCmd open | |||
define dooroperatorNtfy notify dooroperator {GetFileFromURL "http://192.168.xx.xx/?pin=ON1"} | |||
define dooroperatorContact notify EnO_contact_01825A29:closed set dooroperator open | |||
define dooroperatorSwitch notify EnO_switch_00294BF1:A0 set dooroperator open | |||
</pre> | |||
The last two lines are for my other magnetic reed switch on the door and the manual self-powered button switch. | |||
== References == | == References == | ||
* [https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en NodeMCU ESP8266 firmware API] | * [https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en NodeMCU ESP8266 firmware API] | ||
* [http://randomnerdtutorials.com/esp8266-web-server/ ESP8266 web server] | * [http://randomnerdtutorials.com/esp8266-web-server/ ESP8266 web server] |
Revision as of 23:36, 21 November 2015
At our office building, there is a Dorma Automatic Swing Door Operator which is normally engaged by a push button next to the door frame and also wirelessly from the hall way end of the door.
Pressing and waiting for the door to open is unbearable, therefore I made the decision to add a third option to the mix; operating it wirelessly from my mobile phone using the web browser.
Digital switch
The way the existing wired and wireless buttons are wired on the automatic door operator is fairly simple, just ground and a control signal which is pulled high (24V). Pull this control line low and the door will engage and begin to swing open.
Adding a third option is just a matter of adding a transistor between the control signal and ground; and having a controller toggle the transistor when needed.
Schematic
The system is based on a 3.3V regulator (although I used my own ESP8266 breakout board which has a 3.3V regulator, connected to a 5V regulator capable of handling 24V in), the main ESP8266-ESP01 board and a pair of PNP and NPN transistors.
Build
For this to be a one day build, I had to take some shortcuts to save time. The build is fully functional, but it might not look visually pleasing.
Everything was wrapped and isolated before being installed.
Code
The code is based on Lua for the NodeMCU firmware. Programmed using LuaLoader via a 3.3V FTDI USB adapter.
This code is based on a simple web server and modified to wait 500ms before releasing the pull-low toggleT.
wifi.setmode(wifi.STATION) wifi.sta.config("WIFISSID","WIFIPASSWD") print(wifi.sta.getip()) led1 = 3 led2 = 4 gpio.mode(led1, gpio.OUTPUT) gpio.write(led1, gpio.LOW); gpio.mode(led2, gpio.OUTPUT) gpio.write(led2, gpio.LOW); srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(client,request) local buf = ""; local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); if(method == nil)then _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); end local _GET = {} if (vars ~= nil)then for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do _GET[k] = v end end buf = buf.."HTTP/1.1 200 OK\nCache-Control: no-cache, no-store, must-revalidate\nPragma: no-cache\nExpires: 0\n\n"; buf = buf.."<html><head><title>ESP8266 Srv</title></head><body><h1>ESP8266 Web Server</h1>"; buf = buf.."<p>GPIO0 <a href=\"?pin=ON1\"><button>ON</button></a> <a href=\"?pin=OFF1\"><button>OFF</button></a></p>"; buf = buf.."<p>GPIO2 <a href=\"?pin=ON2\"><button>ON</button></a> <a href=\"?pin=OFF2\"><button>OFF</button></a></p>"; buf = buf.."</body></html>"; local _on,_off = "","" if(_GET.pin == "ON1")then gpio.write(led1, gpio.HIGH); tmr.delay(500000); gpio.write(led1, gpio.LOW); elseif(_GET.pin == "OFF1")then gpio.write(led1, gpio.LOW); elseif(_GET.pin == "ON2")then gpio.write(led2, gpio.HIGH); tmr.delay(500000); gpio.write(led2, gpio.LOW); elseif(_GET.pin == "OFF2")then gpio.write(led2, gpio.LOW); end client:send(buf); client:close(); collectgarbage(); end) end)
Installed
The installation process is as simple as it get. Just figure out how the existing buttons are wired and find a power&gnd lane to power everything. Luckly, the wireless module for the door was also powered by 24V so all three necessary pins were next to each other.
For easy removal later on, I did not screw the wires into the terminal block but just stuck them into the right terminal pin.
There was lots of room in the back of the unit to mount everything. This is the area where the cables from the buttons and sensors came in, so just a little re-jiggling was needed.
Working
This shows the screen of an iPhone connected to the webserver. Opening the door is as easy as just toggling the button. By making a shortcut on the home-screen directly to the toggling URL makes it even easier to engage.
FHEM automation setup
To make this setup of any practical use, it would be great to integrate the new web capability of the ESP8266 with other sensors and handler.
FHEM is a open "home automation suite" and is very flexible in what you can do with it. Edit fhem.cfg and put these lines into the file:
define dooroperator dummy attr dooroperator devStateIcon open:signal_Fenster_Offen.on attr dooroperator setList open attr dooroperator webCmd open define dooroperatorNtfy notify dooroperator {GetFileFromURL "http://192.168.xx.xx/?pin=ON1"} define dooroperatorContact notify EnO_contact_01825A29:closed set dooroperator open define dooroperatorSwitch notify EnO_switch_00294BF1:A0 set dooroperator open
The last two lines are for my other magnetic reed switch on the door and the manual self-powered button switch.