Hall Effect Sensors Explained: Switch vs Latch vs Linear

Six hall effect sensors, all in identical little black packages. Here is how to tell them apart and pick the right one first time.

What a hall effect sensor actually does

A hall effect sensor detects a magnetic field without touching anything. No moving parts, no contacts to wear out, no switch bounce to code around. Bring a magnet close and the sensor reacts.

That makes them the right tool whenever you need to sense position, rotation or presence through a gap, through a plastic wall, or somewhere dusty, wet or vibrating that would kill a mechanical switch. A hall sensor is what counts the wheel revolutions in a bike computer, what tells a 3D printer where the axis ends, and what tells a brushless motor which coil to fire next.

The catch: "hall effect sensor" covers three genuinely different components that behave in different ways. Choosing the wrong type is the single most common reason a magnet project does not work, and you cannot tell them apart by looking. Everything below is about making that choice correctly.

The three types

1. Switch (unipolar)

On while a magnet is present, off when it leaves. This is what most people picture when they think "magnetic sensor", and it is the right choice about 70% of the time.

The important detail is in the word unipolar: it only responds to one magnetic pole. Present the south pole to the printed face and it triggers. Turn the same magnet around and nothing at all happens. That surprises a lot of people the first time.

Our parts: A3144 and OH137. The A3144 is the classic workhorse and what we would reach for by default. The OH137 is typically more sensitive, so it triggers on a weaker magnet or across a slightly wider gap, which helps when the magnet has to sit further away than you would like.

2. Latch (bipolar)

A south pole turns it on, and it stays on after the magnet is gone. It takes a north pole to turn it off again. A latch remembers its last state.

This is the type that catches people out. Fit a latch where you meant to fit a switch and it looks broken: it triggers once, then never releases no matter what you do. Nothing is faulty, it is simply waiting for the opposite pole.

Where a latch genuinely wins is anything spinning past alternating poles: a ring magnet with north and south segments, brushless motor commutation, or high speed RPM counting. Because the output only flips at a pole transition, you get clean, unambiguous edges with none of the jitter you can get from a switch hovering near its release threshold.

Our parts: 41F and US1881. The US1881 is the usual pick for BLDC motor work.

3. Linear (analog)

Not on or off at all. A linear sensor outputs a voltage that moves smoothly with how strong the field is and which pole is facing it.

With no magnet nearby the output sits at half the supply voltage, so about 2.5V on a 5V rail. A south pole facing the marked side pushes it up from there, a north pole pulls it down. The further it moves from that midpoint, the stronger the field, until it saturates and stops responding.

Use a linear sensor when you need to measure rather than just detect: how far away the magnet is, how much current is flowing through a wire, or where a throttle or joystick is sitting through its whole range of travel.

Our parts: 49E and AH3503. They behave the same way, and the difference that matters in practice is supply voltage: the 49E runs from 3V so it suits a 3.3V ESP32 directly, while the AH3503 needs at least 4.5V and has to be run from 5V. The AH3503 is the more sensitive of the two at about 22mV per mT.

Which one do I need?

What you are building Type Part to use
Door, lid or drawer open/closed detection Switch A3144
Same, but the magnet has to sit further away Switch OH137
RPM from one magnet on a wheel or shaft Switch A3144
RPM from a multi-pole ring magnet Latch US1881 or 41F
Brushless motor commutation Latch US1881
3D printer or CNC endstop Switch A3144
Measure how close a magnet is Linear 49E or AH3503
Measure current in a wire Linear 49E or AH3503
Linear sensing on a 3.3V board Linear 49E
Contactless throttle, joystick or dial Linear AH3503
Not sure yet, still experimenting All three Start with the A3144

The full range side by side

Part Type Supply Output Turns on Turns off
A3144 Unipolar switch 4.5V to 24V Open collector, active low South pole near Magnet removed
OH137 Unipolar switch 4V to 24V Open collector, active low South pole near Magnet removed
41F Bipolar latch 3.5V to 24V Open collector, active low South pole North pole
US1881 Bipolar latch 3.5V to 24V Open collector, active low South pole North pole
49E Linear analog 3V to 6.5V Analog, ratiometric Continuous output, no threshold
AH3503 Linear analog 4.5V to 6V Analog, ratiometric Continuous output, no threshold

Note the supply ranges. The four digital parts run on anything from 3.5V or 4.5V up to 24V, so they drop straight into 12V and 24V systems. The two linear parts are low-voltage devices and will not survive 12V. Of those two, only the 49E will run from a 3.3V rail; the AH3503 needs 5V, and on a 3.3V board its output then has to be divided down before it reaches an ADC pin.

Wiring, and the pull-up resistor everyone forgets

All six parts share the same pinout. Hold the sensor with the printed flat face toward you and the legs pointing down, then read left to right:

Pin Connect to
1 (left) VCC
2 (middle) GND
3 (right) OUT

Check before you power up. Reversing VCC and GND will destroy the sensor almost instantly, and a dead hall sensor looks exactly like a working one. The datasheet is linked on each product page if you want to confirm.

Now the part that trips up most first attempts. The four digital sensors have an open collector output. That means the output pin can only pull down to ground. It cannot drive itself high. Left on its own it floats, and your readings will be random noise that seems to respond to your hand rather than the magnet.

The fix is a pull-up resistor from OUT to VCC. You can fit a physical 10k resistor, or you can just let the microcontroller do it in one line of code:

pinMode(hallPin, INPUT_PULLUP);

Because the output pulls to ground when it triggers, the logic reads backwards from what you might expect: LOW means a magnet is detected, HIGH means no magnet.

The linear sensors do not need any of this. They drive their output actively, so you wire OUT straight to an analog input.

Code

Digital sensor (A3144, OH137, 41F, US1881)

const int hallPin = 2;

void setup() {
  Serial.begin(9600);
  pinMode(hallPin, INPUT_PULLUP);   // essential: the output is open collector
}

void loop() {
  // LOW = magnet detected, because the output pulls to ground
  if (digitalRead(hallPin) == LOW) {
    Serial.println("Magnet detected");
  } else {
    Serial.println("No magnet");
  }
  delay(200);
}

Linear sensor (49E, AH3503)

const int hallPin = A0;
int zero = 512;   // idle point: about Vcc/2, so ~512 counts on a 5V Arduino

void setup() {
  Serial.begin(9600);
  delay(100);
  zero = analogRead(hallPin);   // calibrate with no magnet nearby
}

void loop() {
  int raw = analogRead(hallPin);
  int offset = raw - zero;      // positive = south pole, negative = north pole

  Serial.print("raw: ");
  Serial.print(raw);
  Serial.print("   offset: ");
  Serial.println(offset);
  delay(200);
}

Calibrating the zero point at startup rather than hard-coding 512 makes the reading far more stable, and it is what lets the same sketch work on a 3.3V ESP32 without changes.

Magnet polarity: the other half of the problems

If your wiring is right and the sensor still does nothing, turn the magnet around. It fixes an enormous share of hall sensor problems.

Unipolar switches only respond to a south pole on the printed face. Latches need to see both poles to cycle properly. On the linear parts a south pole drives the output up and a north pole drives it down. And the sensing element sits in the flat printed face of the package, not the rounded back, so that is the side that needs to point at the magnet.

Small neodymium magnets work far better than the flexible fridge-magnet type, which are often too weak to trigger anything reliably.

Troubleshooting

Problem Likely fix
Output flickers randomly, reacts to your hand No pull-up. Use INPUT_PULLUP or a 10k to VCC
Nothing happens with any magnet Flip the magnet over, then check the flat face is pointing at it
Triggers once and never releases You have a latch (41F, US1881). Use a switch, or present a north pole
Reads inverted from what you expected Normal. LOW means detected on all four digital parts
Analog output stuck near 512 and will not move Magnet is too weak or too far away. Try a neodymium magnet
Analog readings are erratic on an ESP32 Check the supply. The AH3503 needs 4.5V minimum, so use the 49E on 3.3V
Analog reading drifts as the battery drains Ratiometric output. Power the sensor from the same rail your ADC references
Sensor got warm then stopped working VCC and GND were reversed. The part is gone, fit a new one
Only works with the magnet touching the sensor Try the OH137, it triggers on a weaker field

Choosing in one line

  • Is it there or not? Use a switch. A3144.
  • Is it spinning past alternating poles? Use a latch. US1881.
  • How strong, how close, how far? Use a linear sensor. 49E.

All six are in stock in New Zealand and ship from Te Awamutu. They are inexpensive enough that buying a few of each type to experiment with costs less than a coffee, and volume pricing kicks in from 10 units.

Shop all hall effect sensors →


Stuck on a build? Get in touch. We are New Zealand based and happy to help you work out which sensor your project needs.