The KY-024 Magnetic Field Sensor, manufactured by Sensor, is a versatile and reliable component designed to detect the presence and strength of magnetic fields. It is widely used in applications such as navigation systems, robotics, industrial automation, and proximity detection. The sensor combines an analog output for precise measurements and a digital output for threshold-based detection, making it suitable for a variety of projects.
The KY-024 Magnetic Field Sensor is built with a Hall effect sensor and a potentiometer for sensitivity adjustment. Below are the key technical details:
The KY-024 sensor has three pins for connectivity. The table below describes each pin:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin. Connect to 3.3V or 5V DC. |
2 | GND | Ground pin. Connect to the ground of the circuit. |
3 | DO | Digital output pin. Outputs HIGH or LOW based on the magnetic field threshold. |
4 | AO | Analog output pin. Provides a voltage proportional to the magnetic field. |
Below is an example of how to connect the KY-024 sensor to an Arduino UNO:
The following Arduino code reads both the digital and analog outputs of the KY-024 sensor:
// Define pin connections
const int digitalPin = 2; // Digital output pin from KY-024
const int analogPin = A0; // Analog output pin from KY-024
void setup() {
pinMode(digitalPin, INPUT); // Set digital pin as input
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Read digital output
int digitalValue = digitalRead(digitalPin);
// Read analog output
int analogValue = analogRead(analogPin);
// Print values to the Serial Monitor
Serial.print("Digital Output: ");
Serial.print(digitalValue); // Print digital value (0 or 1)
Serial.print(" | Analog Output: ");
Serial.println(analogValue); // Print analog value (0-1023)
delay(500); // Wait for 500ms before the next reading
}
No Output from the Sensor:
Digital Output Always HIGH or LOW:
Analog Output Not Changing:
Interference in Readings:
Q: Can the KY-024 detect both north and south poles of a magnet?
A: Yes, the KY-024 can detect both poles of a magnet. The analog output will vary based on the strength and polarity of the magnetic field.
Q: How do I know if the digital output is triggered?
A: The onboard LED will light up when the digital output is HIGH, indicating that the magnetic field exceeds the set threshold.
Q: Can I use the KY-024 with a 3.3V microcontroller?
A: Yes, the KY-024 is compatible with 3.3V systems. Ensure the VCC pin is connected to a 3.3V power source.
Q: What is the maximum detection range of the KY-024?
A: The sensor can detect magnetic fields up to approximately ±4mT (millitesla).
By following this documentation, you can effectively integrate the KY-024 Magnetic Field Sensor into your projects and troubleshoot any issues that arise.