Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›Reed Switches and Magnetic Door Sensors

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
Short answerWhat the Reed switches, magnetic door sensors and cylinder position switches isReed switches, magnetic door sensors and cylinder position switches pinoutWiring the Reed switches, magnetic door sensors and cylinder position switchesExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Short answer

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
!Safety: Mains voltage can kill

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
01

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.

02

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.

PinFunction
Lead 1To the input pin
Lead 2To GND
MagnetSeparate part, aligned with the switch
COM / NO / NCOn changeover reed sensors
Brown / blue / blackOn electronic cylinder sensors (PNP)
PinFunction
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)
03

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 pinConnectionNote
Switch leadD2 with INPUT_PULLUPLOW when magnet is near
Other leadGNDNo polarity
Wireless sensorRF bridge or BLE gatewayBattery 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
04

Example code

On an ESP32, use the door pin as a deep-sleep wake source for a battery door alarm.

Door open alarm with an MC-38 · Arduino C++Verify & upload in Electrolark
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);
}
05

Setup and tuning

Wiring

connect one lead to a digital pin with INPUT_PULLUP and the other to GND.

Logic

with a pull-up, the pin reads LOW when the magnet is near (normally open type).

Gap

mount magnet and sensor within the rated gap, often 10 to 20 mm.

Debounce

add debounce in code to avoid multiple counts.

Fragility

glass reed switches crack if bent near the body.

06

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
07

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.
08

Common mistakes to avoid

  • !Bending leads close to the glass.
  • !No pull-up.
  • !Gap too large.
  • !No debounce.
09

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

  • Y213 Reed Switch Normal Open 2x14mm Glass
    ₹23View
  • PS-3150 High-Speed Magnetic Reed Switch 220V 500mA – Normally Open Proximity Sensor
    ₹173View
  • Littelfuse 59145 SPST-NO Reed Switch Flange 20.32mm
    ₹477View
  • Littelfuse 59140-1-T-02-F Magnetic Sensor Flange Mount – 2 Pin, 30 G
    ₹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
  • Pepperl+Fuchs 40FR1-3 Reed Switch Proximity Sensor, 19.8mm Sensing Range, IP68, PVDF Cable
    ₹43,739View
  • MAGREED 2538 Magnetic Proximity Sensor – NO/NC/Changeover, 18″ Cable
    ₹84View
  • MC-38 Wired Door Window Magnetic Sensor Alarm Switch – Normally Closed, 30cm Cable
    ₹44View
  • Sonoff DW1 433MHz Wireless Door Magnetic Sensor – 12V DC, RF Bridge Compatible
    ₹419View
  • Sonoff DW2 RF 433MHz Wireless Door/Window Sensor
    ₹669View
  • ELA Innovation Blue PUCK MAG Door Opening Sensor (IDF25243D) – Bluetooth LE, IP68 Waterproof
    ₹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
  • Saier SEN-K011027 Proximity Switch – DC200V, 0.5A Max
    ₹299View
  • Saier SEN-K011010 Proximity Switch with Magnet – 200V DC, 0.5A Max
    ₹319View
  • Saier SEN-K011008 + Float Ball S025043 Proximity Switch – DC200V
    ₹170View
  • Saier SEN-K011007 Proximity Switch with S025008 Float Magnet – DC200V
    ₹175View
  • DAIGOK UG-HJD Magnetic/Inductive Sensor Module – 6-36V DC
    ₹499View
  • DAIGOK CS1-G Magnetic/Inductive Sensor Module – 6-36V DC, IP68, 3-Wire NO
    ₹449View
  • Uno R3 Development Board (No Cable)
    ₹359View
  • Dupont Jumper Wires (40 pcs)
    ₹49View
  • K800 Round Super Circular Magnet – Axially Magnetized NdFeB
    ₹20View
Shop Magnetic, Hall Effect & Reed SwitchesShop Proximity & Inductive/Capacitive Sensors

Projects that use it

Put this into practice: 45 step-by-step builds in our project library use parts from this guide.

Beginner · 45 minutesDoor-open alarm with reed switchView projectBeginner · 1–2 hoursWi-Fi door sensorView projectBeginner · 45 minutesFridge door left-open alarmView project
Browse all 45 projects

Keep learning

Component guideBeginnerHall Effect Sensor ModulesHall effect modules for Arduino: A3144 digital switch, 49E linear analog, LM393 boards and omnipolar switches. Magnet pole, wiring, RPM counting and code.4 min read · SensorsComponent guideBeginnerFloat Level Switch (Small Vertical, Side-Mount and Cable Float)A float switch has a float that rises with the liquid and moves a magnet past a reed switch (small floats) or tilts a switch inside the cable float (tank floats).5 min read · SensorsComponent guideBeginner433 MHz RF Remote Control Switches and Relay Modules433 MHz RF remote switches pair a key-fob remote with a receiver that switches lights, pumps, gates or motors without Wi-Fi or an app.3 min read · IoT & Wireless

Sources

  • Littelfuse reed switch application notes
  • SICK MZT8 data sheet
  • Sonoff DW2 manual

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the Reed switches, magnetic door sensors and cylinder position switches isReed switches, magnetic door sensors and cylinder position switches pinoutWiring the Reed switches, magnetic door sensors and cylinder position switchesExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide8 items · ₹7,315

Y213 Reed Switch Normal Open 2x14mm Glass · Reed Switch · Littelfuse 59140-1-T-02-F Magnetic Sensor Flange Mount – 2 Pin, 30 G · MAGREED 2538 Magnetic Proximity Sensor – NO/NC/Changeover, 18″ Cable · MC-38 Wired Door Window Magnetic Sensor Alarm Switch – Normally Closed, 30cm Cable · Sonoff DW1 433MHz Wireless Door Magnetic Sensor – 12V DC, RF Bridge Compatible · Sonoff DW2 RF 433MHz Wireless Door/Window Sensor · SICK RZT7-03ZUS-KU0 Cylinder Position Sensor, T-Type, SPST-NO, 5–30 VDC, 2-Wire, IP65/IP67, 2 m Cable, Range: 10mm

Run itChange the inputs and watch the output

Magnet near the switch = closed = LOW. Opening the door lets the pull-up read HIGH.

Buzzer silent
Serial monitor9600 baud
 

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question