Arduino hardware for detecting a door or gate open state? from 0 to 90 degrees

Does anyone have any suggestion what i could attach to an arduino sensor to detect the angle for a door or gate in degrees? I don’t need a very exact match, 5-10% per step would be enough.

Thank you!

Maybe a gyro would work for you?

I think that would be ok for detecting movement, not the current state based. I’m looking now at bend sensors - https://www.sparkfun.com/products/8606.
This, coupled with a normal open/closed magnetic switch to detect the gate is fully closed will do the job. Ordered the parts and i will keep this thread updated with my findings.

Could you possibly use a distance sensor? ( ultrasonic )

or what about a potentiometer connected to the hinge? or a rotary encoder mounted the same way?

or a series of reed switches?

Rotary encoder looks like a neat solution gregl!

Here are some Arduino examples:
http://playground.arduino.cc/Main/RotaryEncoders

Only problem is how to mount it properly :slight_smile: Maybe reed switches are simpler.