# Hall effect sensor as 2 wires switch

I need to find a way to make an on/off proximity detector triggered by a magnetic field, fitting in a small space of about 5mm ^ 3, and connected to the board by only 2 wires. I know a could use a reed sensor but I would like to avoid using it because as far as I know, it is not widely used in industry. I would like to know if it is possible to do the same using a Hall sensor like this one AH182.

Here is its block diagram

I spent some time learning how Hall sensors work and it seems possible to do what I want using a simple voltage divider like this (Vcc is a +5V regulated power supply).

This sensor has an open collector NPN transistor, so if no magnetic field is detected then no current can flow through the output, and therefore the sensing voltage is about equal to 0 (R2/(R1+R2)*Vcc). On the contrary, if a magnetic field is detected, the current can flow through the output and the sensing voltage is equal to Vcc, while making sure that the output current does not exceed the maximum rating current of 10mA.

I doubt it is as simple as that because otherwise, I don't understand why special type of Hall effect sensor for 2 wires applications exist, like this one MLX92241. I would like to avoid such application specific device if possible, for the same reasons I mention about the reed sensor.

• What happens to Vdd when the output turns on in your configuration? – ThreePhaseEel Dec 25 '18 at 19:56
• I just added the block diagram of the AH182. I don't really know what happens. I guess nothing in particular. – milembar Dec 25 '18 at 20:01
• What is your Vcc voltage? – Transistor Dec 25 '18 at 20:03
• A +5V regulated power supply. – milembar Dec 25 '18 at 20:09
• As wired, your circuit will pull the voltage across the Hall sensor to zero when it is active. It needs to have some voltage between VDD and GND to operate (the value is in the data sheet). Also, if its voltage changes it may upset the operation of the device -- I wouldn't be surprised if its threshold didn't depend somewhat on VCC. – TimWescott Dec 25 '18 at 20:16

Your proposed circuit would not work because when the output turns on it will short Vdd to GND, power down the chip, turning off the output, removing the short which will power up the chip which will turn on the output ...

simulate this circuit – Schematic created using CircuitLab

Figure 1. A better way?

The datasheet says the device will work down to 2.5 V and that in the off condition the current through it will be measured in μA. (Double-check this. It's not that clear in the datasheet which refers to "enable" which I suspect means "activated" by a magnet.)

In my Figure 1 R2 provides a path to ground as well as a point to monitor the current. In the quiescent state the output voltage would then be $$\ V_{out} = 10\mu \times 1k = 10\ \text {mV} \$$. The AH182 would have almost full 5 V supply across it.

When the device turns on R1 limits the current through M1 and creates a potential divider between R1 and R2 so that Vout will be half-supply, 2.5 V. This leaves 2.5 V to supply the AH182 which is just at the minimum operating limit. I'd be inclined to decrease R2 to 820 Ω to give a little more voltage to the AH182.

@TimWestcott has pointed out that the switching threshold may change if you change the chip voltage like this. He may be right but there is no indication of this in the datasheet.

Your 2-wire requirement means that you'll have to mount R1 at the sensor.

Try it and see.

About the "chip enable" and "chip disable" modes, I found more information in AH1807. As you can see in the block diagram of the AH182, there is a "Reg./Switch" block. According to AH1807, the device is "enable" about 0.1% of the time, and drawing about 2mA max when it is the case, 8 uA max otherwise, for an average of 10uA max. The chip mode switching frequency is quite low, about 8Hz. – milembar 40 mins ago

Good work. That explains a lot. We need to redesign then as my Figure 1 wasn't allowing for that 2 mA through the chip. We can create a table of desired outputs.

Table 1.

Chip EN    Ouput     Current    Notes
---------+---------+----------+-------------
Off        Off       8 uA
On         Off       2 mA
Off        On        5 mA       Half the rated max.
On         On        7 mA       Combination of the chip and output current.


With this arrangement you could set the threshold at 3.5 mA and have a good chance of success.

simulate this circuit

Figure 2. Modified for new information.

• To keep > 2.5 V across the AH182 we'll go for 2.1 V across R2 at 7 mA. That gives us a value of 300 Ω.
• We'll now have 2.9 V available for the chip and 5 mA running through R1. The voltage drop across the output transistor is listed as 0.3 V max at 1 mA. Let's assume 0.5 V max at 5 mA and you can test it. That leaves 2.9 - 0.5 = 2.4 V across R1 at 5 mA giving a value of 480 Ω. 470 Ω is the nearest standard value. Let's update the table.

Table 2.

Chip EN    Ouput     Current    Vout (I x 330 Ω)
---------+---------+----------+-------------
Off        Off       8 uA       2.6 mV
On         Off       2 mA       660 mV
Off        On        5 mA       1.65 V
On         On        7 mA       2.31 V


This looks as though a threshold of around 1 V might work for you.

• Thank you for your help! The first design that came to my mind was this one but as you mention I was not very excited about having to solder the resistor directly on the sensor. I guess it is the way to go anyway. I'll try it! – milembar Dec 25 '18 at 21:07
• About the "chip enable" and "chip disable" modes, I found more information in AH1807. As you can see in the block diagram of the AH182, there is a "Reg./Switch" block. According to AH1807, the device is "enable" about 0.1% of the time, and drawing about 2mA max when it is the case, 8 uA max otherwise, for an average of 10uA max. The chip mode switching frequency is quite low, about 8Hz. – milembar Dec 25 '18 at 21:51
• See the update. – Transistor Dec 25 '18 at 22:53
• I think your computation of Vout for Chip EN ON and Output ON is wrong (see my answer). Using my formula it gives Vout=2.07 V instead of 2.31 V – milembar Dec 26 '18 at 10:49
• The last line of my Table 2 is using 7 mA x 330 Ω = 2.31 V. Which formula do you want me to use? – Transistor Dec 26 '18 at 11:00

The chip has a sleep mode. The device is "enable" during 0.1% of the time, and drawing about 2mA max when it is the case, 8 uA max otherwise, for an average of 10uA max. The chip mode switching frequency is about 8Hz. Here is the table of the states:

Table 1: States

 Chip EN    Output    Current   Vout
---------+---------+----------+--------
Off        Off       8 uA     V_off_off
On         Off       2 mA     V_on_off
Off        On        TBD      V_off_on
On         On        TBD      V_on_on


The measured voltage $$\V_{out}\$$ can be estimated using Generalized Millman law:

$$V\_off\_off = R_2 \times 8\mu A$$ $$V\_on\_off = R_2 \times 2mA$$ $$V\_off\_on = \frac{R_2}{R_1+R_2} \times V_{cc} + \frac{R_1R_2}{R_1+R_2} \times 8\mu A$$ $$V\_on\_on = \frac{R_2}{R_1+R_2} \times V_{cc} + \frac{R_1R_2}{R_1+R_2} \times 2mA$$

The datasheet says the device will work down to 2.5 V, and $$\I_{out} < 10mA\$$. It gives: $$V_{cc} - V\_on\_off > 2.5V \implies R_2 < \frac{V_{cc} - 2.5V}{2mA}$$ $$V_{cc} - V\_on\_on > 2.5V \implies R_1 > R_2 \times \frac{2.5V}{V_{cc} - 2.5V - R_2 \times 2mA}$$ $$I_{out} < 10mA \implies \frac{V\_on\_on}{R_2} < 10mA \implies 5 R_2 + 4 R_1 > \frac{V_{cc}}{2mA}$$

The minimum voltage drop induces by the detection of the magnet and the optimal Voltage threshold are given by: $$\Delta V_{out} = V\_off\_on - V\_on\_off > 100mA \text{ (to measure using 10-bits ADC)}$$ $$V_{th} =\frac{V\_on\_off + V\_off\_on}{2}$$

Let's assume that the voltage power supply is unknown and could be either 3.3V or 5V. $$\V_{cc} = 3.3V\$$ is the most limiting case for the operating voltage of the Hall sensor and minimal voltage drop, and $$\V_{cc} = 5V\$$ is the most limiting case for the current. It should work for both cases with $$\R_1=560\$$ and $$\R_2=100\$$.

Table 2: $$\V_{cc}=3.3V\$$

 Chip EN    Output    Current    Vout
---------+---------+----------+----------
Off        Off      8 uA       0.8 mV
On         Off      2 mA       200 mV
Off        On       5.0 mA     500 mV
On         On       7.4 mA     670 mV


Table 3: $$\V_{cc}=5V\$$

 Chip EN    Output    Current    Vout
---------+---------+----------+----------
Off        Off      8 uA       0.8 mV
On         Off      2 mA       200 mV
Off        On       7.6 mA     756 mV
On         On       9.3 mA     927 mV


A threshold of 350mV might work. Using a 10-bit ADC with a reference voltage of either Vcc or 1.1V, the resolution is about 1mV, which more than enough in principle. I expect in practice an accuracy clearly better than 50mV. So it should be OK for both 3.3V and 5V power supply.

• @Transistor It might also work with R1=560, to keep it constant whatever the voltage of the power supply. By doing so it is quite convenient to adapt the design to work either with 3.3V or 5V power supply since R2 is not mounted to the sensor. – milembar Dec 25 '18 at 23:47
• That might work then. On a separate note, you can't do chat on this site like on a regular forum. Answers (which must be actual answers) float up and down with votes or user sorting preference making it impossible to have a conversation. You have to either post it in your original question as an update / clarification or post it as an actual answer. – Transistor Dec 25 '18 at 23:51
• Ok thank you I'll update my post later accordingly. – milembar Dec 26 '18 at 0:41
• I see your edit. I think you are well on the way to solving this. Have fun! – Transistor Dec 26 '18 at 10:46