-40C to +150C
-40C to +150C
10-50 AT (Ampere-Turns)
Up to 100 Hz
Up to 1 A @ 24 VDC
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.
Reed Switch DocumentationOverviewA 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.PinoutThe 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) contactCode 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
MagnetSoftware Requirements:Arduino IDECode:
```c
const int reedPin = 2; // Connect the reed switch to digital pin 2void 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
MagnetSoftware Requirements:Raspbian OS
Python 3.xCode:
```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.