I'm working on a midi controller to use while boating. I want to use a hinge for a midi control. This means I want to take the angle inside the hinge and convert it to a value between 0 and 127. The physical range of motion is 0-180 degrees. This means I need an angular position that has less than 180/127/2 or +/-0.7 degrees of error. This hinge could have an arbitrary angle with gravity.

There are numerous angular sensors but none seem to fit the bill entirely. Potentiometers are not accurate. Rotary encoders are prone to errors in high-humidity environments, like boating. IMU's don't work well when the waves are causing regular movement in the device.

I understand that there may not be a perfect solution, but before I go empirically testing each solution and trying to filter out imperfections, I thought I would ask for the advice of those more experienced. Any help you can give would be appreciated.


1 Answer 1


There are magnetic rotary encoders that use a permanent magnet mounted on the rotating shaft combined with two/four fixed magnetic sensors (GMR or Hall elements) for measuring the magnetic field in x- and y-direction with integrated signal conditioning in one IC.

I.e. there is no mechanical contact between rotating shaft and sensor. Sensor and electronics can be encapsulated and hermetically sealed.

enter image description here (Image taken from https://www.magcam.com/application/2-pole-rotary-encoder-magnets)

E.g. this one. Resolution is 14 bits, i.e. much more than what you required.

  • \$\begingroup\$ I actually looked into that and the only all-in-one solution I could find was by DFRobot and it cost $60. wiki.dfrobot.com/Gravity__Hall_Angle_Sensor_SKU__SEN0221. I will look again but to put a magnet into the hinge it would need to be cylindrical in shape with the poles orientation and a mounting rod like in the picture. If you know where I can find another all-in-one solution or where to get those kinds of magnets then let me know. \$\endgroup\$ Commented Jun 21, 2021 at 17:34
  • \$\begingroup\$ I looked into it a bit more and I think this one will be too expensive. I found other all-in-one hall effect sensors that were $21 for the cheapest one, but that is too much. Making on myself is difficult because it requires a cylindrical magnet that isn't so strong as to cause noise in nearby electronics, has a screw hole in its center for mounting and has poles as depicted above. I haven't found one that fits this description. I think I will try pots and rotary encoders under high humidity and bouncy tests unless someone can suggest a better solution. I appreciate you taking the time though. \$\endgroup\$ Commented Jun 21, 2021 at 19:51

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.