The KY-003 Hall Sensor is a compact and versatile device designed to detect the presence of a magnetic field. It operates by outputting a digital signal when a magnetic field is detected, making it an essential component in various applications. The sensor is widely used in position sensing, speed detection, and proximity sensing. Its simplicity and reliability make it a popular choice for hobbyists, students, and professionals working on magnetic field detection projects.
The KY-003 Hall Sensor module has three pins, as described in the table below:
Pin Number | Pin Name | Description |
---|---|---|
1 | Signal | Outputs a digital signal (HIGH when a magnetic field is detected, LOW otherwise). |
2 | VCC | Power supply pin (3.3V to 5V). |
3 | GND | Ground connection. |
Wiring the Sensor:
Magnetic Field Detection:
Example Circuit:
Below is an example code to interface the KY-003 Hall Sensor with an Arduino UNO:
// KY-003 Hall Sensor Example Code for Arduino UNO
// This code reads the digital output of the KY-003 Hall Sensor and turns on an LED
// when a magnetic field is detected.
const int hallSensorPin = 2; // KY-003 Signal pin connected to digital pin 2
const int ledPin = 13; // Onboard LED pin
void setup() {
pinMode(hallSensorPin, INPUT); // Set the hall sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorState = digitalRead(hallSensorPin); // Read the sensor's output
if (sensorState == HIGH) {
// Magnetic field detected
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Magnetic field detected!");
} else {
// No magnetic field detected
digitalWrite(ledPin, LOW); // Turn off the LED
Serial.println("No magnetic field.");
}
delay(100); // Small delay for stability
}
The sensor does not detect a magnetic field:
Unstable or fluctuating output:
No output signal:
Q: Can the KY-003 Hall Sensor detect both poles of a magnet?
A: Yes, the KY-003 Hall Sensor can detect both the North and South poles of a magnet.
Q: What is the maximum distance for magnetic field detection?
A: The detection range depends on the strength of the magnet. Typically, the sensor works best within a few centimeters of the magnet.
Q: Can I use the KY-003 Hall Sensor with a 3.3V microcontroller?
A: Yes, the sensor operates within a voltage range of 3.3V to 5V, making it compatible with 3.3V microcontrollers like the ESP32.
Q: Is the KY-003 Hall Sensor suitable for outdoor use?
A: While the sensor can operate in a wide temperature range, it is not waterproof or weatherproof. Use appropriate enclosures for outdoor applications.