Electronics

Switch Magnetic Reed Switch Sensor Module Ky-021

AED 6.30

Low stock
1

Description

The Switch Mini Reed Module Ky-021 is a magnetic switch sensor, we can say it is a  magnetic hall sensor with a magnetic switch in the same device when we put a magnet closer to the switch sensor, the contacts of the reed switch close. The reed switch-based module is used in cases where the proximity of the magnet is needed. For example, a door closure sensor. It is used in mechanisms of the printers with linearly moving parts so it can determine the end position so  For some use cases, there is no difference if you use a reed switch or a magnetic hall sensor. But a big difference is how the direction of the magnetic field has to be in order to use the magnetic switch.

 
Characteristics
 
normally open reed switch
a fixed bolt hole for easy installation
operating voltage 3.3V-5V
the output in the form: Digital switching outputs (0 and 1)
 
Connection of KY-021
 
The connector S and I are connected to the reed switch.
Contact I is connected to the GND wire of the device.
Power - the central contact of the connector is connected to the power line. 



 KY-021 Module diagram. On the board, the GND contact is I, the output is S.
 
If the purpose of KY-021 is just a reed switch, then 2 wires are used to connect the contacts S and I.
Also, a reed switch-based module allows you to change the output voltage level due to the existing resistor. At the same time, if power is supplied to the corresponding contact and 3 wires are used for the connection we can control the internal switch.


The KY-021 has only a digital output and no build-in LED. Therefore We use an external LED to visualize that the threshold is exceeded.


this is how to connect or the connection for the KY-021 with Arduino and ESP8266:

KY-021 Arduino
KY-021 NodeMCU

The program sketch or Arduino code is for the KY-021:

int led = 9 ; // LED
int reedswitch = 8; // KY-021 digital interface
int digitalVal; // digital readings
void setup ()
{
 pinMode(led, OUTPUT);
 pinMode(reedswitch, INPUT);
 Serial.begin(9600);
}
void loop ()
{
 // Read the digital interface
 digitalVal = digitalRead(reedswitch);
 // when the Hall sensor detects a magnetic field, turn LED on
 if (digitalVal == LOW)
 {
 digitalWrite (led, HIGH);
 }
 else
 {
 digitalWrite (led, LOW);
 }
 delay(100);
}