Sensor Digital

Reed Switch

A reed switch is a magnetic-field switch sealed in a glass tube.

Part images

Reed switch. A magnetic switch sealed in a glass tube. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.
Reed switch principle. A magnetic field pulls the reeds together to close the circuit. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.
KY-021 Module Photo. Module Photo for the KY-021 Mini Reed Switch Module. Image source: Joy-IT SensorKit KY-021 module documentation
KY-021 Pinout / Module Diagram. Pinout / Module Diagram for the KY-021 Mini Reed Switch Module. Image source: Joy-IT SensorKit KY-021 module documentation
KY-021 Arduino Wiring Diagram. Arduino Wiring Diagram for the KY-021 Mini Reed Switch Module. Image source: Joy-IT SensorKit KY-021 module documentation
KY-021 Raspberry Pi Wiring Diagram. Raspberry Pi Wiring Diagram for the KY-021 Mini Reed Switch Module. Image source: Joy-IT SensorKit KY-021 module documentation
KY-025 Module Photo. Module Photo for the KY-025 Large Reed Switch Module. Image source: Joy-IT SensorKit KY-025 module documentation
KY-025 Pinout / Module Diagram. Pinout / Module Diagram for the KY-025 Large Reed Switch Module. Image source: Joy-IT SensorKit KY-025 module documentation
KY-025 Arduino Wiring Diagram. Arduino Wiring Diagram for the KY-025 Large Reed Switch Module. Image source: Joy-IT SensorKit KY-025 module documentation
KY-025 Raspberry Pi Wiring Diagram. Raspberry Pi Wiring Diagram for the KY-025 Large Reed Switch Module. Image source: Joy-IT SensorKit KY-025 module documentation

What it is

A reed switch is a magnetic-field switch sealed in a glass tube.

How students use it

Students use it for door/window sensors, magnet-triggered counters, hidden switches, and simple security-themed projects.

Pins and power

Two switch leads. Most small reed switches are non-polarized for basic low-voltage signal use.

Passive switch. Read it as a 3.3V-safe digital input with a pull-up or pull-down.

SunFounder explains that two overlapping metal reeds close when a magnetic field is strong enough and open again when the field weakens.

Voltage and safety

Use as a low-voltage signal switch only in ObsoleteHQ projects.

The glass body is fragile. Do not bend leads right at the glass seal, and power off before repositioning.

Module internals

Two ferromagnetic reeds, sealed glass tube, inert gas or vacuum, and two external leads.

Datasheet notes

SunFounder does not identify a manufacturer part number. Match the exact glass switch before relying on contact rating or operate/release distance.

Common libraries

No special library is needed. Use machine.Pin and debounce if the project counts transitions.

Common mistakes

Putting the magnet on the wrong side or too far away, breaking the glass tube, leaving the input floating, and expecting every magnet to trigger at the same distance.