Results 1 to 16 of 16

Thread: Garage Door Opener

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Garage Door Opener

    I have been working on several different types of Home Automation controllers using Arduino. One of them is a Garage Door controller. From my mobile phone I can open, close, or see the status of the garage door (see if its open or closed). In my garage I have an Arduino Uno with an Ethernet Shield attached to it. The garage door opener is connected to the Arduino via a SainSmart relay board.

    I discovered that the button that normally opens and closes the garage door was just a simple push button that briefly closes the circuit between the two wires running from the garage door opener. Using a Relay, I am able to simulate a button press electronically. I ran a wire pair from the connectors on the back of the garage door opener to a cabinet where the Arduino is located. I connected one wire to the common connector on the relay and the other to the normally open connector. Meaning the connection is always open until the Arduino tells the relay to close the circuit.

    Here is the Arduino (Mega Shown) with Ethernet Shield and Relay board

    Here is the Web Interface from my iPhone. Garage -> Door is the button to open the garage door.


    The Relay Board has 4 relays (In picture, closest relay was broken and removed). I used digital outputs 2, 3, 5, 6 on the Arduino to control the relays. Output 0 + 1 is used for serial communication and output 4 is used for the SD card on the EthernetShield. Additionally, the relay board requires Ground and +5V.

    When I press the Garage Door button on the web interface, it sends a HTTP request to the arduino with a URL similar to http://myip:port/command. For example: http://192.168.1.204:84/flashoutput5 will quickly close and open relay 5, just enough time for the garage door to recognize it as a button press. The garage door then opens.

    Here is the code for the garage door opener with comments.
    C Code:
    1. /*
    2. ARDUINOMATION RELAY CONTROL DEVICE
    3. LAST UPDATED: 06/08/2014
    4. */
    5.  
    6. #include <SPI.h>
    7. #include <Ethernet.h>
    8.  
    9. // VERSION NUMBER
    10. float VersionNumber = 2.0;
    11.  
    12. // DEVICE ID - MUST BE UNIQUE
    13. char deviceID[] = "100001";
    14.  
    15. // NETWORK SETTINGS
    16. int port = 84;
    17. char ipAddress[] = "192.168.1.241";
    18. char macaddress[] = "0xDE:0xAD:0xBE:0xEF:0xFE:0xEE";
    19. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE }; //physical mac address
    20. byte ip[] = { 192, 168, 1, 241 }; // DEVICE IP ADDRESS
    21. IPAddress controllerserver(192,168,1,204); // CONTROL SERVER IP ADDRESS
    22. EthernetServer server(port); //CONTROL SERVER PORT
    23. EthernetClient client;
    24.  
    25. // CONTROL SERVER PARAMETERS
    26. char updateurl1[] = "/projects/arduino/master_controller.php?command=checkin&deviceid=";
    27. char updateurl2[] = "&ip=";
    28. char updateurl3[] = "&mac=";
    29.  
    30. // DIGITAL OUTPUTS
    31. String readString;
    32. int output1 = 2;
    33. int output2 = 3;
    34. int output3 = 5;
    35. int output4 = 6;
    36. int output5 = 7;
    37. int output6 = 8;
    38. int output7 = 9;
    39.  
    40. // **************************** START CODE ****************************
    41.  
    42. void setup(){
    43.  
    44.   pinMode(output1, OUTPUT);
    45.   pinMode(output2, OUTPUT);
    46.   pinMode(output3, OUTPUT);
    47.   pinMode(output4, OUTPUT);
    48.   pinMode(output5, OUTPUT);
    49.   pinMode(output6, OUTPUT);
    50.   pinMode(output7, OUTPUT);
    51.  
    52.   // ETHERNET CONNECTION
    53.   Ethernet.begin(mac, ip); // , ip, gateway, subnet
    54.   server.begin();
    55.  
    56.   //PRINT TO SERIAL
    57.   Serial.begin(9600);
    58.   Serial.println(" Device Controller Loading..."); // so I can keep track of what is loaded
    59.   Serial.print("IP Address: ");
    60.   Serial.print(Ethernet.localIP());
    61.   Serial.print(":");
    62.   Serial.println(port);
    63.  
    64.   // CONNECT TO CONTROL SERVER
    65.   // Control server keeps track of all devices on the network
    66.   if (client.connect(controllerserver, 8888)) {
    67.     Serial.println("Connected to device server");
    68.    
    69.     Serial.println("Updating System");
    70.     client.print("GET ");
    71.     client.print(updateurl1);
    72.     client.print(deviceID);
    73.     client.print(updateurl2);
    74.     client.print(ipAddress);
    75.     client.print(updateurl3);
    76.     client.print(macaddress);
    77.     client.println(" HTTP/1.0");
    78.     client.println();
    79.     client.stop();
    80.     Serial.println("Server updated");
    81.   } else {
    82.     Serial.println("Connection to server failed.");
    83.    
    84.    
    85.     client.stop();
    86.     delay(1000);
    87.   }
    88.  
    89.   // EVERYTHING IS LOADED - WAIT FOR REQUESTS
    90.   Serial.println("Ready for requests...");
    91.   Serial.println();
    92. }
    93.  
    94. void loop(){
    95.   // Create a client connection
    96.   EthernetClient client = server.available();
    97.   if (client) {
    98.     while (client.connected()) {
    99.       if (client.available()) {
    100.         char c = client.read();
    101.  
    102.         //read char by char HTTP request
    103.         if (readString.length() < 100) {
    104.  
    105.           //store characters to string
    106.           readString += c;
    107.         }
    108.  
    109.         //if HTTP request has ended
    110.         if (c == '\n') {
    111.  
    112.           ///////////////
    113.           Serial.println("String:");
    114.           Serial.println(readString); //print to serial monitor for debuging
    115.  
    116.           client.println("HTTP/1.1 200 OK"); //send new page
    117.           client.println("Content-Type: text/html");
    118.           client.println();
    119.  
    120.           client.println("<HTML>");
    121.           client.println("<HEAD>");
    122.           client.println("<TITLE>Garage Control</TITLE>");
    123.           //client.println("<meta http-equiv="refresh" content="5">");
    124.           client.println("</HEAD>");
    125.           client.println("<BODY>");
    126.  
    127.           client.println("<H1>Garage Controller</H1>");
    128.          
    129.          
    130.           // READ SENSOR
    131.           int sensor = digitalRead(8);
    132.          
    133.           //  PRINT STATUS OF SENSOR
    134.           if (sensor == HIGH) {
    135.             client.println("Garage Open");
    136.           } else {
    137.             client.println("Garage Closed");
    138.           }
    139.          
    140.           client.println("<br><br><a href='/?flashoutput5'>Open/Close Garage</a>");
    141.          
    142.           client.println("<br><br><a href='/'>Refresh</a>");
    143.          
    144.           //client.println(sensor);
    145.           client.println("</BODY>");
    146.           client.println("</HTML>");
    147.  
    148.           delay(1);
    149.           //stopping client
    150.           client.stop();
    151.          
    152.           ///////////////////// control arduino pin
    153.          
    154.          
    155.           //******* OUTPUT 5 GARAGE *************
    156.           //This one is Special for Garage.
    157.  
    158.           if(readString.indexOf("flashoutput5") >0)
    159.           {
    160.              digitalWrite(output5, HIGH);
    161.              delay(500);
    162.              digitalWrite(output5, LOW);
    163.              Serial.println("Output 5 Flashed");
    164.           }          
    165.          
    166.           //******* OUTPUT 1 *************
    167.           if(readString.indexOf("highoutput1") >0)//checks for on
    168.           {
    169.            
    170.             digitalWrite(output1, HIGH);    
    171.             Serial.println("Output1 On");
    172.            
    173.           }
    174.           if(readString.indexOf("lowoutput1") >0)
    175.           {
    176.            
    177.             digitalWrite(output1, LOW);
    178.             Serial.println("Output1 Off");
    179.           }
    180.          
    181.           //******* OUTPUT 2 *************
    182.           if(readString.indexOf("highoutput2") >0)//checks for on
    183.           {
    184.            
    185.             digitalWrite(output2, HIGH);    
    186.             Serial.println("Output2 On");
    187.            
    188.           }
    189.           if(readString.indexOf("lowoutput2") >0)
    190.           {
    191.            
    192.             digitalWrite(output2, LOW);
    193.             Serial.println("Output2 Off");
    194.           }
    195.          
    196.           //******* OUTPUT 3 *************
    197.           if(readString.indexOf("highoutput3") >0)//checks for on
    198.           {
    199.            
    200.             digitalWrite(output3, HIGH);    
    201.             Serial.println("Output3 On");
    202.            
    203.           }
    204.           if(readString.indexOf("lowoutput3") >0)
    205.           {
    206.            
    207.             digitalWrite(output3, LOW);
    208.             Serial.println("Output3 Off");
    209.           }
    210.          
    211.           //******* OUTPUT 4 *************
    212.           if(readString.indexOf("highoutput4") >0)//checks for on
    213.           {
    214.            
    215.             digitalWrite(output4, HIGH);    
    216.             Serial.println("Output4 On");
    217.            
    218.           }
    219.           if(readString.indexOf("lowoutput4") >0)
    220.           {
    221.            
    222.             digitalWrite(output4, LOW);
    223.             Serial.println("Output4 Off");
    224.           }
    225.          
    226.           //******* OUTPUT 5 *************
    227.           if(readString.indexOf("highoutput5") >0)//checks for on
    228.           {
    229.            
    230.             digitalWrite(output5, HIGH);    
    231.             Serial.println("Output5 On");
    232.            
    233.           }
    234.           if(readString.indexOf("lowoutput5") >0)
    235.           {
    236.            
    237.             digitalWrite(output5, LOW);
    238.             Serial.println("Output5 Off");
    239.           }
    240.          
    241.           //******* OUTPUT 6 *************
    242.           if(readString.indexOf("highoutput6") >0)//checks for on
    243.           {
    244.            
    245.             digitalWrite(output6, HIGH);    
    246.             Serial.println("Output6 On");
    247.            
    248.           }
    249.           if(readString.indexOf("lowoutput6") >0)
    250.           {
    251.            
    252.             digitalWrite(output6, LOW);
    253.             Serial.println("Output6 Off");
    254.           }
    255.          
    256.           //******* OUTPUT 7 *************
    257.           if(readString.indexOf("highoutput7") >0)//checks for on
    258.           {
    259.            
    260.             digitalWrite(output7, HIGH);    
    261.             Serial.println("Output7 On");
    262.            
    263.           }
    264.           if(readString.indexOf("lowoutput7") >0)
    265.           {
    266.            
    267.             digitalWrite(output7, LOW);
    268.             Serial.println("Output7 Off");
    269.           }
    270.          
    271.           Serial.println("--------------------------------------------------");
    272.           //clearing string for next read
    273.           readString="";
    274.  
    275.         }
    276.       }
    277.     }
    278.   }
    279. }


    Here is what the serial console looks like when it is loaded. Notice that is says "Connection to server failed", thats because I do not have it connected to the network and it was not able to tell the Logic Server that its now online.

    Attachment 115163



    Edit:
    Here is part 2 of the project where I put the project in an enclosure.
    Last edited by dclamp; Aug 25th, 2018 at 12:27 AM.
    My usual boring signature: Something

  2. #2

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    That is just a brief overview of what that code is really doing. While I do not have a fully functional home automation system, I have lots of parts that all work together with a single logic control point. I set up my arduinos to be "dumb": they only report sensors or do what the logic controller says. My Arduinos are not programmed to do any real thinking on their own.

    My logic is a PHP server with MySQL. If anyone wants a more detailed explanation of how my system works I can explain it. Its actually pretty detailed and elaborate.
    Last edited by dclamp; Aug 25th, 2018 at 12:27 AM.
    My usual boring signature: Something

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Garage Door Opener

    A more detailed explanation is more than welcome. :-)
    Regards,

    â„¢

    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Garage Door Opener

    Hang on! It's a Web Application how do you protect it from hacking? What I find impressive is that you managed to get .Net working on your iPhone.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    Like I said, each of the Arduino devices that I create are all "dumb" so they do not actually make any decisions. My system has the following different elements:

    • Arduino Devices
    • Logic Server
    • Web Interface


    My different Devices include:
    • Main Power Switch (Lights)
    • Door Sensor
    • Garage Door Controller
    • Input Device (Button/Toggle)
    • Alarm Inputs
    • Monitor (LCD Screen)


    When I connect one of the devices to the network, it first contacts the Logic server to check in. Each device is given a unique mac address and a unique device ID. The logic server checks to see if the device is already registered with the system, if its not then its added as a new device with no logic associated. If its already registered, then its considered online.

    I can then log into the Logic server and see a list of all the devices in my system that are checked in. For new devices I associate them with a room in the house and I name them. From there I can create logic for each device through the web portal depending on what type of device it is. For example, If I connect a new Button device and a Mains Power Switch, I can associate the button with the Switch. The sequence of events is as follows: Button Press -> Contacts logic server -> logic server processes what should happen -> toggles mains power switch.

    When I add new devices to the network, they are automatically added to the web interface for my phone. The one pictured above is an older version that just shows test items.

    All the devices that I have made so far are still prototypes on breadboards. I haven't been able to get around to making actual printed PCBs that are complete products.

    I got a lot of inspiration from Superhouse.TV on YouTube. He took Arduino home automation to the next level and remodeled his house around a structured wiring system with Arduino devices. He has a lot of fully developed models.
    My usual boring signature: Something

  6. #6

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    Quote Originally Posted by Nightwalker83 View Post
    Hang on! It's a Web Application how do you protect it from hacking? What I find impressive is that you managed to get .Net working on your iPhone.
    The Logic Server is in the private network protected by the firewall. The front end web interface is hosted on a domain outside of the home network required authentication.

    And I am not running .Net on my iPhone?
    My usual boring signature: Something

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Garage Door Opener

    Quote Originally Posted by dclamp View Post
    And I am not running .Net on my iPhone?
    I was thinking you needed to download files in-order for the browser to use the .Net code site but obviously I am incorrect there.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Garage Door Opener

    Sounds like you've put a lot of work into this. Pretty cool stuff. I guess you could also have done this without the internet-facing server and just connect direct to the arduino over WIFI behind your firewall. That would provide a geographical constraint. Unless you actually like opening your garage door from 4000 miles away of course, which might be fun.

    Cool build.
    I don't live here any more.

  9. #9

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    That was kind of the intent of having the sensor to see if the garage is opened or closed. Should be be away from home and notice you left the garage door open, you can close it.
    My usual boring signature: Something

  10. #10

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    But Yeah I have put a lot of time Into it. I have worked on it piece by piece and it just keeps getting larger and more sophisticated as i continue to work on it.
    My usual boring signature: Something

  11. #11
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Garage Door Opener

    I guess you could have a "dead drop" system too in case you find yourself unable to access your web front-end for some reason (some bad guy has hacked your LAN and changed the access credentials). Have the Arduino perform a HTTP get request of a URL you have control over and simply put a predetermined phrase in the content of that web page that would never attract anyone's attention otherwise. Despite the LAN being hacked, the Arduino would likely still have internet access.

    So you could search for the words "I had sushi for dinner" in your most recent twitter messages. The arduino sees this and treats it as a signal that it should close the door and then shutdown completely so that you can only open the garage with a physical key. Might be a nice security feature.

    Dunno really, not thought that idea through all the way but you see what I mean.
    Last edited by wossname; Jun 10th, 2014 at 06:20 AM.
    I don't live here any more.

  12. #12

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    I see where you are going with that idea... Its 0440 here in California and I am dead tired. (Graveyard sucks) I will thinking about this when I awake up and give a thoughtful reply.
    My usual boring signature: Something

  13. #13

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    Another "fail-safe" type system would be a device that is connected to the network and if it detected that the internet connection has been comprised, it could send a signal to the other devices to go into a fail-safe manual mode and not accept any commands. This device could have a GSM chip and could query an outside source to see if I have put it int fail-soft mode.

    I constantly see different home automation concepts on Kickstarter or for sale at the electronic store. I dont like how there are so many different suppliers with their own proprietary system. There needs to be an opensource, generic communication protocol for home automation devices. It would be nice to have a system that is open so I can buy devices and program the logic the way I wanted it. Maybe it already exists and I dont know about it.

  14. #14
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Garage Door Opener

    http://www.openhab.org/ is the only one I've heard of, never tried it though.
    I don't live here any more.

  15. #15

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    Thanks for that link. Never heard of it before. Looking at it now

  16. #16

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Garage Door Opener

    For those subscribed to the thread... I have put this project into an enclosure and mounted it in my garage.

    http://www.vbforums.com/showthread.p...sure&p=4700199

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width