Stufin
Home Quick Cart Profile

Reed Switch

Buy Now on Stufin

Operating temperature range

-40C to +150C

Magnetic sensitivity

10-50 AT (Ampere-Turns)

Switching frequency

Up to 100 Hz

Contact rating

Up to 1 A @ 24 VDC

Operating life

Up to 10^7 cycles

Conclusion

The Reed Switch is a reliable, low-power, and compact magnetic sensor that is widely used in various IoT applications. Its fast response time, omnidirectional sensing, and high reliability make it an ideal choice for designers and engineers looking to integrate magnetic sensing capabilities into their devices.

Pin Configuration

  • Reed Switch Documentation
  • Overview
  • A Reed Switch is a type of electromagnetic switch used in various IoT applications, including proximity sensors, level sensors, and alarm systems. It consists of two ferromagnetic reeds (contacts) sealed in a glass tube, which are normally open and close in the presence of a magnetic field.
  • Pin Description
  • The Reed Switch typically has two pins:
  • Pin 1: Normally Open (NO) Terminal
  • Function: Connects to the positive terminal of the load or the power supply.
  • Description: This pin is connected to one of the reeds inside the glass tube. When the switch is in its normal state (no magnetic field present), this pin is open, and there is no connection between the two reeds.
  • Pin 2: Normally Closed (NC) Terminal
  • Function: Connects to the negative terminal of the load or the power supply (optional).
  • Description: This pin is connected to the other reed inside the glass tube. When the switch is in its normal state (no magnetic field present), this pin is closed, and there is a connection between the two reeds. However, when a magnetic field is present, the connection is broken.
  • Connection Structure
  • To connect a Reed Switch, follow these steps:
  • 1. Connect Pin 1 (NO) to the positive terminal of the load or power supply:
  • This can be a power source (e.g., a battery), a microcontroller, or a relay module.
  • Ensure the voltage and current ratings of the load or power supply are within the Reed Switch's specifications.
  • 2. Connect Pin 2 (NC) to the negative terminal of the load or power supply (optional):
  • If the load or power supply requires a return path, connect Pin 2 to the negative terminal.
  • If the load or power supply does not require a return path (e.g., an LED), leave Pin 2 unconnected.
  • 3. Position the Reed Switch near a magnet or magnetic field source:
  • The Reed Switch will close (Pin 1 and Pin 2 connect) when a magnetic field is present, allowing the load to operate.
  • The Reed Switch will open (Pin 1 and Pin 2 disconnect) when the magnetic field is removed, interrupting the load's operation.
  • Important Notes
  • Ensure the Reed Switch is handled carefully to avoid mechanical shock, which can damage the internal glass tube and reeds.
  • Choose a Reed Switch with a sufficient voltage and current rating to match your application.
  • When using a Reed Switch in a circuit, consider adding protective components (e.g., resistors, capacitors) to prevent overvoltage, overcurrent, or electromagnetic interference (EMI).
  • By following these guidelines, you can effectively integrate a Reed Switch into your IoT project and take advantage of its reliable and efficient switching capabilities.

Code Examples

Reed Switch Documentation
Overview
A reed switch is an electrical switch that operates by means of a magnetic field. It consists of two ferromagnetic reeds (contacts) hermetically sealed in a glass envelope, which are normally open (NO) or normally closed (NC). When a magnet is brought near the switch, the reeds attract each other, closing the circuit. Reed switches are widely used in IoT applications, such as door sensors, liquid level sensors, and proximity sensors.
Pinout
The typical pinout of a reed switch is as follows:
Pin 1: Normally Open (NO) contact
 Pin 2: Normally Closed (NC) contact
 Pin 3: Common (COM) contact
Code Examples
### Example 1: Basic Reed Switch Connection (Arduino)
In this example, we will connect the reed switch to an Arduino board to detect the opening or closing of a door.
Hardware Requirements:
Arduino Board (e.g., Arduino Uno)
 Reed Switch
 Breadboard
 Jumper Wires
 Magnet
Software Requirements:
Arduino IDE
Code:
```c
const int reedPin = 2;  // Connect the reed switch to digital pin 2
void setup() {
  pinMode(reedPin, INPUT);
  Serial.begin(9600);
}
void loop() {
  int reedState = digitalRead(reedPin);
  if (reedState == HIGH) {
    Serial.println("Door is open");
  } else {
    Serial.println("Door is closed");
  }
  delay(100);
}
```
Explanation:
In this example, we connect the reed switch to digital pin 2 of the Arduino board. We set the pin as an input and read its state in the `loop()` function. When the magnet is near the reed switch, the reeds close, and the digital pin 2 reads HIGH, indicating that the door is open. Otherwise, the pin reads LOW, indicating that the door is closed.
### Example 2: Reed Switch with Raspberry Pi (Python)
In this example, we will connect the reed switch to a Raspberry Pi to detect the presence of a magnet.
Hardware Requirements:
Raspberry Pi
 Reed Switch
 Breadboard
 Jumper Wires
 Magnet
Software Requirements:
Raspbian OS
 Python 3.x
Code:
```python
import RPi.GPIO as GPIO
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define the reed switch pin
reed_pin = 17
# Set up the reed switch pin as an input
GPIO.setup(reed_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
    if GPIO.input(reed_pin):
        print("Magnet detected")
    else:
        print("Magnet not detected")
    time.sleep(0.1)
```
Explanation:
In this example, we connect the reed switch to GPIO pin 17 of the Raspberry Pi. We set the pin as an input with an internal pull-up resistor. The `while` loop continuously reads the state of the reed switch pin. When the magnet is near the reed switch, the pin reads HIGH, indicating that the magnet is detected. Otherwise, the pin reads LOW, indicating that the magnet is not detected.
Note: In both examples, make sure to connect the reed switch according to the pinout diagram and use a suitable power supply for your microcontroller or single-board computer.