Electronic circuits · no code

Magnetic Door Open Alarm

A magnet stuck on the door keeps a reed switch closed; when the door opens the reed opens and a buzzer sounds. It is the simplest door and window alarm.

  • LevelBeginner
  • Time20 min
  • Power9 V DC
  • CategoryAudio & alarms

Bill of materials

Everything you need to build it, with the reference you will see on the schematic.

Bill of materials
Qty Part Ref.
1 Reed switch (glass capsule that closes near a magnet) SW1
1 47 kΩ resistor (yellow-violet-orange) R1
1 BC557 PNP transistor Q1
1 Active buzzer (3 to 24 V) BZ1
1 9 V battery with snap clip BT1
1 Small magnet (fridge or speaker magnet)
1 Breadboard (400 tie-points or more)
4 Jumper wires

Missing parts? The kits recommended by Impeca Tech include almost all of them. See the kits

Schematic & wiring

On the left, the circuit diagram; on the right, the same circuit built on a breadboard. Both connect exactly the same things.

Circuit diagram of “Magnetic Door Open Alarm”
Circuit diagram
Breadboard layout of “Magnetic Door Open Alarm”
Breadboard layout

Wire it step by step

  1. Place the components
    • Reed switch SW1: one leg in 5f and the other in 9f (either way round). The glass is fragile: do not bend the legs right against the glass.
    • 47 kΩ resistor R1 (bands: yellow, violet, orange, gold): one leg in 9i and the other in 13i (either way round).
    • BC557 transistor Q1 with the flat face (the one with the text) towards you, left to right: collector (C) in 3h, base (B) in 4h, emitter (E) in 5h.
    • Active buzzer BZ1: the long leg (marked +) in 10f and the other leg in 13f. Reversed, it will not sound.
  2. Add the jumper wires
    • Red wire: from 5j to the + (red) rail.
    • Orange wire: from 4j to 9j.
    • Turquoise wire: from 3j to 10j.
    • Black wire: from 13j to the − (blue) rail.
  3. Connect the battery
    • Connect the 9 V battery to its clip: the clip’s red lead to the + (red) rail and the black one to the − (blue) rail. Do this last, once everything else is in place.
  4. Test the circuit
    • With the magnet next to the reed (door closed) the buzzer should be quiet. Move the magnet about 3 cm away: it sounds. Bring it back and it stops. For a real test, stick the reed on the frame and the magnet on the door so they are a few millimetres apart, up to 1 cm depending on the magnet, when the door is closed.

How to read the holes: the letter is the row and the number is the column of the breadboard (for example 7f). The red (+) and blue (−) rails are the two long lines along the edge.

How does it work?

  1. 1Door closed: the magnet closes the reed
  2. 2The base of Q1 sits at + and it does not conduct
  3. 3You open the door and the reed opens
  4. 4R1 pulls the base down, Q1 conducts and it sounds

Here the reed works the opposite way to the magnet detector. With the door closed the magnet keeps the reed closed and holds the base of the PNP transistor (Q1, a BC557) at the battery plus: with no voltage between base and emitter Q1 does not conduct and the buzzer stays quiet. When the door opens the magnet moves away, the reed opens and R1 (47 kΩ) pulls the base towards 0 V: about 0.18 mA flows out of the base, Q1 conducts and passes about 28 mA to the buzzer, which sounds. At rest the battery draws only about 0.19 mA (what flows through the reed and R1), so it lasts weeks. A bonus of this design: it also sounds if someone cuts the reed’s wire.

Testing & troubleshooting

What you should see

Door closed (magnet next to the reed)
Buzzer currentunder 1 µA
Current drawn from the battery≈ 191 µA
Door open (magnet away)
Buzzer current≈ 28 mA
Voltage across the buzzer≈ 8.82 V
Current drawn from the battery≈ 28 mA

Approximate values, calculated with typical parts. With real parts they can vary by 10 % or more.

If something does not work

It sounds with the door closed

The magnet is too far or badly oriented: bring it closer and hold it parallel to the capsule. With a weak magnet the reed does not close, the base is left unbiased and Q1 conducts. Also check the reed is properly wired between the plus and the base.

It does not sound when the door opens

Check the BC557 (PNP): the emitter goes to the plus and the collector towards the buzzer; the wrong way round it never conducts. Check the buzzer polarity (its + goes to the collector of Q1) and that it is an active one.

Want to automate this circuit with code?

Learn how to program sensors and custom schedules in our e-book “Arduino from Scratch”.