Wednesday, September 14, 2011

Monitor if Your Garage Door is Open with Netduino Plus

This blog post is going to document how to build an infrared sensor to monitor your garage door. It is part of a series to build an Android garage door app.

Supplies

  • Netduino plus (if you don't already have one). There are many places you can buy one and they seem to charge about the same $59.95.
  • Optical Detector / Phototransistor $1.13. (I bought mine from Sparkfun)
  • 200 ohm resistor (under a buck from any almost anywhere)
  • 5.6K ohm resistor (under a buck from any almost anywhere)
  • (Optional) (2) Screw Terminals 3.5mm Pitch $1.25 ea.
  • (Optional) PC Board $2.19 for two.
1. Build it

Follow this schematic to build your garage door sensor.

 This is what mine looks like (I used the PC board and terminals to make mine a little more tidy).


And here is the sensor installed in the garage. I placed it on the side facing the side plate. When the door is open the sensor detects an object close.


2. Code it

If you have not installed all the necessary software see my previous blog post on how to setup your Netduino Plus development environment here (How to Setup Netduino Plus Development Environment).


Create a new project
Launch Visual Studio 2010 then create a new project (File > New Project > Netduino Plus Application). Let's name it NetduinoInfraredSensor.


Open Program.cs

  • Line 2 we define an AnalogInput and set it for PIN 0

  • Line 4 we set the range for reading the analog signal from 0 to 1024
  • Lines 6-10 are the main infinite loop. 
  • Line 8 we read the voltage through analog input 0 (which will return a value of 0 to 1024 which proportionally to the voltage coming from the infrared sensor we built and hooked up to analog input 0).
  • Line 9 we sleep the program for 1 second (so the program debug output is not flooding through the debug window). Be careful with loops that don't contain any Thread sleep commands. It is possible to for Visual Studio to have difficulty connecting and deploying if the loop is too tight. To be safe always throw in a sleep even if its just for a fraction of second.

//Set the analog pin to monitor Pin 0
AnalogInput garageSensor = new AnalogInput(Pins.GPIO_PIN_A0);
//Set sensor range
garageSensor.SetRange(0, 1024);
//Program loop
while (true)
{
    Debug.Print(garageSensor.Read().ToString());
    Thread.Sleep(1000);
}

3. Run it

First we need to change the project properties to deploy the program to the Netdiuno Plus and not an emulator (default). Right click on the project > properties > .Net Framework. Change the Transport to USB and make sure Netdiuno Plus is the device. (Your Netduino must attached to the computer via USB cable before making this change).
Now we can run the program in debug mode by pressing F5 or Debug > Start Debugging. Now hold an object about 3 inches from the infrared sensor and slowly move it towards the sensor. You will begin to see the reading drop from 1024.


Here is the complete code for the sensor.



To learn how to write the Android app that will control and monitor the garage door read the step by step blog post here. http://androidcodemonkey.blogspot.com/2011/10/android-garage-door-app.html

33 comments:

  1. Hi Greg, I enjoyed a lot your post. I was looking for a post like this for a long time, because of I have the necessity to be able to monitor my garage door. This project is perfect for me, I have an arduino (not netduino) idle and skills in programming but lack of skills in the electronic part. And this article seems so easy to follow and implement...but I have one doubt, I don't know where you placed the sensor.
    In the paragraph "And here is the sensor installed in the garage. I placed it on the side facing the side plate. When the door is open the sensor detects an object close." I don't understand the sentence "I placed it on the side facing the side plate." due to my english is not as good as I'd wish. Can you explain where you placed the sensor in a way I'm able to understand? for example adding a new photo to the existing one, but appearing the whole garage door and where you placed the netduino?

    Thanks in advance,

    Albert

    ReplyDelete
    Replies
    1. iI’m lauriel from New York, United States. I lost my job a few months back after my divorce with my wife. I tried everything positive to make sure I took good care of my kids but all failed, and I was in debt which makes everything worse. I was kicked out of my home and i had to live with my neighbor after pleading with her to allow me to stay with her for some days while I figured out how to get a home which she agreed to, but no one was willing to help anymore. I bumped into this page from google and I was excited about this, then I contacted the hackersBill Dean. I had just $200, so I pleaded with them to help me because of my condition but they never accepted. I believed in this, so I managed to pawn a few things and got $500. I ordered the $10,000 card and I got my card delivered to me by Ups 4 days later. I never believed my eyes! I was excited and upset as well, I managed to withdraw $2000 on the ATM and $2500 the second day. I went to Walmart and a grocery store and bought a couple of things for $3000. The card got blocked the third day and I contacted them and I was told it's a mistake from my end. I’m so happy, I have started all over again and have a good apartment with my kids you can contact him through is via email (globalatmcardhackingservice@gmail.com)or his whatsap contact (+1 301-887-5071)

      Delete
    2. HOW TO GET CROWN MAGIC ATM CARD

      UNLIMITED CASH I took the risk and in exactly 6 days later my card was delivered to my home address here and that same evening I used the card to take out $5000 for a start. It's been just 3 weeks and my life has taken a new shape. I simply want to say thank you to this electronic company and help spread their fame abroad. If you ever are in need of this card details on how to get yours today, YOu can also Whatsapp: +12134218707 email crown_technology@yahoo.com

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I'd like to modify your code to work for 2 garage doors, but I am an unfortunate newbie that has basically no experience with this. Is there a place you could recommend that I could get some base knowledge? Or better yet, write the code for me? Just kidding, but any help would be appreciated.

    It looks like I coud just repeat the code just changing the above code to PinX and garagesensor to garagesensor2

    ReplyDelete
  4. I liked very much, I'm just not getting the download Skydrive.

    ReplyDelete
  5. Your Oklahoma City Garage Door Repair Experts
    Seven days a week, our company offers garage door repair services in the areas of Oklahoma City and surrounding cities. Today, one of our specialists will come to you and get your home's garage door functioning like its brand new.

    Mitchell R. Clark
    1569 Harley Brook Lane
    Patton, PA 16668
    martinaaaamarketingg1984@gmail.com
    814-674-8592

    ReplyDelete
  6. I just want to mention I am very new to weblog and actually loved you're website. Almost certainly I’m likely to bookmark your blog . You amazingly come with beneficial posts. Thanks for sharing your web page.garage door repair winston salem

    ReplyDelete
  7. I want you to thank for your time of this wonderful read!!! I definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog! Stanley Garage Door & Gate Repair Cudahy CA

    ReplyDelete
  8. I will be talking about Liftmaster and Craftsman garage door openers. The Chamberlain Corporation makes Craftsman, Chamberlain, and Sears Craftsman garage door openers. BurbankGarageDoorRepair

    ReplyDelete
  9. If your door snaps and gets crammed through its rolling, one of the possible conditions that might have caused it is the spring's performance. garage door window privacy

    ReplyDelete
  10. In other situations, check the hinges and replace damaged ones. When the openers show signs of sagging on one part then correct it by servicing the hinges. Make sure that the solid wood on which the hinge is positioned is not cracked or chipped. local garage door repair & gate

    ReplyDelete
  11. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Garage Pros Calgary

    ReplyDelete
  12. Impressive Blog.
    I am very glad after read this.
    Keep post your blog like this.
    garage door opener repair san diego

    ReplyDelete
  13. Nice....Service Calgary and surrounding areas, and the best services and the lowest prices, supply and install garage doors,openers and repair.
    Garage Door Spring Repairs Calgary

    ReplyDelete
  14. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work locksmith

    ReplyDelete
  15. Thanks for sharing this nice blog. I read it completely and get more interesting knowledge from this. I again thanks for sharing such a nice blog. At Precision Garage Doors, we have the ability to provide the best services for garage door torsion spring repair in Calgary and Canada. Hire us today!

    ReplyDelete
  16. Nice Information, your blog is sharing unique information....
    Thanks for sharing!!!

    Garage Door Mt Sinai NY

    ReplyDelete
  17. Nice Information, your blog is sharing unique information....
    Thanks for sharing!!!

    Overhead Door Port Jefferson

    ReplyDelete
  18. Nice information, keep it up…
    Looking for Garage Door Services San Diego CA, contact Lockout Garage Door today.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Thanks for this amazing post it was very interesting and helpful. Garage doors can malfunction at any time, and we realize the importance of urgent garage door repair. We provide 24/7, 365 days garage door services. We are available for you, even on weekends and holidays. After receiving a call from you, our expert technicians will readily reach your place with all the necessary tools. They will fix the garage gate problems for you. After fixing the malfunction, they will do a detailed inspection of your garage door to look for any issues. Besides fixing the garage door problems, they will inform you of any future risks your door may face in future. We provide overhead door portland service to avoid you from future threats. Or if your gate requires replacement, we offer gate replacement services too. Call now (503) 558-3514

    ReplyDelete
  21. Wonderful article thank you. All of our garage door and gate technicians are trained and certified. They always try their best to provide you with high-quality service. The main focus of our team is on quality service and on customer satisfaction. This is the reason that we have become one of the leading garage door companies in Los Garage Door Repair Hermosa Beach. With many years of experience, our experts only use the highest quality products to ensure reliability and durability. They also offer suggestions to homeowners about what they need. Once our technicians arrive at their place for repair, they will ensure the proper working of the gate for many years to come.

    ReplyDelete
  22. Amazing post thank you. We have become an honest, reputable, and dependable garage door company in Los Angeles because of our 100% customer satisfaction service. We only hire the best installers for Garage Door Repair Hermosa Beach. Much of our success is because of the efforts of exceptional teams that constantly show high levels of effectiveness and proficiency. Our clients feel easier to communicate with us at all times because of the friendly approach of our team. Our technicians provide the best suggestions to all customers. They answer all queries and interrogations in a simple yet direct manner that gives a customer a full guarantee.

    ReplyDelete
  23. Our technicians provide the best suggestions of Garage Door Repair Hermosa Beach to all customers. They answer all queries and interrogations in a simple yet direct manner that gives a customer a full guarantee.

    ReplyDelete
  24. We have become an honest, reputable, and dependable garage door repair company in Southwest Portland because of our 100% customer satisfaction service.

    ReplyDelete
  25. We only hire the best installers for garage gate and Garage Door Repair Portland OR. Much of our success is because of the efforts of exceptional teams that constantly show high levels of effectiveness and proficiency. Our clients feel easier to communicate with us at all times because of the friendly approach of our team.

    ReplyDelete
  26. Are you in need of a reliable garage door service that is affordable as well? Rafael Garage Door is your Local Garage Door maintenance provider and we are one-stop-shop for all Garage Door Repair Northwest Tampa services.

    ReplyDelete
  27. BE SMART AND BECOME RICH IN LESS THAN 3DAYS....It all depends on how fast 
    you can be to get the new PROGRAMMED blank ATM card that is capable of
    hacking into any ATM machine,anywhere in the world. I got to know about 
    this BLANK ATM CARD when I was searching for job online about a month 
    ago..It has really changed my life for good and now I can say I'm rich and 
    I can never be poor again. The least money I get in a day with it is about 
    $50,000.(fifty thousand USD) Every now and then I keeping pumping money 
    into my account. Though is illegal,there is no risk of being caught, because it has been programmed in such a way that it is not traceable, it also has a technique that makes it impossible for the CCTVs to detect 
    you.. For details on how to get yours today, email the hackers on { garryjones_atm_hacker@hotmail.com } Tell your loved once too, and start to live large. That's the simple testimony of how 
    my life changed for good...Love you all ...the email address again is Garryjones_atm_hacker@hotmail.com

    ReplyDelete
  28. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Sliding garage doors

    ReplyDelete
  29. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. garage door repair bentonville ar

    ReplyDelete
  30. This is really informative blog for students, Sidney Emergency Garage Door Repair keep up the good work.

    ReplyDelete
  31. This particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… garage door installation

    ReplyDelete