Description
KY-024 Hall Effect Magnetic Sensor Module
The KY-024 is a magnetic-field detection module built around an integrated 49E linear Hall-effect sensor. It provides both analog and digital outputs, making it suitable for applications such as proximity detection and magnetic-field measurement.
Detailed specifications
- Operating voltage: 3–5 V DC
- Detection range: ±2 mT
- Operating temperature: −40°C to +85°C
- Sensitivity: 1.0 mV/G minimum, 1.4 mV/G typical, 1.75 mV/G maximum
- Dimensions: 45 × 15 × 14 mm
- Weight: 1 g
- Main components: 49E linear Hall sensor, LM393 comparator, potentiometer, LED and resistors
How it works
The KY-024 detects magnetic fields and generates an analog voltage proportional to field strength. Its integrated comparator can provide a digital output when the magnetic field exceeds a threshold adjusted with the potentiometer.
Applications
- Position and speed detection in robotics
- Proximity detection in security systems
- Metal-object detection in industrial applications
- Current measurement in power supplies
- Magnetic-field mapping and measurement in scientific research
Pinout
The KY-024 module has four pins:
- VCC: Power supply (3–5 V)
- GND: Ground
- A0: Analog output
- D0: Digital output
How to use it
Connect the module as follows:
- VCC to 5 V on the Arduino
- GND to GND on the Arduino
- A0 to A0 on the Arduino to read analog values
- D0 to a digital pin (for example, D3) to read digital values
Using it with an Arduino Uno
Basic Arduino code example
const int led = 13; // LED sur l'Arduino
const int digitalPin = 3; // Interface numérique du capteur Hall
const int analogPin = A0; // Interface analogique du capteur Hall
int digitalVal; // Valeurs numériques
int analogVal; // Valeurs analogiques
void setup() {
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
}
void loop() {
// Lecture de l'interface numérique
digitalVal = digitalRead(digitalPin);
if (digitalVal == HIGH) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
// Lecture de l'interface analogique
analogVal = analogRead(analogPin);
Serial.println(analogVal);
delay(100);
}
What the code does: It reads the KY-024 analog and digital outputs and turns on the Arduino LED when a magnetic field is detected.
Components required for the basic example
- Arduino Uno
- KY-024 module
- Connecting wires
Basic code explained
- Pin initialization: The LED pin is set as an output and the sensor pins as inputs.
- Reading and displaying data: The analog and digital values are read and displayed in the serial monitor. The LED turns on when a magnetic field is detected.
Basic wiring
- VCC (KY-024): 5 V (Arduino)
- GND (KY-024): GND (Arduino)
- A0 (KY-024): A0 (Arduino)
- D0 (KY-024): D3 (Arduino)
Advanced Arduino code example
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int led = 13;
const int digitalPin = 3;
const int analogPin = A0;
int digitalVal;
int analogVal;
void setup() {
lcd.begin();
lcd.backlight();
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
}
void loop() {
// Lecture de l'interface numérique
digitalVal = digitalRead(digitalPin);
if (digitalVal == HIGH) {
digitalWrite(led, HIGH);
lcd.setCursor(0, 0);
lcd.print("Magnetic: YES ");
} else {
digitalWrite(led, LOW);
lcd.setCursor(0, 0);
lcd.print("Magnetic: NO ");
}
// Lecture de l'interface analogique
analogVal = analogRead(analogPin);
lcd.setCursor(0, 1);
lcd.print("Analog: ");
lcd.print(analogVal);
delay(100);
}
What the code does: It reads the KY-024 analog and digital outputs, displays them on an I2C LCD, and controls the Arduino LED.
Components required for the advanced example
- Arduino Uno
- KY-024 module
- 1602 I2C LCD
- Connecting wires
Advanced code explained
- Including libraries:
#include <Wire.h>and#include <LiquidCrystal_I2C.h>add the libraries required for the LCD. - Initialization: Communication with the LCD and sensor is set up in
setup(). - Reading and displaying data: The analog and digital values are read and shown on the LCD. The LED turns on when a magnetic field is detected.
Advanced wiring
- VCC (KY-024): 5 V (Arduino)
- GND (KY-024): GND (Arduino)
- A0 (KY-024): A0 (Arduino)
- D0 (KY-024): D3 (Arduino)
- VCC (LCD): 5 V (Arduino)
- GND (LCD): GND (Arduino)
- SCL (LCD): A5 (Arduino)
- SDA (LCD): A4 (Arduino)
Installing the driver/library
To use the KY-024 module and LCD with Arduino, install the LiquidCrystal I2C library through the Arduino IDE:
- Open the Arduino IDE: Make sure it is up to date.
- Open the Library Manager: From the menu, choose Sketch → Include Library → Manage Libraries.
- Search for “LiquidCrystal I2C”: Use the search box to find the library.
- Install the library: Click Install to add it to the IDE.
Keywords: Hall effect, magnetic, sensor.









