Main Content

Hi everyone, in this page i’m going to show you how i made a simple door alarm that is compact,loud and battery powered.

There is a full list of what you need for this project, i savaged most of the components from stuff i had laying around, but you can easily buy them.

AtTiny45/85: The brain of this project, you can use even an arduino board for this but i think it’s way too overpowered.
5V Voltage regulator: i used a CJ78M05 to provide 5 volts for the Attiny.
LM386: op-amp that runs the speaker.
Speaker/Piezo: chose a loud one , not to high in impedance.
Relay: Electromagnetic switch used to turn off the Amp in order to save power when the alarm is in stand-by, i used a TX2-3V even if i’m going to drive it with 5v, that should be fine.
Optocoupler: A little IC to isolate the coil of the relay from the Attiny, i used an EL817 but you can use whatever you want.
NPN transistor: to drive the relay.
Diode: to protect the circuit from the high voltage spikes of the coil discharging when the relay goes off.
Reed Switch: a magnetic switch to detect the door position using a magnet.
Magnet: i savaged this from an old hard disk.
Capacitors: you’ll need a 10 uF one to set the gain of LM386 and two 300uF, one to stabilize the power line and one for the speaker output.
Resistors: one 1kOhm for the base of the transistor,one 1MOhm as a pulldown resistor for the reed switch input, i used such a high resistance one to save power when in stand-by, and a resistor for the input of the optocoupler.
You need to calculate the value of this last one based on the datasheet of your optocoupler: in my case the datasheet showed an ideal current flow of 20mA trough the infrared led of the optocoupler, so as i’m driving it with 5v i calculated the resistance i needed using Ohm’s law :

R=V/I —> R=5v/0,002A —> R=250Ohms

Switch: connected with a long cable to turn on and off the alarm.
Battery lead+9v battery.
Perf board: i’m using one with ground connection over one side to make the circuit cleaner (not the one in the picture).
header pins for IC’s and speaker, screw terminal for the switch: raccomended but not strictly necessary.
Plastic case: again, raccomended but you can mount in on the door even using double sided tape or you can even 3d Print one.”

Link to article