Blog

How to use Linear Magnetic Hall sensor module (KY024)

KY-024 Linear Magnetic Hall Effect Sensor

Precision Magnetic Field Detection for Arduino and Embedded Systems

Introduction

The KY-024 Linear Hall Sensor is a magnetic field detection module based on the 49E analog Hall-effect sensor. It provides both analog and digital outputs proportional to magnetic field strength, making it ideal for position sensing, speed detection, and current measurement applications.

KY-024 Hall Sensor

Key Features

🧲 Linear Output

Analog voltage proportional to field strength

📊 Dual Output

Analog + Digital (threshold-triggered)

🎛️ Adjustable

Sensitivity potentiometer for digital output

🔌 Easy Interface

3.3V/5V compatible with standard pins

Technical Specifications

Operating Voltage 3.3V – 5V DC
Output Type Analog (0-VCC) + Digital (0/1)
Sensitivity 1.3mV/G (typical)
Measurement Range ±1000 Gauss (analog)
Response Time 5μs (typical)
Current Consumption 4-8mA

Pin Configuration

KY-024 Pinout
Pin Label Description Arduino Connection
1 GND Ground GND
2 + Power (3.3V-5V) 5V
3 D0 Digital Output D2 (Digital Input)
4 A0 Analog Output A0 (Analog Input)
Note: Blue potentiometer adjusts digital output threshold

Wiring Diagram (Arduino)

// Basic Connections:
// GND → GND
// +   → 5V
// D0  → D2 (Digital Input)
// A0  → A0 (Analog Input)

// For magnetic sensing:
// - South pole increases output voltage
// - North pole decreases output voltage
// - No field ≈ VCC/2

Basic Magnetic Detection

const int analogPin = A0;
const int digitalPin = 2;

void setup() {
  Serial.begin(9600);
  pinMode(digitalPin, INPUT);
}

void loop() {
  int analogValue = analogRead(analogPin);
  int digitalValue = digitalRead(digitalPin);
  
  Serial.print("Analog: ");
  Serial.print(analogValue);
  Serial.print(" | Digital: ");
  Serial.println(digitalValue);
  
  delay(200);
}

Advanced Applications

Field Strength Calculation

// Convert analog reading to Gauss
float voltage = analogValue * (5.0 / 1023.0);
float zeroFieldVoltage = 2.5; // VCC/2
float sensitivity = 1.3; // mV/G

float gauss = (voltage - zeroFieldVoltage) * 1000 / sensitivity;
Serial.print(gauss); Serial.println(" Gauss");

Speed Measurement

// Measure RPM using magnet on rotating shaft
unsigned long lastPulse = 0;
float rpm = 0;

void loop() {
  if(digitalRead(digitalPin) == HIGH) {
    rpm = 60000 / (millis() - lastPulse);
    lastPulse = millis();
    Serial.print(rpm); Serial.println(" RPM");
  }
}

Current Sensing

// Measure current via magnetic field
// Using split-core transformer principle
float current = gauss / 10.0; // 10G per amp
Serial.print(current); Serial.println(" A");

Position Detection

// Linear position via moving magnet
int position = map(analogValue, 0, 1023, 0, 100);
Serial.print("Position: "); 
Serial.print(position); 
Serial.println("%");

Troubleshooting

No Analog Response

  • Verify magnet polarity (try flipping)
  • Check analog pin connection
  • Test with stronger magnet (neodymium recommended)

Digital Output Always High/Low

  • Adjust sensitivity potentiometer
  • Check threshold voltage with multimeter
  • Ensure magnet is within 1-2cm range

Unstable Readings

  • Add 0.1μF capacitor between VCC and GND
  • Keep away from EMI sources
  • Implement software averaging