I'd like to be able to measure the position of my garage door. Determining if the garage door is fully open or fully closed should be fairly simple with some magnetic reed switches but I'd like to know the position of the door when it's partially open/closed.

  • Well, if it's not open and not closed, it's inbetween ;) you'll neer two sensors though to be able to distantiate beteren these states.
    – aaa
    Dec 19, 2016 at 6:53
  • If you really want some amount of precision inbetween, you could mount a "ultrasonic sensor" or "ir ranging" sensor to the door and measure the distance to the ground. However, I don't see why it would be neccesary. Most garage doors would shut down when blocked, but ask your manufacturer.
    – aaa
    Dec 19, 2016 at 6:58

3 Answers 3


A couple of possibilities occur to me. One would be to mount a rotary encoder on a rotating part of the door. Another would be to attach a reed switch to the track and a series of magnets to the door. I suppose you could do something with a proximity sensor as well.

How much precision do you need in the position of the door? What do you know that is deterministic? For example is the door transit time predictable? Is it a positive drive? Do you get to know when the door starts moving? That might be enough right there.

If you can say more about what you're trying to do it would make it easier to provide suggestions and insight.

  • As for precision, within a couple of inches or so would be fine. It's mostly for informational/educational purposes.
    – jcollie
    Dec 28, 2015 at 22:15
  • 1
    Seems like a reed switch and magnets might be one of the simpler ways to go about it. Or if you control the motor and the door drive is positive you could just time it.
    – dlu
    Dec 28, 2015 at 22:25
  • Timing it wouldn't help if the door gets stuck (how would you know where it got stuck) and would probably be less precise than I want if the door doesn't travel at a constant rate. Magnetic reed switches would work but would require a lot of them and hooking them up would take some fancy electronics or a lot of pins. Plus there would be some uncertainty if the door stopped inbetween the switches. So far a rotary encoder tracking the movement of the chain sounds like the best bet.
    – jcollie
    Dec 29, 2015 at 1:55
  • The way I would do it with a reed switch (or maybe two or three) is to use one switch and many magnets – at most you would use three pins. You would keep track of the door position by counting switch closures. You could make it a bit more positive if you also used a switch or possibly two for "open" and "closed" – you could reset your count when the open or closed switch was tripped which might make it easier to keep track of your position. One thing to keep in mind is how you will deal with different failure modes. The rotary encoder will give you the wrong answer if the chain breaks.
    – dlu
    Dec 29, 2015 at 9:09

I would suggest an Ultrasonic Range Finder. There is an example in the Arduino Tutorials and they are available cheaply on ebay.

  • Can you add a link to the tutorial? Or at least describe the general idea?
    – dlu
    Dec 29, 2015 at 9:11

A linear encoder (usually comprising an LED, a photodetector, and an encoder strip with black lines on it) would work, but a long encoder strip is expensive and probably not reliable a garage environment. You could use a radial encoder attached to the motor, but that is probably too expensive too and overkill for your application.

Ranging devices are often difficult to use with something narrow and dirty like the bottom edge of a garage door. Placing devices on the door itself is probably not the most reliable and inexpensive way to do this either.

A Solution for Any Large Spring Loaded Position Sensing

One way that can be very reliable and is inexpensive is to use two strain gauges. In spite of the low cost, this approach is used in many industrial and laboratory arrangements. You could use an IN114 or a similar 8-pin dip instrument amplifier to convert the differential strain gauge resistance to a Voltage within the range of the Arduino analog input.

I'd guess a cost around $100 with shipping for the IN114, the rest of the circuit, strain gauges, emery cloth, bonding cement, temperature sensor (optional), power supply, jacks, solder, circuit housing, PCB breadboard, and cabling.

You will need to use a Wheatstone bridge at the + and - input of the instrument amp. There are plenty of example circuits. Search for, "instrument amp wheatstone bridge strain gauges," to get some schematic diagrams.

An adjacent two of the four legs of the Wheatstone bridge are the two strain gauges. One of the other two legs would be a potentiometer in series with a fixed resistor to give you offset adjustment. Another potentiometer adjusts gain. The IN114 spec sheet shows how to set the gain and how to power the chip.

Mechanically, the strain gauges would go on opposite sides of the exact same point on the spring, near where it attaches to the stationary frame to which the tracks are mounted. One strain gauge must be bonded to the inside of the spring. The other to the outside, directly opposite the inside one through the thickness of the spring wire. This will allow the Voltage you measure to indicate the strain on the spring which is related to the position of the door.

(The image at http://recordtek.com/sites/default/files/Gauge-spring.png shows a strain gauge bonded to the outside of the spring. The inside complement would go directly underneath it on the inside.)

I'd recommend an Arduino Due to read the output voltage of the IN114, setting the gain and offset to stay within the 1.55 to 2.75 V range of the analog inputs of the Due for all garage door positions. That will take some trial and error with a Voltmeter before you connect the Due.

To calibrate the system, the analogRead() values for ten somewhat equally spaced garage door positions are placed in an array of integers. Another same size array of doubles receives the corresponding door positions in whatever units you want. These can be static arrays that are initialized in your Arduino code.

You would get the position from the analogRead() at any point in time by interpolating the data in the table represented by the two corresponding arrays. That is easier than it sounds. There are articles explaining how and libraries providing linear interpolation in C, some of which may be usable without modification in an Arduino sketch.

Bonding the Strain Gauges

There are many articles available on using strain gauges and how to rigorously clean the surface and position and orient the gauges before bonding them to the metal of the spring. That's critical. They have to point in a particular direction, and the bond will come apart if you don't clean the metal well enough, which would not be good.

Going High End

If you wanted high accuracy, you could enhance your design to possibly get three or more significant figures as you reach expert level.

  • Read and factor in temperature when doing the interpolation
  • Take more than 10 calibration samples and use larger arrays to match
  • Use a quadratic or cubic interpolation instead of linear
  • Write a calibration algorithm to fill the two arrays with new values automatically every time the door goes from one extreme position to the other

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.