The KY-024 Magnetic Field Sensor, manufactured by Arduino (Part ID: MM), is a versatile component designed to detect the presence and strength of magnetic fields. It outputs an analog voltage proportional to the detected magnetic field strength and includes a digital output for threshold-based detection. This sensor is widely used in applications such as compass systems, magnetic field detection, proximity sensing, and robotics.
The KY-024 sensor combines a linear Hall-effect sensor and a potentiometer for sensitivity adjustment. Below are its key technical details:
The KY-024 sensor has a 3-pin interface for easy integration into circuits. Below is the pinout:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (3.3V to 5V DC) |
2 | GND | Ground connection |
3 | DO | Digital output (high/low signal based on magnetic field threshold) |
4 | AO | Analog output (voltage proportional to magnetic field strength) |
The KY-024 sensor is straightforward to use in a variety of circuits. Below are the steps and considerations for proper usage:
Wiring:
Adjusting Sensitivity:
Arduino Code Example: Below is an example Arduino sketch to read both the analog and digital outputs of the KY-024 sensor:
// KY-024 Magnetic Field Sensor Example
// Reads analog and digital outputs and prints them to the Serial Monitor
const int analogPin = A0; // Pin connected to AO (Analog Output)
const int digitalPin = 2; // Pin connected to DO (Digital Output)
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
pinMode(digitalPin, INPUT); // Set digital pin as input
}
void loop() {
int analogValue = analogRead(analogPin); // Read analog value
int digitalValue = digitalRead(digitalPin); // Read digital value
// Print the values to the Serial Monitor
Serial.print("Analog Value: ");
Serial.print(analogValue);
Serial.print(" | Digital Value: ");
Serial.println(digitalValue);
delay(500); // Wait for 500ms before the next reading
}
No Output from the Sensor:
Analog Output is Constant:
Digital Output Always High or Low:
Fluctuating Readings:
Q1: Can the KY-024 detect the polarity of a magnetic field?
A1: No, the KY-024 cannot detect the polarity of a magnetic field. It only measures the strength of the field.
Q2: What is the range of magnetic field strength the KY-024 can detect?
A2: The exact range depends on the Hall-effect sensor used, but it is typically suitable for detecting small to moderate magnetic fields.
Q3: Can I use the KY-024 with a 3.3V microcontroller?
A3: Yes, the KY-024 is compatible with 3.3V systems, but ensure the output voltage levels are within the microcontroller's input range.
Q4: How do I know if the sensor is working?
A4: Use a multimeter to measure the voltage on the AO pin. The voltage should vary when a magnet is brought near the sensor.
By following this documentation, you can effectively integrate and troubleshoot the KY-024 Magnetic Field Sensor in your projects.