Skip to content
IoT Crest

Hall effect sensor: how it works, types and uses

Published , 13 min read

Short answer: A Hall effect sensor is a small chip that detects a magnetic field and turns it into an electrical output, so a microcontroller can tell when a magnet is near, how strong its field is or which way it points. Switches and latches give an on or off output for doors, lids, flow meters, wheel speed and motor position; linear and 3D sensors give a reading that follows the field. It has no moving contacts, so it does not wear like a reed switch, but it needs a magnet placed with care and, unlike a reed switch, it draws supply current all the time.

How a Hall effect sensor works, its switch, latch, linear and 3D types, wiring to a microcontroller, common uses, and how it compares with a reed switch.

This article covers what the Hall effect is, what is inside a Hall sensor chip, the switch, omnipolar, latch, linear, 3D and current sensor types, how to wire each kind of output to a microcontroller, common uses in IoT projects, how a Hall sensor compares with a reed switch, its downsides, and what happened to the original ESP32's built-in Hall sensor. It does not cover magnet selection and magnetic simulation in detail, magnetoresistive and fluxgate sensors, or recommendations of particular modules to buy.

A Hall effect sensor is a small chip that detects a magnetic field and turns it into a signal a microcontroller can read. Put a magnet on a door, a wheel or a rotor, put the sensor next to it, and the chip tells you whether the magnet is near, how strong its field is, or which way it points. Because nothing touches, it has no contacts to wear, it can be sealed away from water and dirt, and it can count fast. This guide explains the physics in plain words, what is inside the chip, the main types, how to wire each one, where they are used, and how they compare with a reed switch. It sits with the sensors and hardware guides, next to the overview of IoT sensors and the microcontroller choice guide.

The Hall effect in plain words

Pass a current through a thin, flat plate of conductive material, then hold a magnet so its field passes through the plate at right angles. The field pushes the moving charges sideways, so they crowd toward one edge of the plate. One edge ends up with extra negative charge and the opposite edge with less, and that difference is a voltage across the width of the plate. It is called the Hall voltage, and it grows with the strength of the field.

Allegro MicroSystems’ Hall-effect IC applications guide describes the effect as discovered by Hall in 1879. Edwin Hall reported it in “On a New Action of the Magnet on Electric Currents”, published in the American Journal of Mathematics in 1879. Texas Instruments’ introduction, What Is a Hall-effect Sensor?, gives the same picture: a small voltage develops across the conductor as current is forced through it and a magnetic field is applied in an orthogonal direction.

The Hall effect in a thin conductor - - - - - - - - + + + + + + + + current in current out V Hall voltage magnetic field B, into the page The field pushes the moving electrons toward one edge of the plate. The voltage across the plate grows with the strength of the field.
Diagram: the Hall effect in a thin conductor. A current flows into the plate from the left and out on the right. A magnetic field passes through the plate into the page, shown by the crossed circles. The field pushes the moving electrons toward the top edge, which becomes negative, and leaves the bottom edge positive. Two contacts in the middle of the top and bottom edges connect to a voltmeter that reads the Hall voltage across the plate, which grows with the strength of the field.

The catch is size. TI notes that the output of a bare Hall element is tiny, sometimes in the microvolt range, which is why nobody wires a raw element to a microcontroller.

What is inside a Hall sensor chip

A Hall sensor IC (integrated circuit) puts the element and its support circuit on one piece of silicon. Allegro’s guide lists the parts of a digital Hall switch: a Hall voltage generator, a signal amplifier, a Schmitt trigger and an output transistor, which is usually an open-collector NPN or an N-channel FET. Linear versions replace the trigger with an analog output stage and add a stable amplifier and voltage regulator.

The Schmitt trigger is a comparator with two thresholds. The output switches on when the field rises past the operate point, called BOP, and switches off only when the field falls below a lower release point, BRP. The gap between the two is the hysteresis, and TI’s article explains that it stops the output bouncing back and forth when the field sits near a threshold.

The simplest parts have three pins, for supply, ground and output, in a small surface-mount SOT-23 or a through-hole TO-92 package. Direction matters: Allegro says the field must cross the active area at right angles, and TI’s DRV5055 linear sensor senses flux perpendicular to the top of the package. TI notes that most datasheets give the expected direction of the field relative to the package surface.

Types of Hall effect sensor

TI’s article groups position sensors into three families, and two more types matter for IoT projects.

Unipolar switch. Turns on when one magnetic pole, usually south, comes close enough to pass BOP, and turns off when it moves away past BRP. Allegro describes a unipolar part as having its switch points entirely in the south range. The other pole does nothing.

Omnipolar switch. The same, but either pole turns it on, which means you do not have to care which way round the magnet is fitted. TI’s DRV5032 comes in omnipolar and unipolar versions.

Latch. Turns on with a south pole and stays on after the magnet leaves. According to Allegro, it releases only when a north pole comes past. That makes latches suit alternating poles, such as a ring magnet on a shaft.

Linear. Gives an analog voltage that follows the field. TI’s article explains that with no field the output sits at half the supply voltage, then moves toward the supply for one pole and toward ground for the other until it saturates. The DRV5055 is ratiometric: its datasheet says the resting voltage and the sensitivity scale with the supply voltage.

3D and angle sensors. Several Hall elements on one chip measure the field along three axes and report numbers over a digital bus. TI’s TMAG5273 has three Hall sensors in the X, Y and Z axes, a 12-bit analog-to-digital converter (ADC) and an angle engine that gives a full 360 degrees of rotation, read over I2C.

Current sensors. A conductor carrying current makes its own magnetic field, so a Hall chip can measure the current from that field. Allegro’s guide calls Hall devices excellent for limiting or measuring current, and notes that the conductor does not have to be broken. Allegro says its current sensor ICs deliver galvanic isolation. The metering circuit in a smart plug uses a low-value shunt resistor or a current transformer instead.

Output as a magnet passes: switch, latch, linear south pole passes north pole passes field at chip BOP BRP switch BRP latch unipolar switch on latch on, held linear half supply The switch ignores the north pole. The latch needs it to release. The linear output follows the field above and below half supply.
Diagram: how three sensor types respond as a magnet's south pole passes the chip and then its north pole passes, drawn qualitatively over time. The top trace is the field at the chip: it rises for the south pole and falls below zero for the north pole. Dashed lines mark the operate point BOP, the release point of a switch BRP just below it, and the release point of a latch, which is on the north side. The unipolar switch turns on when the field passes BOP and off when it falls below its BRP, and ignores the north pole. The latch turns on at the same BOP and stays on after the south pole leaves, releasing only when the north pole takes the field past its negative BRP. The linear output rests at half the supply voltage and rises and falls with the field. Many digital switches pull their output low when on, so the electrical level can be the inverse of the line drawn.

How to wire a Hall sensor to a microcontroller

Start with the datasheet for the exact part, because pin order and output type vary between parts that look identical.

Digital switch or latch. Connect supply and ground, and take the output to a GPIO (general-purpose input/output) pin. The DRV5032 datasheet shows the usual behavior: when the field exceeds BOP the output goes low, and it stays low until the field falls below BRP. Some versions have push-pull outputs that drive the pin high or low themselves. Others have open-drain outputs, which only pull low, and for those the datasheet says an external pull-up resistor must be used. The same datasheet points out that an open-drain output leaks current through the pull-up while it is low, and that push-pull gives the lowest system power. Because the output is a clean edge, you can attach an interrupt to it and let a battery node sleep until the magnet moves, as the guide to powering IoT sensors describes.

Linear analog. Take the output to an ADC input. The DRV5055 datasheet says the ratiometric design can eliminate error from supply tolerance when the ADC uses the same supply as its reference, so power the sensor from the same rail as the microcontroller’s ADC. That also keeps the output inside the range the ADC pin can read on a 3.3 V board, since the output swings with the supply. Its datasheet gives the linear output range as 0.2 V up to 0.2 V below the supply.

Digital 3D sensor. Connect it to the I2C bus like any other digital sensor, with the usual pull-up resistors on the two bus lines; the I2C vs SPI guide explains how the bus works. The TMAG5273 datasheet lists a 1.7 to 3.6 V supply, a maximum I2C clock of 1 MHz, factory-programmed and user-configurable addresses, and an interrupt signal when the field or temperature crosses a threshold you set.

What Hall effect sensors are used for

Door, lid and cover detection. TI’s article lists switches in laptops and refrigerator doors, and its application note on replacing reed switches is written around battery-operated door and window sensors for home security. A magnet in the door and a switch in the frame report open or closed.

Flow meters. A common type of small water flow sensor turns a wheel in the flow and senses it with a Hall sensor. DATAQ Instruments’ flow sensor datasheet describes a pinwheel in the water line and a Hall sensor that outputs a pulse with every revolution, sealed from the water. Count the pulses with an interrupt and convert to volume with the factor from the datasheet.

Wheel, fan and shaft speed. Allegro lists latches in shaft encoders, speedometers and tachometers. Count pulses over a fixed time and divide by the number of pulses the sensor gives per turn to get the speed.

Brushless motor commutation. A brushless motor’s controller has to know the rotor position to switch the windings at the right moment, and both Allegro and TI name motor commutation as a common job for latches.

Joysticks and keyboards. TI’s joystick and lever design note says magnets and Hall sensors remove contact-based components that wear out over time. Its keyboard application note says mechanical key switches degrade from friction and can only give an on or off response, while a Hall sensor sees the magnet move closer as the key goes down.

To detect people in a room, see the mmWave vs PIR guide.

Hall effect sensor vs reed switch

A reed switch is the older way to sense a magnet. TI’s reed switch note describes it as a glass tube filled with inert gas holding two ferromagnetic blades, which touch when a magnet comes near. Both do the same job in a door sensor and differ in most other ways.

Hall effect switchReed switch
How it switchesSemiconductor output, no moving partsTwo metal blades that touch
Wear and bounceAllegro: clean, fast output, without bounceTI: lifetime limited by mechanical wear
PowerNeeds a supply all the time; sampled parts cut the averageThe switch itself draws nothing
OrientationField must cross the chip in the datasheet’s directionTI found its detection field erratic in tests
SpeedSuited to fast signals, except slow-sampled micropower partsContacts reach their limits at high rates
Switching a loadDrives a logic input or a transistorCan switch and isolate a circuit directly

Power is the most argued point. Magnetics Magazine explains that a reed switch that receives no magnetic pulse does not consume any power, while a Hall sensor needs a constant supply of power. TI’s note adds that a reed circuit can still draw current through its pull-up or pull-down resistor, depending on how it is wired. Sampled Hall switches narrow the gap: the DRV5032 averages 0.54 µA (microamps) in its 5 Hz version, according to its datasheet.

The same article, quoting a Standex product manager, puts the Hall sensor ahead for high-speed use, in the range of 1 kHz and above, where reed contacts reach their physical limits. It also says even the smallest reed switches can isolate voltages of up to 1,000 volts. A reed switch is a contact, so it can switch a circuit directly, while a Hall output drives a logic input. TI’s tests found a low-power Hall switch had a tighter, more symmetrical detection range than the reed switch in its comparison. For a battery door contact either works; for counting, motors or anything that moves all day, the Hall sensor is the better fit.

Downsides of Hall effect sensors

It needs a magnet, placed with care. TI’s article shows how fast a magnet’s field decays with distance, and advises keeping the working range in the region where the field changes most. A misaligned magnet or an extra millimeter of gap can leave a switch that never operates.

Temperature. Allegro notes that extremes of temperature shift the operate and release points, and its table gives negative temperature coefficients for most of the magnet materials it lists, so those magnets weaken as they warm. Some linear parts correct for this: the DRV5055’s A versions compensate for magnet temperature drift and its Z versions do not.

Stray fields. Any other magnet near the sensor counts as a signal. TI’s reed switch note looked at how easily an external magnet could fool a door sensor, and found that 3D sensors can detect tamper attempts and stray fields, because their three-axis reading moves away from its normal resting value when another magnet comes near.

Constant supply current for most parts. Honeywell’s SS49E linear sensor draws 6 mA typical at 5 V, and the DRV5055 datasheet gives 3 mA typical at 5 V. Micropower parts get down to microamps by sampling the field at a low rate: the DRV5032 updates its output at 80 Hz, 20 Hz or 5 Hz depending on version. A 5 Hz part can miss a magnet that passes quickly. The TMAG5273 lists 2.3 mA active and 1 µA in its wake-up and sleep mode.

The original ESP32’s built-in Hall sensor

The original ESP32 had a Hall sensor on the chip, so a project could sense a magnet held near the module with no extra parts. Espressif’s ESP-IDF v4.4 ADC documentation says reading it used channels 0 and 3 of ADC1 (GPIO 36 and 39), through a function called hall_sensor_read(), and that nothing else should be connected to those pins.

ESP-IDF 5.0 dropped it. The v5.0 peripherals migration guide says the hall_sensor_read API on ESP32 has been removed and the Hall sensor is no longer supported. If a tutorial calls that function, it was written for an older framework. For current projects on any ESP32, including the ESP32-C6, use an external Hall sensor wired as above.

How to pick one for a project

  1. Decide what you need to know. Present or absent: a switch. Rotation with alternating poles: a latch. Position or distance: a linear sensor. Angle or position in more than one direction: a 3D sensor.
  2. Match the threshold to the magnet and gap. Switches come with different operate points. The DRV5032 is sold in versions with maximum BOP values from 3.4 mT (millitesla) to 63 mT, and a sensitive version lets a smaller magnet work from further away.
  3. Check the power budget. On a battery, pick a sampled micropower switch or a 3D sensor with a sleep mode, and check that the sampling rate is fast enough for what you are watching.
  4. Check the output type and supply voltage against your board: open-drain needs a pull-up, analog needs an ADC on the same supply, I2C needs a free address.
  5. Try the real gap before fixing anything. Check the magnet at the distances and angles it will see in use, including the worst case.

For more sensor types and how their readings leave the board, go back to the sensors and hardware guides or read the IoT sensors overview and the guide to powering IoT sensors.

Common questions

What is the Hall effect sensor?

It is a chip that senses a magnetic field. Inside is a Hall element, which produces a small voltage when a field passes through it while current flows, plus an amplifier and an output stage that turn that voltage into an on or off signal, an analog voltage or a digital reading.

How does a Hall effect sensor work?

A bias current flows through a thin plate of conductive material. When a magnetic field crosses the plate at right angles, it pushes the moving charges toward one edge, and a voltage appears across the plate that grows with the field. The chip amplifies that voltage and either compares it with a threshold (a switch or latch) or passes it on as an analog or digital value (a linear sensor).

What are the downsides of using a Hall effect sensor?

It needs a magnet, placed so the field crosses the chip in the direction its datasheet specifies, and the field weakens quickly with distance. Its switching points and the magnet itself shift with temperature, a stray magnet nearby can trigger it, and most parts draw supply current all the time, although sampled low-power switches can average under a microamp.

Are Hall effect sensors worth it?

For anything that moves often or fast, such as wheel speed, flow meters, motors, joysticks and keys, yes: there are no contacts to wear and the output does not bounce. For a simple door contact on a battery, a reed switch draws no power itself and is often the simpler part, while a low-power Hall switch is an alternative with a tighter detection range.

Written by the IoT Crest editorial team. Facts in this article follow the editorial policy: only well-established behavior is stated and no figures are invented.

More from Sensors and hardware

  1. Ambient IoT: battery-free devices explained

    Ambient IoT explained: devices that run on harvested energy with no battery, how backscatter works, the 3GPP and Bluetooth approaches, uses and real limits.

  2. ESP32-C6 explained: Wi-Fi 6, Thread and Zigbee

    ESP32-C6 explained: its RISC-V cores, Wi-Fi 6, Bluetooth LE and Thread or Zigbee radio, how it compares with ESP32, C3, S3, H2 and C5, and when to choose it.

  3. I2C vs SPI: which sensor bus to use

    I2C vs SPI compared for sensor projects: wires and pull-ups, addresses against chip selects, speed, distance, power, and which bus suits each kind of part.

  4. mmWave sensor vs PIR: how presence and motion detection differ

    An mmWave sensor is a small radar that can detect a person sitting still, where a PIR sensor sees only movement. How each works, false triggers and placement.

  5. What is an IoT device? Parts, examples and how they connect

    What is an IoT device: the parts inside one, examples at home, at work and in cities, how IoT devices connect, and how they differ from a phone or a laptop.

  6. IoT sensors: the main types and how to choose one

    IoT sensors explained: the main sensor types by what they measure, how analog, digital and wireless outputs differ, and how to choose one for a project.

  7. Choosing a microcontroller for an IoT project: ESP32, Arduino or Raspberry Pi Pico

    Choosing a microcontroller for an IoT project: how ESP32, Arduino boards and the Raspberry Pi Pico compare on radio, power, pins and toolchain.

  8. Temperature and humidity sensors compared: DHT22 vs SHT31 vs BME280

    DHT22 vs SHT31 vs BME280 compared: interface, accuracy class, response time, self-heating, and which temperature and humidity sensor suits each project.

  9. Powering IoT sensors: batteries, solar and deep sleep

    Powering IoT sensors: how to estimate a power budget, choose between mains, batteries and solar, and use deep sleep so a node runs for months.

All sensors and hardware articles

Sponsor an article in this topic

Sponsored articles and in-article link placements for IoT vendors, agencies and SEO buyers. Every sponsored piece is labeled, edited to the same standard as the rest of the site, and placed in the hub its readers already visit. Rates on request.

Ask a question

Ask a question

Spotted an error, or want a topic covered? It goes straight to the editors, who reply by email, WhatsApp or SMS.