Random Nerd Tutorials
Shares

Monitor Your Door Using Magnetic Reed Switch and Arduino

Shares

This tutorial demonstrates how to use a magnetic reed switch. I’ll do a quick overview on how it works and show a project example using an Arduino.

Description

A magnetic contact switch is basically a reed switch encased in a plastic shell so that you can easily apply them in a door, a window or a drawer to detect if the door is open or closed.

The switch that we are going to use has two parts: the switch itself, that usually comes opened, and the magnet. When you buy this switch, it also comes with 4 screws, so that you can attach it to your door.

label

How does it work?

It’s very very simple.

The electrical circuit is closed when a magnet is near the switch (less than 13 mm (0.5’’) away). When the magnet is far away from the switch, the circuit is open. See the figure below.

magnetic_reed_switch_howitworks

Where to buy?

These switches are very cheap. You can buy them on ebay here.

Project Example

In this example, we will turn on a red LED if your door is open and a green LED if your door is closed.

You’ll need the following components:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Schematics

Here’s the schematics for this example.

magnetic contact switch_bb

Uploading Sketch

For this example, upload the following code:

Demonstration

Here’s a video demo showing this project working.


I hope you found this tutorial useful.

Are you thinking of including a magnetic reed switch in one of your projects? Share your thoughts writing a comment below.

Share this post with a friend that also likes electronics!

You can contact me by leaving a comment. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

Thanks for reading,

-Rui Santos


Learn ESP32 with Arduino IDE

This our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! The special launch discount ends soon, so SIGN UP NOW »

Leave a Comment:

Add Your Reply

⏰ Registrations are open ⏰
Sign up for "Learn ESP32 with Arduino IDE" Course