# Tiny Magnet Sensor Switch

I know just enough about electronics to do the occasional Arduino or Raspberry Pi project, as long as I don't have to understand too much of what's going on. I am a software guy who dabbles in hardware a tiny bit. So, I'm not even sure I can form a good question, which is why I haven't been able to Google an answer to this question.

I have made a small wearable device (about 30mm x 30mm x 10mm) that has one simple job. There is a magnet clipped onto the device. When the magnet is removed, it tells my phone (via BLE). Think of a sort of personal alarm device.

My first prototype uses a NC reed switch and works perfectly ... except that the reed switch is quite susceptible to false activation when jostled around too much. The device should only activate when the magnet is removed. As an improvement, I figured the solution was probably to use a hall effect IC. I've also read a little bit about MEMS. Cost is not an issue, within reason (i.e. sub-$20), but size and durability are absolutely important. My questions: 1. First, is a hall effect IC an appropriate solution, or is there something else that would work better? 2. My assumption is that I must use a NC switch that is open when the magnet is nearby. This makes a digital IO pin go HIGH only when the magnet is removed. My reasoning is that if the switch is NO, then it will be closed when the magnet is nearby, making the IO pin HIGH most of the time. I believed that this would be an unnecessary drain on the battery. But, I recently read something to suggest that digital IO doesn't work like this. So, my question is ... does it use more power to maintain HIGH state than LOW? 3. Am I thinking about this all wrong? Is there a simple way to accomplish the same thing in a very tiny package? I am using a 3V logic Arduino derivative with plenty of pins. The device currently uses just about 50uA, on average, and I'd like to keep it that way. • You can put a series R, shunt C filter to remove the Hall sensor glitch set RC =T delay – Sunnyskyguy EE75 Jul 9 '18 at 1:05 ## 2 Answers Your idea to use a Hall Effect device would seem to be ideal. There are plenty of Hall Effect sensors, here is one at about$0.40 that would be ideal IMO. It operates at 2.3 - 5V and has an open drain output and so could be used with a single digital input with just a high value pullup resistor. You could probably even just use the inbuilt pullup supplied on most MCUs (in the 20-50k Ohm range. You could search for others on Digikey.

It has ultra low power consumption, but you could drive it using a digital output pin, so it's only turned on when you want. I assume to get very low current consumption of your MCU you are spending most of your time in sleep mode. Before you go to sleep simply turn the port supplying power to an input (lowest power consumption) with no pullup resistor.

When you use a switching device like the reed relay it is either open or closed. When closed it can easily switch an MCU GPIO input pin to GND. However when the switch is open something has to take care of setting the MCU GPIO input back to a high level. That is normally done with a resistor to the VCC of the microcontroller. So the low current condition in this case would be when the switch is open. When the switch closes there is current being sunk from the resistor through the relay contact to the GND which is consuming power.

You could swap the resistor and reed switch around such that the resistor pulls the GPIO input to GND and the switch (with one side to the supply voltage) would be then pull the GPIO high when the switch closes.

In both cases the higher battery drain state is when the reed switch is closed so you would want to select a switch that opens when the magnet is present (assuming that the magnet present is the long duty cycle part of the usage scenario).

A Hall effect device should be the perfect device for your application. They are small, relatively inexpensive and rugged. When you select an sensor pick one that gives a simple high or low output based upon the presence of a certain strength magnetic field or absence thereof. There are other types of Hall sensors that produce an analog output based upon how strong the magnetic field is near the sensor (translates roughly to distance from magnet) but those are more expensive and have a complex procedure to calibrate them to a given magnet in a given operating environment.