Make a Talking Security Alarm with a PIC16 and ISD1820
By Robin Mitchell
Alarm circuits are common in the field of hobby electronics, typically utilizing a switch (such as a reed switch) and a speaker to produce an alarm. However, the alarm system in this project has several unusual features that will be able to fool most intruders.
In this DIY Hacking project, we will make a security system that will fool intruders into thinking that someone is around!
Warning! Atchung! Attention!
This project uses mains voltage for lamp control via the relay. ONLY ATTEMPT THIS IS YOU ARE CONFIDENT AND COMPETENT TO DO MAINS ELECTRICAL WORK!
- 10K resistor (R1, R2, R3, R4)
- 100nF capacitor (C1, C2, C3, C4, C5, C6)
- 1N5817 diode (D1, D2, D3)
- 2N3904 (Q1, Q2)
- Buzzer (BZ1)
- Relay (RL1)
- 7805 (U2)
- PIC16F1516 (U1)
- ISD1820 module (J6)
- Switch, reed switch, or other electromechanical trigger (J4)
Talking Security Alarm Schematic
How Does It Work?
The project circuitry is rather simple with the complexity of this project being found inside the microcontroller (PIC16F1516) and the ISD1820 module. The idea behind the circuit is to make an intruder think that someone is at home or nearby and this is done in three steps:
- Once a detection has been made, the relay is activated and turns on a light
- After a few seconds, the ISD1820 is triggered to play some audio (“Hey, what are you doing here?!”)
- An alarm is then raised and plays for 20 seconds
The relay and buzzer (RL1 and BZ1 respectively) are not directly connected to IO ports on the PIC as the PIC lacks the current sourcing requirements. To solve this, a transistor is used instead whereby the PIC only needs to source a few mA to turn on either the relay or buzzer (remember that transistors can behave as electronic switches). The relay also has a diode in reverse polarity across its terminals as it is an inductive load and negative voltages generated when the current is switched off could damage the transistor and/or other parts.
Connecting the mains plug to the lamp via the relay
The ISD1820 module is a single IC solution that can record and play back up to 10 seconds of recorded audio (picked up by the microphone). What makes this module very useful is that the record and playback feature can be controlled via an external circuit including microcontrollers. Two IO pins control how the sound is played back; PLAYE plays the entire recorded audio upon a clock pulse (active high) while PLAYL plays for as long as the input is on. For our project, we need the PLAYE pin and not the PLAYL pin. The PLAYE pin is connected RC2.
The ISD1820 Module used in this project
Everyone reading this project will be happy to hear that I have switched from MPLAB 8.92 and Microchip C18 to MPLAB X and XC8 which means most of my projects and code will work for all PICs in the PIC16 and PIC18 series of microcontrollers. One nice feature about this is that all code for PIC16 chips can now be in C and many PIC16 chips are very cheap. The microcontroller in this article, the PIC16F1516, has to be the best bang for buck and costs only a few bucks and comes with the following features:
- 16MHz internal oscillator
- 8K ROM, 512 Byte RAM
- 28 DIP Package (plenty of IO)
- 3 timers (Timer0, Timer1, and Timer2)
- ADC, UART, SPI, and I2C
The code for the talking alarm is very basic with the main loop checking for a logical 1 on the RA0 pin. Once a detection is made then the system kicks into action and starts with a delay so if the intruder heard the security switch trigger then they may think the system did not detect them. Once the delay has been done we need to fool the intruder into thinking that someone has been woken up. This is done by activating the relay which is used to enable and disable power to a mains lamp (remember to switch the LIVE wire and NEVER THE NEUTRAL!). Another delay kicks in to give the impression that someone is half awake and then after that, the ISD1820 module is activated which plays our message “Hey! You! GET OUT OF MY HOUSE”. If the intruders still have the courage to stick around, the system enables the buzzer and starts alarming the area. After a while, this alarm is turned off and the system reset but at this point the intruders should be far away!
This project uses all through hole parts which allows it to be built using most circuit construction techniques. These include breadboard, stripboard, veroboard, matrix board, and even PCBs. However, in this project I have opted to use a PCB as it makes construction neater and easier to do (i.e. no flying wires).
You may notice the white layer on the PCB; this is an experimental silkscreen (also known as a component legend). When making PCBs at home, they can be difficult to construct without both the schematic AND PCB layout side by side. On a laptop this is very impractical as the screen is not very big. So instead, I am experimenting with component legends by printing out the silklayer onto paper, gluing it to the topside of the PCB, aligning it correctly, and then cutting the overhanging paper off using a sharp knife.
The results have been acceptable but it turns out that my CNC needs some scaling adjustments to make it fit perfectly with the printouts. The paper can also get dirty and smudged so its important to use a laser printer and not an inkjet. I plan to purchase some coloured card to produce a thicker layer that is more sturdy and that looks nicer (white shows up dirt too well). Paper is also rather thin and cam come up on the edges but in terms of functionality, it worked really well.