Magnetic door sensors

Introducing Magnetic door sensors

Magnetic door sensors can establish if a door is open or closed and are commonly used in alarm systems to trigger the opening and closing of doors and windows.

Introduction to magnetic door sensors

Magnetic door sensors, also called reed switches, are sensors that use a magnet to establish whether a door is open or closed. They are commonly used in alarm systems to trigger the opening and closing of doors and windows.

Magnetic door sensor on a door

Magnetic door sensor mounted on a door. Image from

It consists of two parts encased in a plastic shell — a magnet and a sensor/switch.

In combination, it basically works by opening/closing a reed switch by using the magnet’s magnetic field. When the two parts are next to each other the switch is closed and when they are far apart the switch is open.

Basics of a reed switch

Basics of a reed switch. When the two parts are close together, the reed switch is closed — allowing current to flow — and when they are far apart the reed switch is open — allowing no current to flow.

When mounted on a door or a window, the switch is open when the door or window is closed the switch is closed.

This can be used by an alarm system, or for example an Arduino microcontroller or Raspberry Pi, to monitor the activity and trigger an alarm when needed.

Sample uses & alternatives

Magnetic door sensors are mainly used for monitoring doors and windows for security purposes. It can also be used to monitor headcounts, e.g. how many times it was opened in a set period of time.

What makes magnetic door sensors so special?

These little sensors are readily available, easy to mount, easy to use and fairly cheap.

The current flowing through the switch can be used to signal a digital read pin on a microcontroller.


Because magnetic door sensors need to be mounted on doors and windows, choosing the correct placement and hiding the wires can sometimes be a bit tricky.


With their ease of use, price and availability, magnetic door sensors are fairly easy to incorporate into projects for example with Arduinos and Raspberry Pis.

They are great to be used as a trigger switches for windows and doors in home automation projects.

Leave a Reply

Your email address will not be published. Required fields are marked *