Saturday, December 21, 2024

Door-Ajar Alert with Countdown Timer

Ever accidentally left your room door ajar for a long period of time and found your valuables missing? Here is an intelligent solution for you. The idea is fairly simple as it mainly requires a TM1637 4-digit display and a Digispark USB development board.

Digispark board
Fig. 1: Digispark board

TM1637 is a popular clock display module with a TM1637 driver chip from Titan Micro Electronics. This 4-digit, 7-segment LED display module can be controlled using just a two-wire serial interface.

Digispark USB board, based on Atmel Attiny85 microcontroller, is similar to Arduino hardware platform. However, it is smaller with limited pins, and a bit less powerful than Arduino.

- Advertisement -

A normally-closed (NC) reed switch is used as the door sensor. When the door is closed, as per mechanical arrangement, switch contacts open to disable the alert system. When the door is opened, switch contacts close to enable the alert system. So a piezobuzzer starts beeping after some time. The alert system wired around Digispark Attiny85 module and clock display module shows live status of the countdown timer.

Arduino-compatible code (door_ajar.ino) is used for this project. The code displays the countdown timer and initiates an alarm after a set time of about 60 seconds. Here, DigitalTube library created by Frankie Chu (Website) is used to control the 4-digit display.

- Advertisement -

So, first download the library, extract contents of the zip file to arduino/libraries folder, and restart the Arduino IDE. Now you can see DigitalTube listed under Sketch/Include Library options in Arduino IDE. Next, copy door_ajar.ino code into the Arduino IDE (Arduino IDE 1.6.6+) to compile and program Digispark.

To program Digispark, first you need to install relevant drivers from the Arduino IDE by selecting Tools/Board/Boards Manager/Digistump AVR Boards options. For details go through the tutorials at this link.

After successful installation of the drivers, Digispark will feature in the Board list of Arduino IDE. Select the correct board as per the Digistump model you have. We selected Digispark(Default-16.5MHz) option. Click Sketch/Upload options from Arduino IDE. You will be prompted to connect Digispark board to the USB port of your PC. As soon as the board is plugged in, the code will be uploaded. Now, plug-out the board and make connections as per the circuit diagram.

 Circuit of door ajar alert system
Fig. 2: Circuit of door ajar alert system

Download Source Folder

After construction, enclose the electronics (including the door sensor) in a small box made of rigid plastic and mount it on the door frame. Attach an appropriate-size magnet on the door such that when the door is closed, the magnet comes closest to the sensor (reed switch S1) and its contacts open. Use an appropriate 9V alkaline battery pack to power the system.

Author’s prototype during testing
Fig. 3: Author’s prototype during testing

This circuit was first published on 17 April 2018 and was updated on 7 April 2020.

1 COMMENT

  1. Many thanks for publishing this and in such great detail! I have used the instructions down to the T, and it works just so well! I love the idea, that no power is consumed, until the door is opened. There is a ~3 second delay until the display and countdown starts up due to the botting up, but that is the price for longevity of the battery. My GF has medication that needs to be stored in a narrow temperature range in the fridge. We have had items blocking the door twice now and the medication had to be re-ordered; worth > EUR 1000. I had not found a good commercial solution and this was just perfect! So this is a savior! Many thanks for the great work and the excellent documentation!

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics