If you are building a tachometer, a door alarm, or a brushless motor commutation circuit, you need a reliable way to detect magnetic fields. The direct answer for most bench builds is to use the A3144 for digital (on/off) switching or the SS49E for analog (linear field strength) measurements. Wire the VCC to 5V, GND to GND, and the signal pin to either a digital interrupt pin (D2) or an analog pin (A0). The A3144 triggers specifically on a South magnetic pole, which is the number one reason beginners think their sensor is broken.
Parts List & Module Variants
Before you wire anything, you need to know which module you have. The bare ICs (like the Allegro A3144EUA or Honeywell SS49E) are surface-mount or tiny TO-92 packages, so 99% of makers use the breakout modules. These modules include the necessary bypass capacitors and pull-up resistors, saving you from breadboarding discrete components.
| Module Variant | IC Part Number | Output Type | Typical Price (5-pack) | Best Use Case |
|---|---|---|---|---|
| Digital Switch | A3144 (or 44E clone) | Digital (LOW when triggered) | $1.50 - $2.50 | RPM counting, limit switches, door alarms |
| Linear Analog | SS49E (or 49E clone) | Analog (Ratiometric to VCC) | $3.00 - $5.00 | Joystick position, current sensing, proximity |
Pin Mapping & Wiring Steps
The code below targets the Arduino Uno R3 (Rev3) and Arduino Nano v3 (both ATmega328P based). If you are using an ESP32, note that its ADC pins are non-linear and its GPIOs are 3.3V logic; you will need a logic level shifter or a 3.3V hall sensor like the DRV5053.
| Sensor Pin | Arduino Uno/Nano Pin | Wire Color (Standard) | Notes |
|---|---|---|---|
| VCC | 5V | Red | Do not use 3.3V on 5V A3144 clones; they will not trigger. |
| GND | GND | Black | Ensure a solid connection; floating ground causes phantom triggers. |
| DO / OUT (A3144) | D2 | Yellow | D2 is required for hardware interrupts (INT0) on Uno/Nano. |
| AO / OUT (SS49E) | A0 | Blue | Analog pin for reading linear voltage variance. |
Wiring Procedure:
- De-energize the board: Unplug the Arduino USB cable before inserting wires into the breadboard to prevent accidental 5V-to-GND shorts.
- Seat the modules: Place the A3144 and SS49E modules on the breadboard, ensuring the pins are fully inserted and not bent under the plastic housing.
- Connect Power Rails: Run red jumper wires from the Arduino 5V pin to the breadboard positive rail, and black wires from GND to the negative rail. Connect the sensor VCC and GND pins to these rails.
- Route Signal Lines: Connect the A3144 Digital Out to Arduino D2. Connect the SS49E Analog Out to Arduino A0.
- Verify connections: Use a multimeter in continuity mode to verify that the GND pin of the sensor has a near-zero ohm reading (< 1 ohm) to the Arduino GND pin.
Complete Arduino Code with Error Handling
This sketch handles both digital interrupts for high-speed RPM counting and analog polling for field strength. It includes serial error handling to detect disconnected wires or dead sensors.
// Target Board: Arduino Uno R3 / Nano v3 (ATmega328P)
// Arduino Hall Effect Sensor: A3144 (Digital) & SS49E (Analog)
#include <Arduino.h>
#define HALL_DIGITAL_PIN 2 // Must be an interrupt-capable pin (INT0)
#define HALL_ANALOG_PIN A0 // Analog pin for SS49E
#define LED_PIN 13 // Onboard LED for visual feedback
volatile unsigned long lastPulseMicros = 0;
volatile unsigned long pulseIntervalMicros = 0;
volatile bool magnetDetected = false;
int analogBaseline = 0;
int errorCount = 0;
void IRAM_ATTR hallInterrupt() {
unsigned long currentMicros = micros();
pulseIntervalMicros = currentMicros - lastPulseMicros;
lastPulseMicros = currentMicros;
magnetDetected = true;
}
void setup() {
Serial.begin(115200);
while (!Serial && millis() < 2000) { delay(10); }
pinMode(LED_PIN, OUTPUT);
pinMode(HALL_DIGITAL_PIN, INPUT_PULLUP); // A3144 outputs open-drain LOW
// Attach interrupt: Trigger on FALLING edge (when magnet pulls pin LOW)
attachInterrupt(digitalPinToInterrupt(HALL_DIGITAL_PIN), hallInterrupt, FALLING);
// Calibrate analog baseline (SS49E zero-point)
long sum = 0;
for (int i = 0; i < 50; i++) {
sum += analogRead(HALL_ANALOG_PIN);
delay(2);
}
analogBaseline = sum / 50;
Serial.print("Analog Baseline Calibrated: ");
Serial.println(analogBaseline);
}
void loop() {
// 1. Handle Digital Sensor (A3144) via Interrupt
if (magnetDetected) {
magnetDetected = false;
digitalWrite(LED_PIN, HIGH);
if (pulseIntervalMicros > 0) {
float rpm = 60000000.0 / pulseIntervalMicros;
Serial.print("Digital Trigger | RPM: ");
Serial.println(rpm, 1);
}
delay(50); // Debounce / LED visibility
digitalWrite(LED_PIN, LOW);
}
// 2. Handle Analog Sensor (SS49E) via Polling
int currentAnalog = analogRead(HALL_ANALOG_PIN);
int variance = abs(currentAnalog - analogBaseline);
// Error Handling: Check for disconnected analog wire
// A disconnected pin often floats to a steady mid-rail or rail value
if (variance < 2) {
errorCount++;
if (errorCount > 100) {
Serial.println("Warning: Analog variance < 2. Magnet out of range or wire disconnected.");
errorCount = 0; // Reset to prevent serial flooding
}
} else {
errorCount = 0;
// Map analog variance to a pseudo-distance or field strength indicator
Serial.print("Analog Field Variance: ");
Serial.println(variance);
}
delay(100); // Slow down serial output for readability
}
Debugging: First 3 Checks and "Stuck at 0" Errors
When your serial monitor spits out Warning: Analog variance < 2 or the digital pin never triggers, do not immediately throw the sensor in the trash. Hall sensors are solid-state and rarely fail unless subjected to overvoltage or extreme heat. Here are the first three things to check on the bench:
- Magnet Polarity (The #1 Culprit): The A3144 is a unipolar switch. It only activates when the South pole of the magnet faces the branded side of the IC. If you are using the North pole, the sensor will remain HIGH indefinitely. Flip the magnet.
- VCC Rail Voltage: Many cheap A3144 clones have poorly regulated internal circuitry. If your Arduino is powered via USB and the 5V rail sags to 4.6V under load, the sensor may fail to switch. Measure the VCC pin with a multimeter; it must be strictly > 4.5V.
- Pull-Up Resistor State: The A3144 has an open-drain output. It can pull the line LOW, but it cannot drive it HIGH. If you wired it as
INPUTinstead ofINPUT_PULLUPin your code (and your module lacks an onboard 10k pull-up), the pin will float, causing phantom interrupts or aSensor reading stuck at 0error.
Error: Digital pin stuck HIGH. Check GND connection.Ranked Causes:
1. The GND wire is broken or not fully seated in the breadboard.
2. You are using the North pole of the magnet instead of the South pole.
3. The magnet is too weak or too far away (A3144 typical operate point is 30 Gauss; a weak fridge magnet won't cut it at 2cm distance).
Extending and Simplifying the Build
Depending on your final application, you will want to modify the baseline sketch.
How to Simplify:
If you are building a simple limit switch (e.g., a 3D printer endstop), strip out all Serial.print statements and the analog polling code. Rely purely on the hardware interrupt. For ultra-low latency, replace digitalWrite(LED_PIN, HIGH) with direct port manipulation: PORTB |= (1 << 5); (which maps to D13 on the Uno). This cuts the execution time from microseconds to nanoseconds.
How to Extend:
To build a full tachometer, extend the code by adding a rolling average array for the pulseIntervalMicros to smooth out mechanical vibrations. You can also add an I2C OLED display (using the U8g2 library) to render the RPM locally. If you are measuring bidirectional movement (like a joystick), replace the A3144 with a dual-axis linear hall sensor like the TI DRV5053, which provides separate X and Y analog outputs.
FAQ: Arduino Hall Effect Sensor Questions
Why is my Arduino hall effect sensor always reading HIGH?
If your digital sensor (A3144) is always reading HIGH, it means the open-drain transistor inside the IC is not being triggered to pull the line to ground. This happens for three reasons: you are presenting the North pole of the magnet instead of the South pole, the magnet is too far away (the operate point is typically 30 Gauss, requiring a strong neodymium magnet within 1-2 cm), or your code is missing the INPUT_PULLUP configuration, leaving the pin floating in an undefined state.
Can I use an Arduino hall effect sensor to measure AC current?
You can, but not with the standard A3144 or SS49E modules. Measuring AC current requires a high-sensitivity linear hall sensor placed in the air gap of a ferrite toroid core that the AC wire passes through. For AC current sensing, it is vastly superior to use a dedicated hall-effect current sensor IC like the ACS712 (for <30A) or the ACS758 (for up to 200A), which integrate the ferrite core and provide isolated, ratiometric analog outputs specifically designed for microcontroller ADCs.
How far away can the magnet be from the Arduino hall effect sensor?
Magnetic field strength follows an inverse-cube law relative to distance. For a standard 10mm x 3mm neodymium disc magnet, the A3144 will reliably trigger at a distance of about 1.5 cm to 2.5 cm. If you need to detect a magnet through a thick plastic enclosure (e.g., 5 cm away), you must either use a much larger neodymium magnet (like an N52 grade 20mm block) or switch to a high-sensitivity omnipolar sensor like the Allegro A3141, which has a lower Gauss threshold but consumes slightly more quiescent current.






