A3144 Hall effect sensor

The Allegro A3144 Hall effect switch in a flat TO-92, and the magnet you hold up to it. Aliases: Hall sensor, KY-003, magnetic switch.

It looks like a transistor and is a whole chip: a Hall plate, an amplifier, a Schmitt trigger and an open-collector output. Bring the south pole of a magnet up to its printed face and OUT pulls to ground. It is the sensor in bike speedometers, fan tachometers and "is the lid shut" projects.

Pins

Printed face towards you, left to right:

Pin What it does
VCC Supply, 4.5 V to 24 V.
GND Ground.
OUT Open collector: pulled low while the magnet is there, let go otherwise.

Properties

operate is the field it switches on at, 210 gauss by default, and hysteresis is how much weaker the field must get before it switches off, 55 gauss.

While it runs

The slider is the magnet's distance from the printed face, 0 to 40 mm. Click the magnet to turn it round. The dot on the body lights while OUT is pulled low.

Reading it on an Arduino

OUT only ever pulls down, so it needs a pull-up, and it reads LOW when the magnet is there:

pinMode(2, INPUT_PULLUP);
bool magnet = digitalRead(2) == LOW;

What the model gets right

Open collector. From the Allegro A3141-A3144 datasheet: OUT sinks up to 25 mA at about 175 mV, and off it is high impedance. With no pull-up the pin floats.

South pole only. It is unipolar: a south pole at the printed face operates it, and a north pole does nothing however close it comes. That is the first thing a class tries.

Switch points and hysteresis. The sheet gives the A3144's operate point as 70 to 350 G and its hysteresis as 55 G typical. The part uses 210 G, the middle of that spread, so with the magnet below it switches on at about 10.5 mm and off at about 11.5 mm.

The magnet. A 10 mm by 3 mm N35 disc, face on, with the textbook on-axis field: about 3 kG at its face, 230 G at 10 mm and 90 G at 15 mm.

The supply. It has its own regulator and wants 4.5 V. On a 3.3 V board a bare A3144 does nothing here, as on the bench.

What it does not model

Switch points moving with temperature, rise and fall times (under 2 µs), and fields that are not along the axis.

Common mistakes

No pull-up. OUT is open collector, so without INPUT_PULLUP or a 10 k resistor the pin floats.

The wrong pole. Turn the magnet round.

See it in action

Heat, magnet and wheel lights the Uno's LED when the magnet comes near. Open it at /templates.