Introduction: ScaryPi Halloween

Every year around Halloween we do a lot of decorations outside the house, pumpkins with lights, spiders, skeletons etc.

After that we are waiting for the childrens to knock on the door and ask for trick or treat.

This instruct is about building a device to expand the scary experience for them when knocking on the door.

I call the project ScaryPi.

If you want to use it for other happenings you can easily modify it to suit for example Christmas or a birthday party, etc.

let's get started.

Step 1: This Is How It Works

The idea is to play scary sounds and blink randomly with lamps when motion is detected outside the door.

The project consists of a raspberry Pi, a PIR sensor and a couple of external components.

The PIR sensor is detecting motions, if there is someone at the door it will trig a GPI input on the raspberry pi.

A small program, written in python, then choose between 8 different sound effects and randomly blink lights on two different outputs.

Step 2: List of Materials

This is what you need:

1 raspberry pi B+ Runing rasbian.

1 USB memory device

1 Pir sensor ,with built in relay, normally open.

2 Opto Coupler ,4N35.

2 FET transistors IRF520.

1 Power amplifier breakout, TPA2005/D1 from sparkfun.

2 Resistors, 1K.

2 Resistors 100K.

2 Resistors 220 Ohm

1 Resistor 10K.

2 Resistors 47K, used to change the gain on the amplifier breakout board.

3 Diodes, 1N4007, used to protect the circuit.

Header pins, to make it easy to connect the external devices.

1 small full-range loudspeaker, about 4 to 5inches big.

2 Christmas tree lamps or what else you prefer. Make sure you can power them with a power supply between 9 to 30Volts DC.

Experiment PCB ,wires, etc.

It's also a good idea to use a breakout board and flat cable for the GPI. Pi Breakoutboard

Step 3: Curcuit Description

When the PIR sensor detect a motion, the pi will play a sound-effect stored on an USB device.

The reason for why I store them to USB rather than to the Pi, is because it makes it easy to change sound-effects for different events.

The sound effect must be a *.wav file and you can find many different effects on the web that is free to download

I find mine at

Another idea is to record your own sound files, like "Welcome to my house" and leave it as a message when someone is near.

The Pi play the sound file and randomly turn the GPO 24 and 25 on and off, the time it is on and off is also randomly selected. You can adjust the blink time for each sound, so it matches the length of the sound.

The GPO is connected to an optocoupler to protect the pi and to make sure that the voltage from the load never reach the PI and destroy it.

The optocoupler is connected to the gate on the FET transistor so it switches the load on and off.

The circuit is suitable for voltage between 9-30 Volts.

To amplify the sound from the headphone outlet to a level that is suitable for a small speaker, I use a small mono power amplifier breakout board from sparkfun.

This device amplifies the level from the headphone outlet on the pi to 1.4Watts, not enough to shake your pants off, but enough for a small loudspeaker, in my case 5 inches big.

To adjust the sensitivity, add two resistors ,47K to the board, see picture.

The trim potentiometer in the schematic is optional, I think it is easier to adjust the volume from the pi rather than from the PCB/ breadboard.

Step 4: Soldering

Solder the external components to a prototype board of your choice. I use a PCB with the same signature as a standard solderless breadboard.

It can be hard to see how to wire on the picture so please refer to the schematic.

Make sure to connect the amplifier board to 5V on your Pi(pin2).

Don't forget the protection diodes for, D1, D2, D3.

D1 protects the circuit against wrong polarity, D2,D3 protect the FET's against inductive loads, this is if you modify the curcuit and want to control relays or other inductive loads.

Be careful when connect the power supply for the loads so you don’t accidently use the same rails on your breadboard as for the 3.3V and 5 V from the Pi.

Step 5: Connect the Periheries

When you are finish with your PCB it’s time to connect the peripheries.

Connect the PIR sensor relay to the GPI 18, this must be normally Open, (NO), then connect the the load to the load terminals and lastly connect the power source for the loads.

Connect the amplifier input terminals, plus and minus, on the breakout board to the headphone outlet on the pi.

Make sure to connect plus to Tip and minus to ground/sleeve.

Use a 3.5 mm plug, strip one end of the cable.

Note that I only use one channel from the pi, if you need both channels (left/Right) add a 10K resistor to each channel and then connect them together. see picture.

Then connect the loudspeaker.

If you are using the GPIO Breakout it is very easy to connect your pi with a flat cable, if you don’t, use standard female wires.

Step 6: Time to Test

Power up your PI and launch python3.

Open the program file and make necessary changes to the file path and file names to match your sounds, See picture.

Run the program.

If succeed, you should hear sound playing and see lamps blinking when moving towards the sensor.

The program also tracks the time and date for each visitor/trig, and does a printout to the screen, so that you can see if someone has been at the door when you are not home.

To prevent the sound to be played repeatedly the program will wait for 30 second before the sensor will detect motion again, change the time if necessary.

Step 7: Time to Decorate

When everything works as it should, it’s time to set it up outside the house.

In this step you need to use your own fantasy and creativity.

I did my decoration beside the front door and then placed the sensor, so it points towards the door, this is to avoid false alarms and make sure it only will trig when someone standing in front of the door.

I'm using 2 standard Christmas tree slings of light and put them behind the flying skeleton, now we will just wait for the visitor’s reactions when it gets dark outside.

Step 8: Congratulation

f you don’t have the time to build this before Halloween, change the sound and light for Christmas or others.

Hope you like the instruct.

Best regards

Tomas C

Halloween Contest 2018

Participated in the
Halloween Contest 2018