Having spent a couple of years asking, reminding and pleading with the other denizens of the house I gave up and decided to try to fix the problem with technology.
This project uses an Arduino and a handful of other components to produce reminding beeps every time the door is opened and then left open for any length of time.
I scavenged a magnetic reed switch from an old window frame that used to have a security monitor. I had a spare Arduino Nano from another project. The other components were out of my bits-a boxes. I used a small bread board to put this together so that I didn't need to spent hours soldering on proto board or making a circuit board.
I live in hope that this project will not be permanently deployed and can be recycled at some time down the track.
It took me approximately two hours to throw this project together, if you don't include the time spent looking for components.
- Arduino Nano (or any other Arduino you might have spare)
- Small bread board
- 6 bread board jumper wires
- Medium sized zippy box or project enclosure
- Battery Holder, 4 x AA
- NPN small signal transistor. DS548, BC338 or similar
- 1N4148 or similar diode
- 330ohm, 1/8 - 1/4 watt resistor
- 10k, 1/8 - 1/4 watt resistor
- Small piezo buzzer or speaker
- Small button or bar magnet
- Reed switch
- Silicon sealant
- hot glue gun
- soldering iron
- small phillips head screw driver
- electronics wire clippers
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Hardware
The circuit diagram is pretty simple. An image of the schematic is attached as well as the original Eagle files.
For power there is a battery pack with 4 AA cells, producing 6v. The on board regulator of the Arduino drops that down to required 5v for the Atmega microcontroller.
For the sense circuit I've used a normally open magnetic reed switch connected to 0v and a 10k pull up resistor connected to Vcc. I trialled a larger resistance to reduce the quiescent current however the Arduino digital input became a bit unreliable. The reed switch is connected to digital pin 7.
For the audio output circuit I have used a BC338 NPN transistor. The base is driven via a 330ohm resistor connected to digital output 2. This transistor needs to be fully on or off when operating so the base resistor will provide sufficient current that the transistor will saturate when on. The emitter of the transistor is connected to 0v. The collector is connected to a piezo speaker element. The piezo speaker used was provided as sample from a component manufacturer. The speaker I chose is a little quite for this application and I would recommend a speaker from a singing greeting card as probably the best device to choose.
There is also a 1N4148 diode reverse biased across the speaker. The diode is recommended by the speaker manufacturer to prevent fly-back voltage from damaging the drive transistor. [Fly-back voltage is the reverse voltage spike produced by an inductor when the supply current is suddenly disconnected. The inductor magnetic field begins to collapse producing an instant reversal of voltage across the inductor and potentially swinging the point between the speaker and the transistor's collector to 2*Vcc.]
Step 2: Software
Attached is an Arduino sketch '.ino' file containing all the code. Feel free to use, modify or distribute. If we meet up one day you can by me a beer.
The code is not complex. There are the usual functions found in any Arduino sketch. There are also some preprocessor directives declaring some magic numbers and allowing for a debug vs operational compile of the code.
The setup() function initialises the sense and output pins as well as the global variables.
The loop() function performs the operational work. The main body of the loop function is only performed every 50ms to provide a stable time base for the rest of the code. At the 50ms time periods the reed switch state is sample using the defined SENSE_PIN digital input. (digital pin 2). If the reed switch indicates that the door is closed then no other significant action is taken other than to reset the time period.
On the occasion where the reed switch indicates that the door is open then the input is de-bounced. That is to say, the door has to register as open for 5 or more successive samples before any further action is taken.
Once the sensor input has been de-bounced then the total time the door has been open is recorded.
Using a succession of tests for various time periods a sequence of beeps of different lengths and numbers is executed.
The first beep occurs when the door opens. Another at 15 seconds and then again at 30 seconds. Then every 30 seconds after that until 3 minutes has passed. There is a beep at 4 minutes. At five minutes there is a beep and then the door monitor gives up and goes silent since it is apparent that the perpetrator is no longer present or doesn't care.
The beeps are produced by a function called buzz(), which generates a set 1000Hz tone of a specified duration and a specified number of times. The tone is sent out on BUZZER_PIN which in this case is set to digital output 7.
Any beep cycle desired could really be programmed. A slight modification to the code could also produce different beep tones.
The time keeping in this software is approximate. There are delays in operation every time a beep occurs. However the project is monitoring a door rather than the time for 100m freestyle swimming at the Olympics so approximates are sufficient for the purpose.
Step 3: Construction
I wired the circuit using bread board and jumper wires. This method is temporary and not how I would normally produce a widget. However this is a project to remind people to close a door and I wasn't prepared to dedicate the time required to produce a circuit board.
As a result of this construction method the time spent putting it together was about the same amount of time it took the hot glue gun to heat to working temperature. As a bonus, any mistakes made in construction were simple to rectify.
For a less resource intensive construction method I might consider wiring the components direct to the pins of the Arduino. But that would be very unattractive as well as more difficult to modify.
Once the bread board was finished I glued the reed switch to the inside of the box, against the bottom edge. The battery pack and the bread board were also glued in place.
I tested the magnet effective range and confirmed the unit would operate, then fitted the lid.
Step 4: Installation
I wanted to be able to remove this unit at some time the future. Silicone is a good adhesive in this case as it can be peeled off much of the time but in the mean time, it sticks to almost anything.
On the inside of the door frame the magnet was fixed in place with a blob of silicone. When completely dried any daggy edges can be cleaned up with a small hobby knife.
Next the project box was held against the door and trialled in different positions until operation seem reliable. The position was marked. Then the unit had silicon applied to the rear surface and was placed back in the marked position.
While the silicon sets it has low strength. To avoid spending 4 hours holding the unit in place, while the silicon set, I used strips of masking tape over the unit and around the edge of the door to hold the unit in place. After a few hours the masking tape can be removed.
Step 5: Results
Surprisingly only the youngest and shortest member of the house noticed the unit attached to near the top of the door.
The other members of the house were aware of the beeps. The number one door abandoner didn't know what the beeps were but became aware that they happened when the door was open so closed it to stop the beeping.
In the day or so following the installation I have not had one instance of the door being left open. To me that is the perfect result. Time will tell if new habits are formed or if I should increase my store of batteries to keep the unit powered.
Participated in the