Blogs
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.
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

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)
1 2 3 4 5 6 7 8 9 10 |
// 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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
1 2 3 4 5 6 7 |
// 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
1 2 3 4 5 6 7 8 9 10 11 |
// 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
1 2 3 4 |
// 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
1 2 3 4 5 |
// 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