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.


  • 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)

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.


  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,


  2. This comment has been removed by the author.

  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

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

  5. Garage Door Repair Fontana 212-0325 Garage Door Installation, Broken Spring Replacement, Liftmaster and Genie Garage Door Openers & Remote, 24 Hours Garage Door company in Fontana

  6. Introduction include modern day gadgets made us all engineering generally based entirely.
    There is not a single second once we will not be put into use any kind of type of engineering.
    Since the people include hardly time, therefore it is being a crying have to obtain every
    little thing done more rapidly than just before. At present, many individuals will not be
    holding funds; instead they are holding ATM minute card to get anything, which is why,
    they have come to be essential for every single company centre, no matter whether retail
    center or maybe take a trip firm, to be furnished with the device where funds can be taken
    from the actual minute card in combination with supplying expenses right away for the

  7. 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

  8. 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


  9. This is such a good post. Thank you for sharing this information. Keep it up! my service: Garage Door Repair in Austin, Round Rock & Georgetown, Texas.

    box truck door repair austin


  10. It's really awesome post. Keep update and Your blog is really useful for me.

    Austin website design services

    austin web design

  11. 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

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

  13. Wow! What a Great Article Thanks Man! Great work! Really great info.

  14. 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

  15. 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

  16. 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

  17. Mesmerized article written on this blog with other relevant information. It is straight to the point that how we can improve our skills as well as how we can be represented to a new stream of professionalism.

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

  19. 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