I want to use a hall effect sensor to detect when a door is close or not; the sensor would be in the door frame, and a little permanent magnet would be on the door. However, I learned that the sensor I got is latching: at first it outputs 0, when I bring the magnet in the right direction it turns 1, and when I remove the magnet it stays 1.

For my project, I want the sensor to turn HIGH only when the magnet is close to the sensor. To solve this, I could probably get a different non-latching hall effect sensor, but I wanted to know if there was a way to do this with the current sensor I have.

I thought about using a 2nd magnet that would by default make the sensor output 0, but would not be powerful enough to compensate the field generated by the magnet on the door.

Better ideas? Is it worth it?

  • \$\begingroup\$ Why not just use a simple reed switch? \$\endgroup\$
    – Pentium100
    Feb 13, 2016 at 9:21
  • \$\begingroup\$ What happens when you remove power from it? Does it revert back to 0? \$\endgroup\$
    – Steve G
    Feb 13, 2016 at 10:18
  • \$\begingroup\$ Hall sensor just doesn't work as you described, it just detects magnetic field and it doesn't latch. \$\endgroup\$ Feb 13, 2016 at 10:41
  • \$\begingroup\$ @MarkoBuršič there are latching hall effect sensors. allegromicro.com/en/Design-Center/Technical-Documents/… \$\endgroup\$
    – Steve G
    Feb 13, 2016 at 10:43
  • 1
    \$\begingroup\$ @MarkoBuršič: See Melexis MLX92211-AxA 3-Wire Hall Effect Latch, page 1. "With latching magnetic characteristics, the output is turned low or high respectively with a sufficiently strong South or North pole facing the package top side. When removing the magnetic field, the device keeps its previous state." \$\endgroup\$
    – Transistor
    Feb 13, 2016 at 14:06

1 Answer 1


The document @SteveG linked describes the latching hall effect sensor as latching one value when it detects either a positive ("north") or negative ("south") field and switching to the other value only when it detects the opposite field. Your magnet has both north and south ends, so you should arrange for the magnet to pass north and south across the sensor in one direction when the door is closing and in the opposite direction when the door is opening. If the setup is N then S when the door is closing, and S then N when it is opening, then the sensor will output the latched S value when the door is closed and the latched N value when it is open. The magnet would have to be one where the N and S ends were separated by some distance, like a bar magnet. A disk magnet probably wouldn't work because it would be difficult to pass the N and S sides across the sensor in the manner described.

  • \$\begingroup\$ yeah interesting idea. Might have a schema of it? I have a disk magnet, so the magnet has to be flat on the door' surface (otherwise it won't close). I'll test later anyway if your idea works. \$\endgroup\$
    – jonathanGB
    Feb 13, 2016 at 21:39
  • \$\begingroup\$ A disk magnet will have N on one side and S on the other, so I don't think you could set it up the way I've described. You'd need a bar magnet, I think. \$\endgroup\$ Feb 14, 2016 at 14:27
  • \$\begingroup\$ Ok yeah, makes sense. Could you edit your answer with that restriction and ill vote it. \$\endgroup\$
    – jonathanGB
    Feb 14, 2016 at 17:46
  • 1
    \$\begingroup\$ I'll do anything for a few reputation points! Done. \$\endgroup\$ Feb 14, 2016 at 19:24

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.