In this issue of "Useful parts" we’ll talk about reed switches and other types of magnet switches.

The goal is to use magnets to turn on/off LEDs or other functions on models that are deployed on the layout and need to be controlled by presence of other models.

An example of this is shown in this video where a construction site lamp is controlled by the presence of a generator model.

In the video the lamp contains most of the parts and includes LEDs, battery, mechanical switch and reed switch. (A battery protection did not fit).

Reed switch

The reed switch is a time-tested aproach to magnet-activation, and on aliexpress you can find reed switches glass tubes as small as 10x3mm.

Upside of the reed switch is that there is no leakage current at all, so it technically doesn’t even need a extra switch to power off.

Downside is that it can still be quite big if the project is very minuature. Also, it’s still a mechanical device, so has a limited resource (though quite high). It also probably needs some minimum load (wetting current) to properly conduct, otherwise the contacts may degrade and the device may get reduced performance after some time.

Hall effect sensor ICs

In addition to hese days we also can use hall effect sensors, which are rather affordable for DIY projects. While the simple Hall-effect sensor has analog output and needs some circuitry to turn into a switch, there are specialized sensors that are designed to be low-power and have a digital binary output.

Some of these low-power ICs can only supply sub-mA current, so are not suited for direct LED control. Most of my searching was focused on choosing ICs that can power LEDs without extra circuitry.

First chip that I found was MT8651AT from Magn Tek, the company I have never heard of. It has open drain output, can drive 8mA (absolute maximum), consumes single-digit microAmps (presice number is hard to get from the datasheet), works from 2-5.5V, single-cell LiIon battery is within specs. The sensor is unipolar, meaning it switches on with magnets of both polarities.

Recommended circuitry includes 2 capacitors and one pull-up resistor, which is not optimal, but workable.

Then I came across a whole family of DRV5032 magnetic sensors from TI.

Inside the family, devices have differenct sensitivities, refresh rates (with corresponding current consumption), have either push-pull or open-drain outputs.

They also come in omnipolar, unipolar or bipolar sensitivity types, meaning they respond to magnet of any polarity, only one polarity or respond differently to opposite polarities.

chip options

They can drive loads at maximum of 5mA, which is sufficient for an LED or two with a suitable resistor.

For my application I decided to use DRV5032DU, which is of unipolar type, so that the LEDs only turn on when a specific magnet pole is facing the device. I don’t need high refresh rate, so I chose the minimal one to reduce current consumption. Using push-pull type allows to to use it either as a high-side or a low-side switch.

Judging by the datasheet, idle current consumption should be around 1.6 uA, which is comparable to battery self-discharge current and will drain a small 200mAh battery in around 5 years (and a tiny 50 mAh in 1.3 years). So, while in realistic scenarios it can be permanently attached to the battery without switches, I’d still put a switch before the battery and toggle it off for long-term storage.

This is also on the same order of magnitude as power consumption of a battery protection IC like DW01 or XB3306 which is permanently attached to a battery. Although, at last in the case of DW01, it goes into even deeper sleep (0.1 uA) when below 2V to protect the battery for even longer. In case of XB3306 however, this deep sleep current is around the same 1.4 uA, which is not that impressive.

Magnetic field orientation (compass) ICs

Honorary mention goes to compass ICs which give output in a form of ordinary analog signal, suitable to feeding into ADC MCU pin. They serve a different purpose though, so you won’t use them to turn on LEDs in presence of a magnet. What they do is replace a potentiometer in position sensing applications. To be used in this task, a magnet needs to be attached to rotating piece, in a specific orientation (magnet axis needs to be perpendicular to rotation axis). It can be a special diametrically magnetized round magnet, or a normal magnet placed on side.

I tried 2 ICs, AS5600 and MT6701, both from AliExpress. First one was dead on arrival, second one worked pretty well and I can recommend it as a contactless potentiometer. In general, MT6701 appears to be favored more, e.g. see this SimpleFOC discussion.

These ICs can also be configured by I2C with values like minimum, maximum output, data format, etc.