Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Sensor de Campo Magnético: Examples, Pinouts, and Specs

Image of Sensor de Campo MagnéticoDesign with Sensor de Campo Magnético in Cirkit Designer

Introduction

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.

Explore Projects Built with Sensor de Campo Magnético

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Nucleo-L4R5ZI and RM-3100 Magnetometer Sensor Interface: A project utilizing Sensor de Campo Magnético in a practical application
Nucleo-L4R5ZI and RM-3100 Magnetometer Sensor Interface

This circuit integrates a Nucleo-L4R5ZI microcontroller with an RM-3100 magnetometer sensor for magnetic field measurement. Communication between the microcontroller and the sensor is established through I2C protocol, with an additional data ready signal connected to the microcontroller's D9 pin. Power supply and ground connections are established to power the sensor and provide common reference points.

Open Project in Cirkit Designer

Technical Specifications

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:

Key Specifications

Pin Configuration and Descriptions

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.

Usage Instructions

How to Use the KY-024 in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to the ground.
  2. Connect Outputs:
    • Use the DO pin for digital output. This pin will output HIGH (1) when the magnetic field exceeds the threshold set by the potentiometer.
    • Use the AO pin for analog output. This pin provides a voltage proportional to the detected magnetic field strength.
  3. Adjust Sensitivity: Use the onboard potentiometer to set the desired sensitivity for the digital output.

Example Circuit with Arduino UNO

Below is an example of how to connect the KY-024 sensor to an Arduino UNO:

Example Code

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
}

Important Considerations and Best Practices

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output from the Sensor:

    • Check the power connections (VCC and GND).
    • Verify that the sensor is receiving the correct voltage (3.3V or 5V).
    • Ensure the magnetic field is within the detection range of the sensor.
  2. Digital Output Always HIGH or LOW:

    • Adjust the potentiometer to change the sensitivity threshold.
    • Verify that the magnetic field strength is sufficient to trigger the digital output.
  3. Analog Output Not Changing:

    • Ensure the AO pin is connected to an analog input pin on the microcontroller.
    • Check for proper grounding and stable power supply.
  4. Interference in Readings:

    • Keep the sensor away from strong electromagnetic sources.
    • Use shielded cables if the sensor is placed far from the microcontroller.

FAQs

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.