Component guide · Beginner · 5 min read
Reed Switches and Magnetic Door Sensors

Y213 Glass Reed, PS-3150, Littelfuse 59140 and 59145, TE PS811, Pepperl+Fuchs 40FR, MAGREED 2538, MC-38 Door Switch, Sonoff DW1 and DW2, Blue PUCK MAG, SICK MZT8 Cylinder Sensors and Saier Float Switches
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
A reed switch is two thin metal blades sealed in glass that close when a magnet comes near. It needs no power, which makes it ideal for door and window alarms, float switches and pneumatic cylinder position sensing. The MC-38 is a wired door switch pair; the Sonoff DW1 and DW2 send door open and close events by 433 MHz radio to an RF bridge.
Key specs at a glance
- Element
- Glass reed switch, normally open on most
- Power
- None needed for the switch itself
- Rating
- Signal level, up to about 0.5 A on larger types
- Housings
- Bare glass, flange mount, M8 thread, door pairs, cylinder T-slot
- Wireless
- Sonoff DW1/DW2 (433 MHz), Blue PUCK MAG (BLE)
- Industrial
- SICK MZT8 electronic cylinder sensors, Saier float and magnet switches
This part is often wired to 230 V mains. Do all wiring with the plug pulled out, keep mains wires inside a closed box with strain relief, add a fuse, and never touch the board while it is plugged in. If you are new to mains wiring, have an electrician check it before you switch on.
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1Y213 Reed Switch Normal Open 2x14mm Glass₹23
Option 2PS-3150 High-Speed Magnetic Reed Switch 220V 500mA – Normally Open Proximity Sensor₹173
Option 3Littelfuse 59145 SPST-NO Reed Switch Flange 20.32mm₹477
Option 4Littelfuse 59140-1-T-02-F Magnetic Sensor Flange Mount – 2 Pin, 30 G₹309
Option 5TE Connectivity PS811 Reed Switch, PS8 Series, M8 Thread, 12 mm Sensing, SPST-NO, 250 Vac / 1 A, w/ 1.5m Cable₹1,149
Option 6Pepperl+Fuchs 40FR1-3 Reed Switch Proximity Sensor, 19.8mm Sensing Range, IP68, PVDF Cable₹43,739
What the Reed switches, magnetic door sensors and cylinder position switches is
Reed switches and magnetic door sensors close or open a contact when a magnet comes near, used for door and window alarms, counters and position sensing.
For a door alarm, fix the switch on the frame and the magnet on the door so they line up within about 1 to 2 cm when closed. Wire it between a pin and ground with INPUT_PULLUP. With an MC-38 the reading is LOW when the door is closed and HIGH when it opens.
Glass reed switches are fragile: bend the leads at least 2 mm away from the glass and do not overheat them when soldering. For pneumatic cylinders, the SICK MZT8 sensors clip into the T-slot and sense the piston magnet; they are electronic and need a 10-30V supply.
Reed switches, magnetic door sensors and cylinder position switches pinout
The pins on the Reed switches, magnetic door sensors and cylinder position switches and what each one does.
| Pin | Function |
|---|---|
| Lead 1 | To the input pin |
| Lead 2 | To GND |
| Magnet | Separate part, aligned with the switch |
| COM / NO / NC | On changeover reed sensors |
| Brown / blue / black | On electronic cylinder sensors (PNP) |
- Lead 1
- To the input pin
- Lead 2
- To GND
- Magnet
- Separate part, aligned with the switch
- COM / NO / NC
- On changeover reed sensors
- Brown / blue / black
- On electronic cylinder sensors (PNP)
Wiring the Reed switches, magnetic door sensors and cylinder position switches
Reed switches carry small currents only. Use a relay or transistor to switch a lock, siren or lamp.
| Reed switches, magnetic door sensors and cylinder position switches pin | Connection | Note |
|---|---|---|
| Switch lead | D2 with INPUT_PULLUP | LOW when magnet is near |
| Other lead | GND | No polarity |
| Wireless sensor | RF bridge or BLE gateway | Battery powered |
- Switch lead
- Connection:
- D2 with INPUT_PULLUP
- Note:
- LOW when magnet is near
- Other lead
- Connection:
- GND
- Note:
- No polarity
- Wireless sensor
- Connection:
- RF bridge or BLE gateway
- Note:
- Battery powered
Example code
On an ESP32, use the door pin as a deep-sleep wake source for a battery door alarm.
const int DOOR = 2;
const int BUZZER = 8;
void setup() {
Serial.begin(9600);
pinMode(DOOR, INPUT_PULLUP);
pinMode(BUZZER, OUTPUT);
}
void loop() {
if (digitalRead(DOOR) == HIGH) { // magnet away = door open
Serial.println("Door open");
tone(BUZZER, 1500, 200);
}
delay(300);
}Setup and tuning
connect one lead to a digital pin with INPUT_PULLUP and the other to GND.
with a pull-up, the pin reads LOW when the magnet is near (normally open type).
mount magnet and sensor within the rated gap, often 10 to 20 mm.
add debounce in code to avoid multiple counts.
glass reed switches crack if bent near the body.
What you need
Shop this list20 of 20 found in our store · ₹33,786
Generic Y213 Reed Switch Normal Open 2x14mm Glass: the part this guide coversY213 Reed Switch Normal Open 2x14mm Glass₹23
PS-3150 High-Speed Magnetic Reed Switch 220V 500mA – Normally Open Proximity Sensor: another version this guide coversReed Switch₹28
Littelfuse 59145 SPST-NO Reed Switch Flange 20.32mm: another version this guide coversReed Switch₹28
Littelfuse 59140-1-T-02-F Magnetic Sensor Flange Mount – 2 Pin, 30 G: another version this guide coversLittelfuse 59140-1-T-02-F Magnetic Sensor Flange Mount – 2 Pin, 30 G₹309
TE Connectivity PS811 Reed Switch, PS8 Series, M8 Thread, 12 mm Sensing, SPST-NO, 250 Vac / 1 A, w/ 1.5m Cable: another version this guide coversReed Switch₹28
Pepperl+Fuchs 40FR1-3 Reed Switch Proximity Sensor, 19.8mm Sensing Range, IP68, PVDF Cable: another version this guide coversReed Switch₹28
MAGREED 2538 Magnetic Proximity Sensor – NO/NC/Changeover, 18″ Cable: another version this guide coversMAGREED 2538 Magnetic Proximity Sensor – NO/NC/Changeover, 18″ Cable₹84
MC-38 Wired Door Window Magnetic Sensor Alarm Switch – Normally Closed, 30cm Cable: another version this guide coversMC-38 Wired Door Window Magnetic Sensor Alarm Switch – Normally Closed, 30cm Cable₹44
Sonoff DW1 433MHz Wireless Door Magnetic Sensor – 12V DC, RF Bridge Compatible: another version this guide coversSonoff DW1 433MHz Wireless Door Magnetic Sensor – 12V DC, RF Bridge Compatible₹419
Sonoff DW2 RF 433MHz Wireless Door/Window Sensor: another version this guide coversSonoff DW2 RF 433MHz Wireless Door/Window Sensor₹669
ELA Innovation Blue PUCK MAG Door Opening Sensor (IDF25243D) – Bluetooth LE, IP68 Waterproof: another version this guide coversELA Innovation Blue PUCK MAG Door Opening Sensor (IDF25243D) – Bluetooth LE, IP68 Waterproof₹3,749
SICK RZT7-03ZUS-KU0 Cylinder Position Sensor, T-Type, SPST-NO, 5–30 VDC, 2-Wire, IP65/IP67, 2 m Cable, Range: 10mm: another version this guide coversSICK RZT7-03ZUS-KU0 Cylinder Position Sensor, T-Type, SPST-NO, 5–30 VDC, 2-Wire, IP65/IP67, 2 m Cable, Range: 10mm₹5,739
SICK MZT8-03VPS-KW0 Cylinder Position Sensor, T-Type, PNP-NO, 2m 3 Wire Cable, 10 to 30VDC, IP67/IP69K, Range: 3mm: another version this guide coversSICK MZT8-03VPS-KW0 Cylinder Position Sensor, T-Type, PNP-NO, 2m 3 Wire Cable, 10 to 30VDC, IP67/IP69K, Range: 3mm₹10,099
SICK MZT8-03VPS-KUB Cylinder Position Sensor, T-Type, PNP-NO, 5m 3 Wire Cable, 10-30VDC, IP68/IP69K, 3mm Range: another version this guide coversSICK MZT8-03VPS-KUB Cylinder Position Sensor, T-Type, PNP-NO, 5m 3 Wire Cable, 10-30VDC, IP68/IP69K, 3mm Range₹10,629
Saier SEN-K011027 Proximity Switch – DC200V, 0.5A Max: another version this guide coversSaier SEN-K011027 Proximity Switch – DC200V, 0.5A Max₹299
Saier SEN-K011010 Proximity Switch with Magnet – 200V DC, 0.5A Max: another version this guide coversSaier SEN-K011010 Proximity Switch with Magnet – 200V DC, 0.5A Max₹319
Saier SEN-K011008 + Float Ball S025043 Proximity Switch – DC200V: another version this guide coversSaier SEN-K011008 + Float Ball S025043 Proximity Switch – DC200V₹170
Saier SEN-K011007 Proximity Switch with S025008 Float Magnet – DC200V: another version this guide coversSaier SEN-K011007 Proximity Switch with S025008 Float Magnet – DC200V₹175
DAIGOK UG-HJD Magnetic/Inductive Sensor Module – 6-36V DC: another version this guide coversDAIGOK UG-HJD Magnetic/Inductive Sensor Module – 6-36V DC₹499
DAIGOK CS1-G Magnetic/Inductive Sensor Module – 6-36V DC, IP68, 3-Wire NO: another version this guide coversDAIGOK CS1-G Magnetic/Inductive Sensor Module – 6-36V DC, IP68, 3-Wire NO₹449
Alternatives and when to choose them
- Hall effect sensor modules: solid-state magnet sensing.
- Float level switch: reed switch inside a float.
- 433MHz RF remote switch: pairs with 433 MHz door sensors.
Common mistakes to avoid
- Bending leads close to the glass.
- No pull-up.
- Gap too large.
- No debounce.
Frequently asked questions
How do I wire a door sensor to Arduino?
One wire to a pin with INPUT_PULLUP, the other to GND.
Why does it read the opposite way?
The switch may be normally closed; invert the logic in your code.
How far can the magnet be?
Usually 10 to 20 mm for door sensors; check the rated gap in the datasheet.
Why do I get multiple counts?
The contacts bounce each time they close; add a short debounce in code.
Can reed switches carry mains?
Only rated types; use them to drive a relay instead.
Parts for this guide
- ₹23View
- ₹173View
- ₹477View
- ₹309View
TE Connectivity PS811 Reed Switch, PS8 Series, M8 Thread, 12 mm Sensing, SPST-NO, 250 Vac / 1 A, w/ 1.5m Cable₹1,149View- ₹43,739View
- ₹84View
- ₹44View
- ₹419View
- ₹669View
- ₹3,749View
SICK RZT7-03ZUS-KU0 Cylinder Position Sensor, T-Type, SPST-NO, 5–30 VDC, 2-Wire, IP65/IP67, 2 m Cable, Range: 10mm₹5,739View
SICK MZT8-03VPS-KW0 Cylinder Position Sensor, T-Type, PNP-NO, 2m 3 Wire Cable, 10 to 30VDC, IP67/IP69K, Range: 3mm₹10,099View
SICK MZT8-03VPS-KUB Cylinder Position Sensor, T-Type, PNP-NO, 5m 3 Wire Cable, 10-30VDC, IP68/IP69K, 3mm Range₹10,629View- ₹299View
- ₹319View
- ₹170View
- ₹175View
- ₹499View
- ₹449View
- ₹359View
- ₹49View
- ₹20View
Projects that use it
Put this into practice: 45 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



