The reed switch is a type of electromechanical switch that operates through the principle of magnetism. Professor Valentin Kovalenkov invented it in 1922 at the Petrograd Electrotechnical University (PEU). Walter B. Ellwood developed it into the reed relay in 1936 at Bell Telephone Laboratories. Generally, these switches include a set of ferromagnetic flexible metal contacts, which seal hermetically in a glass envelope. Typically, a magnetic field keeps these contacts open; otherwise, they close to complete the circuit and allow current to flow. The reed switch detects the opening of a window or door for a safety alarm. So, the KY-025 module is an example of a reed switch module. This article elaborates on the KY-025 module, its working & its applications.
What is the KY-025 Module ?
The KY-025 is a magnetic reed switch sensor module that detects the presence of a magnetic field, making it ideal for triggering actions or proximity sensing based on magnetic proximity. This module features a reed switch that activates in response to a magnetic field. When someone brings a magnet close to the module, the switch closes, and the reed switch module sends a digital signal. As a result, this module frequently finds use in Arduino projects, microcontroller applications, DIY electronics projects, and more.
How does the KY-025 Module Work ?
The KY-025 module includes a set of contacts on top of ferrous metal reeds. This module operates whenever someone applies a magnetic field to it. When the module is exposed to a magnetic field, two ferrous materials within the reed switch pull together, causing the reed switch to close. Once the magnetic field disappears, the reed switch opens. Thus, this module is a great choice mainly for noncontact switching-based applications.
This module has two outputs: analog and digital. The analog output delivers a voltage that corresponds to the magnetic field strength, while the digital output switches to LOW or HIGH depending on whether the reed switch is closed. You can adjust the threshold of the voltage comparator circuit using a potentiometer. Thus, users commonly employ this module in applications such as proximity sensing, position detection, and security systems.
Pin Configuration :
The KY-025 module pin configuration is shown below. This module includes four pins, which are explained below.

KY-025 Module Pin Configuration
- Pin-1 (GND): It is the ground pin of the switch module.
- Pin-2 (+V): It is a voltage supply pin that connects to a 3.3V/5V power supply.
- Pin-3 (D0): It is a digital output pin that goes high whenever the magnetic field goes beyond the set threshold.
- Pin-4 (A0): It is an analog output that provides a voltage supply that is proportional to the strength of the magnetic field.
Features & Specifications:
The features and specifications of the KY-025 module include the following.
- KY-025 is a magnetic reed switch sensor module.
- This module includes four pins.
- It has a fixed bolt hole for simple installation.
- This module has an LM393 voltage comparator.
- The protocol is analog or digital.
- The operating voltage of this module ranges from 3.3V to 5V
- This module’s dimensions are 36 x 15 x 14 mm.
- This module’s magnetic field’s strength will be changed based on the model.
- Current is up to 1.2Amps.
- It has a fixed bolt-hole for simple installation.
- Its operating temperature range is from -25°C to +70°C.
Components
The KY-025 module includes different components like a normally open reed switch, an LM393 IC, a trimmer potentiometer, 2 LEDs & male header pins, which are explained below.
- This module has a reed switch, which acts like a core component that operates whenever a magnetic field is applied.
- The LM393 IC is the dual differential comparator that processes the signal from the switch to provide digital output.
- The Potentiometer is used to adjust the threshold value for noticing magnetic fields.
- This module has two modules that provide visual feedback on the status of the module.
- This module has four male header pins that connect the other electronic components.
- It is compatible with different microcontrollers like Arduino Board, ESP32, Raspberry Pi, etc.
Equivalents & Alternatives :
Equivalent to the KY-025 module are KY-021, KY-017, Hall-effect sensors, etc. So, an alternative to the KY-025 module is the KG180 module.
KY-025 Module Interfacing with Arduino Uno
The KY-025 reed switch module’s interfacing with Arduino Uno is shown below. This is a small electrical switch used as a proximity sensor and is operated through a magnetic field. So, this module includes both analog and digital outputs. To calibrate this module’s sensitivity, a potentiometer can be used. Thus, this module is compatible with different microcontrollers.
The required components to make this interfacing mainly include a KY-025 module, Arduino Uno, and connecting wires. The connections of this interfacing follow as;

KY-025 Module Interfacing with Arduino Uno
- Connect the analog output or A0 pin of the module to the A0 pin on the Arduino board.
- The digital output pin (D0) of the switch module is connected to pin 3 of the Arduino board.
- Connect the (+) power line pin of the module to the 5V pin of the Arduino.
- Connect the GND pin of the module to the GND pin of the Arduino board.
Code:
The required code for this interfacing is shown below.
int led = 13; // define the LED pin
digitalPin = 3; // KY-025 digital interface
int analogPin = A0; // KY-025 analog interface
digitalVal; // digital readings
int analogVal; //analog readings
void setup()
{
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
//pinMode(analogPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if(digitalVal == HIGH) // if magnetic field is detected
{
digitalWrite(led, HIGH); // turn ON Arduino’s LED
}
else
{
digitalWrite(led, LOW); // turn OFF Arduino’s LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}
Working
In the above interfacing, we can read the values from both analog and digital interfaces on the module. So, a magnet is required to interact through the reed switch module. Here, the digital interface sends a HIGH signal whenever a magnetic field is noticed; then, it turns on the LED on the pin-13 of the Arduino board. Thus, conversely, the analog interface returns a HIGH numeric value whenever there is no magnetic field there, and it will drop to zero whenever a magnet is near.
Difference between KY-025 and KY-021 Modules
The difference between KY-025 and KY-021 modules include the following.
KY-025 |
KY-021 |
KY-025 is a reed switch module. | KY-021 is a small reed switch. |
Its main function is to detect magnetic fields & measure their strength. | It detects simple on or off magnetic field. |
Its operating voltage ranges from 3.3V to 5.5V. | This module’s operating voltage ranges from 3.3V to 5V. |
It outputs both analog and digital signals. | It outputs only digital signals. |
This module has a built-in 100kΩ potentiometer. | It has a built-in 10kΩ resistor. |
This module’s sensitivity can be adjusted through a trimmer or potentiometer. | This module’s sensitivity cannot be adjusted. |
It is used in level detection, proximity sensing, and many more. | It is used in simple ON/OFF applications. |
Advantages & Disadvantages
The advantages of the KY-025 module include the following.
- The KY-025 module has many benefits: it is simple, versatile, compatible with different microcontrollers, consistent in magnetic field detection, and simple to incorporate into DIY projects.
- This module needs extremely little power to function and is thus used in battery-powered applications.
- These are small, simple, and efficient modules.
- It provides both analog & digital outputs, thus allowing for supple data analysis & control.
- Its simple design & operation will make it simple to know and utilize
- These are not expensive.
The disadvantages of the KY-025 module include the following.
- The KY-025 depends on a reed switch, so it needs a very strong magnetic field to turn on. It might not be appropriate for applications that need distant or weak magnetic field detection.
- Reed switches in the KY-025 module can ultimately fail in some ways, which leads to faulty operation.
- Due to the potentiometer and LM393 comparator IC, its sensitivity remains fixed, and users cannot dynamically adjust it.
- These modules serve only in simple applications because of their limitations, rather than in high-precision or complex applications.
- This module needs an additional power supply to work, so it adds difficulty to some projects.
Applications
The applications of the KY-025 module include the following.
- These modules are used in window or door alarms to detect whether doors are opened or closed through a magnet.
- Security monitoring systems use them to trigger actions or alerts based on the presence or absence of a magnet.
- This module detects the mechanical position of an object or mechanism.
- Limit switches utilize it to identify when a device reaches a specific limit in its movement.
- This module counts objects or events based on how the magnet passes by.
- It detects the presence or absence of a magnet at a fixed level within a container.
- Industries use it in automation across various applications to detect and control processes.
Please refer to this link for the KY-025 module datasheet.
Thus, this is an overview of the KY-025 module, pin-out, features, specifications, interfacing, and its applications. This reed switch module operates through a magnetic field and commonly serves as a proximity sensor, providing both analog and digital outputs. This module is perfect for applications that need magnetic field detection, like position sensors, door/window alarms, or security systems. Here is a question for you: What is KY-017 sensor module ?