Overview
A reed switch is a magnetic proximity sensor sealed in a small glass tube. Two thin metal reeds sit just apart inside; when a magnet comes near, they snap together and close the circuit. This normally-open reed switch is the sensor behind door and window alarms, lid-open detection, RPM and position sensing, and contactless on/off triggers.
It needs no power of its own and reads exactly like a button: wire it to a GPIO pin with a pull-up and a magnet does the rest. It works with Arduino, ESP32, Raspberry Pi, and Pico.
At a Glance
Type
Reed, normally open
Trigger
Nearby magnet
Reads Like
A button
Power
None required
Leads
2 (non-polarized)
Body
Glass tube ~14mm
Specifications
| Parameter | Value |
| Contact Type | Normally open (SPST-NO) |
| Actuation | Magnetic field (permanent magnet) |
| Max Switching Voltage | ~100-200V (rated), use at logic levels |
| Max Switching Current | ~0.5 A |
| Body | Glass, ~2 x 14 mm |
| Power | Passive, no supply needed |
| Leads | 2, non-polarized |
Wiring Guide
Arduino / ESP32 Wiring
Wire it exactly like a push button using the internal pull-up resistor. No external parts are needed.
| Reed Lead | Goes To |
|---|---|
| Lead 1 | Digital pin (e.g., D2), set INPUT_PULLUP |
| Lead 2 | GND |
Tip: With INPUT_PULLUP the pin reads HIGH when open and LOW when the magnet closes the switch. The glass is fragile, so do not bend the leads right at the seal.
Raspberry Pi Wiring
Same idea: one lead to a GPIO configured with an internal pull-up, the other to ground.
| Reed Lead | Pi |
|---|---|
| Lead 1 | GPIO17 (pull_up_down=PUD_UP) |
| Lead 2 | GND |
Code Examples
Arduino
reed.ino
// Reed switch on pin 2 (like a button)
const int REED = 2;
void setup() {
pinMode(REED, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
int closed = (digitalRead(REED) == LOW); // magnet near?
Serial.println(closed);
delay(200);
}
Frequently Asked Questions
Does it need power?
No. A reed switch is a passive contact, like a button. Wire it between a GPIO pin (with a pull-up) and ground, and a magnet does the switching.
How close does the magnet need to be?
Typically within about 10-20mm, depending on magnet strength and orientation. Test your specific magnet and adjust spacing for reliable triggering.
Does polarity or wire order matter?
No. It is a simple on/off contact with no polarity, so either lead can go to the pin or ground.
Why do I get flickering reads?
Mechanical contacts bounce. Add a short software debounce, or only act on a state that has been stable for a few tens of milliseconds.
Can it switch a load directly?
Only very small loads within its current rating, and reed contacts are easily damaged by inrush. For anything more than a logic signal, use it to trigger a transistor or relay.