# Cancel latching hall effect sensor effect

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?

• Why not just use a simple reed switch? – Pentium100 Feb 13 '16 at 9:21
• What happens when you remove power from it? Does it revert back to 0? – Steve G Feb 13 '16 at 10:18
• Hall sensor just doesn't work as you described, it just detects magnetic field and it doesn't latch. – Marko Buršič Feb 13 '16 at 10:41
• @MarkoBuršič there are latching hall effect sensors. allegromicro.com/en/Design-Center/Technical-Documents/… – Steve G Feb 13 '16 at 10:43
• @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." – Transistor Feb 13 '16 at 14:06

## 1 Answer

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.

• 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. – jonathanGB Feb 13 '16 at 21:39
• 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. – Willis Blackburn Feb 14 '16 at 14:27
• Ok yeah, makes sense. Could you edit your answer with that restriction and ill vote it. – jonathanGB Feb 14 '16 at 17:46
• I'll do anything for a few reputation points! Done. – Willis Blackburn Feb 14 '16 at 19:24