All articles

    The Hall Effect Sensor: Sensing a Magnet Without Touching It

    Hall sensors explained: the digital A3144 with its open-collector output that needs a pull-up and how to run it with an ESP32, the analog 49E that measures field strength and polarity, the types (unipolar, bipolar, latching), why the pole and distance matter, an RPM speed-counter project, a comparison with the reed switch, and common faults.

    Updated 6 min read

    Want to count a wheel's turns? Know whether a door is open or closed? Measure a motor's speed? A Hall sensor detects a magnet without any contact, so there's no friction or wear as there is with mechanical switches.

    The magnet approaches the sensor, and the output changes
    The magnet approaches the sensor, and the output changes

    The idea

    When current flows through a chip and a magnetic field approaches it, the field pushes the electrons towards one side of the chip, producing a small voltage between the two sides (microvolts to millivolts). The sensor has an amplifier inside that boosts this voltage, and in the digital types it also has a comparator that turns it into ON or OFF.

    Two important points follow from this:

    • The sensor detects only the field perpendicular to its face. A magnet coming from the side may have no effect.
    • The direction of the field matters: the north pole produces a voltage one way, and the south pole the other way.

    Two main types

    Digital: the A3144 (and similar)

    • ON or OFF: the output changes when the magnet approaches.
    • It detects one pole only (usually the south pole facing the marked side of the sensor). If it doesn't work, flip the magnet.
    • The output is open-collector: it needs a pull-up (10k, or INPUT_PULLUP).
    • The output goes LOW when it detects.
    pinMode(2, INPUT_PULLUP);
    bool magnet = digitalRead(2) == LOW;

    Wiring: the pins, viewed from the marked face, from the left: VCC, GND, OUT.

    Note: the original A3144 has been discontinued, and much of what's on the market is lookalike chips. There are also latching types that stay in their state until the opposite pole approaches, so know your type.

    With an ESP32 (3.3 V)

    The A3144 needs a supply of at least 4.5 V, so at 3.3 V it may not work, or work only sometimes. The fix is easy thanks to the open-collector output: power the sensor from 5 V, and keep the pull-up at 3.3 V (or INPUT_PULLUP on the ESP32). That way the output never rises above 3.3 V, and the pin is safe. Or use a sensor designed for 3.3 V in the first place.

    Analog: the 49E (SS49E)

    • It gives a voltage proportional to the field strength.
    • With no magnet → about half the supply voltage.
    • One pole → the voltage rises, the other pole → it falls.
    • Read it with analogRead. See the ADC.
    • Useful for measuring approximate distance or position, or for a joystick.
    const int ZERO = 512;          // the reading with no magnet, measure yours
    int r = analogRead(A0) - ZERO;
    if (r > 40)       Serial.println("one pole");
    else if (r < -40) Serial.println("the other pole");
    else              Serial.println("no magnet");

    Measure ZERO yourself with the magnet far away, because it varies from one sensor to another and with the supply voltage. The margin (40 here) stops noise from making the reading jump. Its sensitivity is roughly 1.4–2 mV per gauss, meaning a weak magnet a few centimetres away may change the ADC reading by only a few steps.

    Types by how they respond

    TypeSwitches on withSwitches back whenExample
    UnipolarOne pole approachingThe magnet moves awayA3144
    BipolarA poleThe opposite pole approaches (usually)some motor chips
    LatchingA poleThe opposite pole must approachUS1881
    Analog (linear)Continuous voltage by strength—SS49E

    The latching type is excellent with a ring magnet on a motor (alternating poles), because each turn gives clean pulses. And it's mostly wrong for a door sensor.

    The modules

    Many modules carry the sensor + an LM393 comparator + a potentiometer + an LED, giving you a digital output with an adjustable threshold, and sometimes an analog output too. These modules usually run on 3.3 or 5 V, and the output follows the supply.

    Project: an RPM speed counter

    A small magnet on the wheel or the motor shaft, and the sensor facing it. Each turn = one pulse. Counting with interrupts so we don't miss a single pulse:

    volatile unsigned long pulses = 0;
    void onPulse() { pulses++; }
    
    void setup() {
      Serial.begin(115200);
      pinMode(2, INPUT_PULLUP);
      attachInterrupt(digitalPinToInterrupt(2), onPulse, FALLING);
    }
    
    void loop() {
      static unsigned long last = 0;
      if (millis() - last >= 1000) {
        last = millis();
        noInterrupts();
        unsigned long p = pulses; pulses = 0;
        interrupts();
        Serial.print("RPM = ");
        Serial.println(p * 60);      // one magnet = one pulse per turn
      }
    }

    Note the use of millis instead of delay. If the speed is low (under 60 RPM), counting for one second gives jumpy numbers (0, 60, 0...). It's better then to measure the time between two pulses with micros(), and speed = 60,000,000 ÷ the time in microseconds. And if you want the wheel's speed in km/h: wheel circumference × turns per hour.

    Hall sensor or reed switch?

    A reed switch is a small switch inside a glass tube, which closes when a magnet approaches.

    Hall sensorReed switch
    Needs power?Yes, it draws current all the timeNo, an ordinary switch
    SpeedThousands of times a secondLimited, and it bounces like a button
    LifespanNo moving partsMillions of operations, but the glass breaks
    PoleUsually mattersDoesn't matter

    For a battery-powered door sensor, the reed is better because it draws no power at all. For a speed counter or a motor, Hall.

    Uses

    • A turn or speed counter: as in the project above. The same idea is inside water flow sensors.
    • A door or window sensor: a magnet on the door leaf.
    • Motor position: BLDC motors contain Hall sensors.
    • Current measurement: sensors such as the ACS712 are built on the same idea. See current sensing.

    Tips

    • Distance matters a lot: the field weakens quickly with distance. A small neodymium magnet makes a big difference.
    • If the counter counts twice per pass, there's jitter at the threshold. Use a sensor with hysteresis or a filter in code.
    • A 100 nF capacitor across the sensor's supply, close to it.
    • How do you tell the magnet's pole? Bring it near a 49E: if the reading rises, that's the pole that raises it, so mark it.

    Common faults

    FaultUsual cause
    No response at allWrong pole, or the magnet is coming from the side
    The output doesn't change at 3.3 VThe A3144 needs at least 4.5 V
    The output jumps by itselfA floating pin with no pull-up
    It only works very closeA weak magnet, or too much distance
    It stays ON after the magnet moves awayIt's a latching type

    FAQ

    Is the sensor getting hot? If it's getting hot, the pins are probably reversed. Disconnect immediately and check the order.

    Can I measure the field in gauss with it? With a 49E, roughly yes: the voltage difference from the midpoint ÷ the sensitivity from the datasheet. For high accuracy there are dedicated sensors.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.