Difference between revisions of "ESP8266 Controlled Door Operator"
(→Code) |
|||
(18 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Image:Door_operator_swing_door.jpg| | [[Image:Door_operator_swing_door.jpg|350px|right]] | ||
At our office building, there is a Dorma [http://www.dorma.com/us/en/products/opening_closing/automatic_swing_door_operators/ed100_250_ansi/index-144-470-2757.html 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. | At our office building, there is a Dorma [http://www.dorma.com/us/en/products/opening_closing/automatic_swing_door_operators/ed100_250_ansi/index-144-470-2757.html 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. | ||
Line 16: | Line 16: | ||
== Build == | == 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 | 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. | ||
[[Image:Door_operator_build1.jpg| | Everything was wrapped and isolated before being installed. | ||
[[Image:Door_operator_build1.jpg|500px]] [[Image:Door_operator_build2.jpg|500px]] | |||
== Code == | == Code == | ||
Line 83: | Line 85: | ||
== Installed == | == 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 | 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. | ||
[[Image:Door_operator_installed.jpg| | For easy removal later on, I did not screw the wires into the terminal block but just stuck them into the right terminal pin. | ||
[[Image:Door_operator_installed.jpg|500px]] [[Image:Door_operator_installed2.jpg|500px]] | |||
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. | 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. | ||
Line 93: | Line 97: | ||
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. | 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. | ||
[[Image:Door_operator_iphone_webbrowser.png|400px]] | [[Image:Door_operator_iphone_webbrowser.png|200px]] | ||
== FHEM automation setup == | |||
To make this setup of any practical use, it would be great to integrate the new web capability of the door controller with other sensors and handlers. FHEM is a open "home automation suite" and is very flexible in what you can do with it. By specifying when a sensor triggers, it can spit out a request to the door controller webserver and open the door, e.g. when your main office door opens (sensed by a magnetic sensor), also open the next door down the hall. Or when you click the "OPEN" link in the web interface, open the door. | |||
[[Image:Door_operator_fhem_automation.png|400px]] | |||
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:open set dooroperator open | |||
define dooroperatorSwitch notify EnO_switch_00294BF1:A0 set dooroperator open | |||
</pre> | |||
The last two lines are use to link the magnetic reed switch on the door and the manual self-powered button switch to the door operator action. | |||
You can also call the action directly via http://192.168.xx.xx:8085/fhem?cmd=set%20dooroperator%20open | |||
== 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] | ||
* [http://fhem.de/HOWTO.html#actors FHEM howto] | |||
* [http://forum.fhem.de/index.php?topic=12807.0 FHEM open closed event] |
Latest revision as of 12:58, 22 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 door controller with other sensors and handlers. FHEM is a open "home automation suite" and is very flexible in what you can do with it. By specifying when a sensor triggers, it can spit out a request to the door controller webserver and open the door, e.g. when your main office door opens (sensed by a magnetic sensor), also open the next door down the hall. Or when you click the "OPEN" link in the web interface, open the door.
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:open set dooroperator open define dooroperatorSwitch notify EnO_switch_00294BF1:A0 set dooroperator open
The last two lines are use to link the magnetic reed switch on the door and the manual self-powered button switch to the door operator action.
You can also call the action directly via http://192.168.xx.xx:8085/fhem?cmd=set%20dooroperator%20open