the Raspberry Pi Haunted House

Video Notes:

This is my Raspberry Pi Haunted house. In this video, I’m going to show you how to program your Raspberry Pi in Python to scare EVERYONE for Halloween. For a solid basic scare, all you’ll need is a Raspberry Pi and some speakers. For more advanced users….you’re going to have some fun. 




-Raspberry Pi:



-Dupont Wires:



-Terminal Block: (instead of step pad)

-Doorbell Wire:

-Halloween Prop:


-Raspberry Pi Camera:

-Motion Sensor:


-Crazy stuff:

0:00   ⏩  Intro

1:37   ⏩  Scare #1

1:46   ⏩  Don’t let your life be a scary story

2:52   ⏩  What you need

2:56   ⏩  The Magic of Raspberry Pi GPIO

4:30   ⏩  Scare #2 

5:23   ⏩  Level 1 – Raspberry Pi Scary Sound

8:17   ⏩  Scare #3

8:30   ⏩  Level 2 – Raspberry Pi Relays

9:53   ⏩  Scare #4
13:43 ⏩  Scare #5

13:54 ⏩  Raspberry Pi Motion Sensor

17:28 ⏩  Scare #6

19:22 ⏩  Scare #7

19:42 ⏩  Raspberry Pi Camera

28:37 ⏩  BOO!! 

I did all of that with the Raspberry Pie. Welcome to a super spooky episode of Network Chuck. In this video I’m gonna show you how to build a raspberry pie haunted house. And all you’ll need is a simple Halloween prop, some raspberry pie magic and a little bit of python code. And what I’m gonna show you is nuts. You’ll trigger with motion, start recording with a pie camera and then scare the living daylights outta your victim 


And if you have a little bit of extra copy in your cup, I’m gonna show you how to go a bit scaling because I found a website with legit haunted house props and combined with the raspberry pie, I feel sorry for my trick or dreamers, but I’m giving full size candy bars. They have to earn it. Boo. Does that scare you? Boo? Did I scare you? <laugh> this stupid. And of course you gotta stay tuned for some excellent scare footage because you know, I scared my family and my friends and pretty much anyone I could scare. I scared 


Where’s the candy? Right? It’s in the bowl. I scared. 

Now do you wanna hear a real scary story? Once upon a time there was a beardless man, he knew nothing about it. Not only that, he was stuck in a dead end job selling toilets. He told himself day after day I’m going to buy it, training, I’m going to study, I’m gonna get a better job. But he never did excuse after excuse. He’s selling toilets to this day and he still has no beard. Now thankfully the end of that story was made up. The Beardless man started studying for it certifications, got his A plus CCNA and became a happy bearded IT engineer, making a ton of money. So don’t want that scary story. Be your story. You can start studying right now and get it certifications that will change your life. Open up jobs with it. Pro tv, they are the sponsor of today’s video and they are here to make sure that your life isn’t a scary story. 

Get your A plus CCNA AWS and hacking stuff to get everything. And it’s training that won’t put you to sleep, it won’t make you a zombie. And they also have labs and practice exams to make sure you actually know your stuff. So check it out, link below. If you use my code network Chuck, you’ll get 30% off forever. Now here’s everything you need to do this with the varying levels of spookiness going from spookiness level one, level two, and level three. I’ll show you extreme later. Now before we dive in, let me show you how this is gonna work because when I found out raspberry pies could do this, this blew my mind, opened up a whole new world. So let me find the Halloween prop. Oh my little buddy here. Now you’ll notice on these animatronic Halloween props, they’ll often have a try me button, which the button on this one has been ripped off by my kids. They they’re animals. But what I want you to go ahead and do is rip off the tri me button, cut it, cut the wire. And you’ll notice there are two wires. And the way these props are activated is by touching those two wires together or creating a short like this. 

I say my breath, 


He goes. For larger animatronics, they probably won’t have a tri button like this crow scarecrow behind me. But instead they’ll have a eighth inch jack hole port thing where you can plug in a step pad, which those are pretty cheap. And if you get one of those step pads and you rip off the pad like I’ve done here, you’ll see the same kind of thing. Two wires that when touch together will create a short and activate your prop. So now we have to figure out some way for our raspberry pie to trigger that prop to make those two wires touch. And that is where our relay comes in. The way the relay works is really simple on the relay, you’ll put one of the wires inside, one of the little re relay holes. I’m sure there’s a technical term for it, I don’t know what it is. And you’ll put the other wire in the other hole. And when triggered, the relay will actually touch those wires together triggering our prop. And this is all controlled via python on the raspberry pie. It’s amazing. Now for those of you who don’t have a relay or a Halloween prop, that’s cool. You can still do this. All you’ll need is some computer speakers that just wire up to the audio jack on the raspberry pie. And we can trigger a spooky sound like this. 

Come on. 

Now the main way I’m gonna show you how to trigger these props and these scary sound if you wanna do that, is with a motion sensored like this, well wire this motion sensor up to the G P I O pins on our raspberry pie, which are all those little pokey spiny things on your raspberry pie that you always ignore. But now we’re gonna use, cause they’re amazing by the way, this is not an accurate wiring, I’m just drawing. Okay, just relax. So this motion sensor will obviously sense motion. Send that information to the raspberry pie and the raspberry pie will kick off the Halloween prop. Now again, if you don’t have this, I’ll show you how to trigger your raspberry pie to do whatever you wanted to do with your phone. Where’s my phone? With your phone? And it’s so simple and awesome. Now level one is spookiness, you don’t need much. I only need this some speakers and a raspberry pie For the raspberry pie, this will be a basic setup. I did a headless install with raspberry pi os light 32 bit. I’m not gonna walk you through that here cause I do have other videos showing you that. Check ’em out somewhere around here. So with my raspberry pie powered up, I’m gonna go ahead and plug in my speakers into the audio port 

<laugh>. There we go. And I wanna log into my pie. I’ll go ahead and get SSH in and we’ll start a new Python script. Nano high scare audio dot pie. And first we’ll import a few things. We’ll import time and we’ll also import pie game. This is what will actually allow us to play the sound. And here’s the code. First, we’ll use pie game, pie it with open and closing parentheses to initialize it. We’ll then set a variable called scary sound and have that equal this pie game dot mixer. Dot sound with the capital S and then will specify our sound. This will be the file that you have in your raspberry pie that will play. Now you will need a file. I’ve got a zombie screaming, which is awesome. It’s in the OG format. The og, because I found that played pretty nicely with the raspberry pie. 

It should be able to play wave files, but if you have a problem just convert it to OG with something like Audacity or Adobe Audition. And then we can also set our volume real quick. I’ll do pie game dot mixer dot sound set underscore volume. And I’ll say set and then parenthesis. I’ll specify scary sound and set the volume to one, which I think is a hundred percent. Yeah, just like loudest you can go cause you want that don’t you? And now we’re ready to play our sound. We’ll simply do scary and parenthesis. So to keep it simple, we’ll just do time dot sleep four, five seconds, that’s it. Control x, y enter to save. And we’ll run our script. This is gonna be loud, I’m warning you. Ready? Here we go. 

<laugh>, how awesome is that? Now the question you probably have is, how do I trigger this? How can I scare my family and trick or treaters? Of course that’s what you wanna do. You could use a motion sensor, which I’ll show you how to do here in a moment. But if you don’t have that and all you have is raspberry pies and speakers, you can use your stinking. Where’s my, oh you can use your phone like check this out on the iPhone they have an app called a Shortcuts. If you’re not using that, you’re crazy. It’s so cool. Here I’m going to add a new shortcut and I’ll click add action and I’m gonna search for ssh. And there it is. You probably already see where it’s going. Now run script over ssh. I’m gonna select that. And here in the script box, I’m just gonna run with Python three my Pie scare audio script. Then I’ll enter in connection information. How do you get to it? Log info and that’s it. So now with one button press you can the living daylights out of some people watch, I’ll do it again. How awesome is that? Now keep in mind as I show you more stuff in this video, we can do that or we can trigger with some other stuff that don’t involve us. I’ll show you that too. 

So now time to play at our relay. So what I want you to do is unplug your raspberry pie, power it off, let it be dry like this. I don’t know why I said dry. And we’re gonna grab some DuPont wires. I recommend buying a set with an assorted bunch of wires. At first we’re going to use a female to female DuPont wire, only three of those suckers. Notice on the other side of the relays we’ll have some pens on the far left we’ll have ground on the far right we’ll have voc. Now yours may be smaller. You may have a two terminal relay. I have an eight terminal relay, but work the same. We’re gonna work with the ground pin first on the very far left, go ahead and plug that in. And then referring to our G P I O pen out diagram, we’re gonna plug this in on pen 39, 1 of the ground options. 

We’ll grab another female DuPont wire, plug that into VOC on the very far right and on the Raspberry Pi, we’ll plug that into pen two, which is five volt power. So currently <laugh>, currently the raspberry pie is providing a five volt current to power our relay. Now I’m gonna grab another female DuPont wire and on the relay I’ll plug this into i n is it i N i? Yeah, i n one I in one. And then on the raspberry pie, I’ll plug that into pen 37. It’s this pin i n one that will trigger the first relay, either opening it or closing it, connecting the wires and disconnecting the wires. And notice you’ll have an eye in for each terminal on your relay. Now what do you say we tested out. Let’s go ahead and plug in our pie. Power it up and ssh into it. Once I’m logged in, I’ll start a new python script with nano naming it Scare pie dot pie. She bang. Did I scare you? 

Look, come here close. Look, it’s right here. Look, it’s right there. You see it? All you gotta do is grab it Kendall, come here. All you gotta do is grab it right here. <laugh>, no milli. Come here if I’m milli 

And we’ll first start with importing things on. The most important thing we’re going to import, sorry, is the raspberry pie gpi i o library. So we’ll do import r rpi dot g pio O as G PIO O. And actually that’s all I care about right now cuz we’re just testing. Next we’ll set our G P I O mode with G pio O dot set mode and parentheses will say G pio o dot board. And all that’s doing is telling it what numbering system we’re gonna use for our G I O pens. Next we’ll set a variable. I’ll name it relay. Now I’m going to have this equal the pin that we plugged into our raspberry pie, the one we used, which is 37. If you use a different one, obviously put that in. Now we’re gonna tell the raspberry pie to use that pin as an output, we’re gonna be outputting data, sending electro signal down that wire. 

So we’ll use the command G PIO O dot setup and in parentheses will say our variable relay pin 37 and it’ll say G pio o dot out. Now we’re almost done. All we have to do now is put in some code to make it open and close or connect the wires and disconnect. And actually I lied about importing. I do wanna import one more library. We’ll import time cuz you always need more time. So next we’ll do G PIO O dot output cuz we are outputting signal now and imprint thees will say which pen we’re gonna output on relay and we’ll tell it we’re gonna go G pio o dot high, which in the case of our relay is telling it to open up. Do not connect the wires. And with the next command we’ll tell it to go low dot low, which will close it. Connecting the wires. You’ll actually hear it click when we try it here in a bit. And then we’ll put it to sleep for a second time dot sleep. We’ll do two seconds and then we’ll do G PIO dot output once more and we’ll do it high opening it back up. Okay that’s our code control X, Y enter to save with nano. And then I’ll rub my code with Python three scare pie dot pie. And let’s see if it works. 

Hear that. Click and close. Let’s do it again. Ah, love that. It’s so cool. Put your finger on it, you can feel it connecting and closing the wires. Now if you haven’t already, let’s go ahead and connect to Halloween prop and see how this will actually work. I’m gonna grab our guy from earlier. Oh sorry, didn’t mean to hurt you. I’ll take that try me wire. 


Are you? There it is. And actually I gotta strip it a bit more. Expose some more wire. Wire. 

I’m be right back. 

Got it. 


This is kinda hard to maneuver this guy. Okay, so now I’m my relay looking at K one, which is the first terminal. I’m going to unscrew the first two terminal holes from the left. I’m gonna plug in one of them and I’m gonna put one of the wires inside one of ’em. Screw that in to make it tight and then do the other one. So now if I run my python command once more, let’s see what happens. Ah shoot the wires came out. Make sure they’re tight. <laugh>. Dang it. All right, now this should be tighter. Ready? Let’s try it out. 


Cool is 


And often you can turn ’em off cuz the if you do the try new button again, it turns it off. 


Isn’t that cool? Oh that’s magic. So that right there is the baseline on how we’re going to trigger our Halloween props. And actually fun fact, that’s how most haunted houses, if you’re a fan of haunted houses like I am, will trigger their props. But I guarantee you they’re not as sophisticated as us using Python. Actually I know because I toured these and talked to the guys we’re more advanced 

Snack. Give me a snack you you’re in the way the camera, it’s not gonna help you. 

So now it’s pretty cool that we can trigger it with Python. But oftentimes you wanna make this automatic, you don’t want to be there. You wanna scare everyone even when you’re not there. Now it’s time for the motion sensor and this thing is nuts. So first let’s get it wired up before we program some Python. I’m gonna grab three female to female DuPont wires. Now looking at my motion sensor, I know the very left pen is for ground, so I’ll plug that first one into ground and I’ll plug the other end on the raspberry pie into pen. What number is that? Pen six, which is another ground pen. And then grabbing another DuPont wire on the motion sensor. I’ll plug this into the very far right pen, which is for power. And I’ll plug the other end into pen four on the raspberry pie, which is also a five volt pen. 

So that got our motion sensor powered up. Now the middle pin is the data pin. I’ll take my third wire, plug it into the pen on the sensor <laugh>, show it to the middle one first. This is hard. And I’ll plug the other end into pin 35 on the Raspberry Pi. All right, now time to code. I’m gonna start a new script just to test. So I’ll do nano motion test dot pie. Just like the relay, I’m going to import the G P I O library by doing import RP lowercase. I do G P I O as G PIO o. I’ll also import time and that’s all I need right now. And just like before, we’ll set our PIO O mode G PIO dot set mode, G PIO dot board. And then we’ll set up our pin for our motion sensor. Now this will be a bit different. 

So let’s first assign our pen, we’ll do a variable called motion and have that equal, what was the pin 30, remember 35? Yes, 35 I think. And then we’ll set that pin up as input rather than output because the motion sensor’s gonna be sending data to the Raspberry Pi. So we’ll do a G PIO dot setup and parenthesis will specify motion our pen and we’ll say G P I O dot N, all upper case. And now with that set we can test it. Then we’re gonna do a wild statement. While true this will run forever unless we stop it. I’ll hit enter tab over and I’ll set a new variable real quick. I’ll just call it something and I’ll have that equal G PIO O dot input. And at parenthesis I’ll say the variable motion, which is our sensor. I’ll hit enter tab over once more and I’ll say print something. 

And what this will do is actually print what information or what data the motion sensor is sending to the raspberry pie. And then just after that I’ll enter tab over into a time dot sleep for one second. So it’ll print it every second. Click control x, y enter to save. Let’s run our script. Python three. Motion test dot pie. Ready, set, go. Okay, so right now it’s printing zero, which does mean there’s no motion. But now if I wave my hands in front of it, ah look that one one means motion detected. Look at that. And that’s how this works. So now that you have it wired up and you know how to program it, the possibilities are endless. So now what I wanna do real quick is set this up to trigger my buddy over here. Let’s do that right now. I’ll do control C to close up script and let’s take everything we just did with the motion sensor and add that to our relay script. 

I’ll do nano scare pie dot pie, I’ll add all the information for our motion sensor. I’ll take all the stuff out at the bottom real quick and I’ll do another wild true state while true. And then I’ll put it if statement in here. Now if all this is like new, you’re like whoa, what’s Chuck even talking about? What even is Python? I’ve got a Python series where I cover pretty much all of this. So check it out over here somewhere. It’ll fill in the gaps on some of the stuff I’m doing right now, but don’t leave yet. I’ll walk you through everything right now. No big deal. Go grab me. I’ll waff on you Tre. 

So we’ll do if something equals double equals one. So we know that it’s gonna print zero when nothing’s there one when something is. So we’re gonna say, hey, when something’s there, when one happens, do this thing. So colon enter, we’ll tab over twice. So we’re nested under our if. And this is where I’m gonna trigger my buddy over here. What should I name him? Spencer. His name is Spencer. I don’t know why he just came to me. I’ll do G P I O do output relay. I’ll first put him high to make sure it’s open and then just under that I’ll put him low. I’ll leave it open for two seconds and then I’ll close it. That way it gives this guy time to realize he’s been triggered. And that’s it. I will un nest myself and do a time dot sleep. And now this time I’ll do five seconds and that’s it. So let’s save it. Control X, Y enter to save. I’ll run our script Scare pie dot pie. So right now, no motion, right? Nothing’s going on 


How cool is that? Motion 


Stay still. So right now I’m not moving. I’m not moving if I move 


I love that. Now what do you say we add in our sound just under where I triggered the relay. I’m gonna add all my sound information here. I’ll import pie game and then just under, when I trigger the relay, I’m gonna play the sound. That’s it. Let’s test it out. Control X, Y enter to save, run our script. Okay, no motion right now if I’m moving my coffee cup, 

I love 

It. That is pure magic. Let’s do it again. Okay, that’s enough of that. 

Now let’s talk about the raspberry pie camera. They’re actually a ton of different cameras you can get for the raspberry pie here I have the pie camera too, but I also bought a couple others and they all work great. So now our goal here is to capture the scares we perform with this guy or whatever guy you have. So first we’ll get it plugged in. You’re gonna plug it into the slot that’s right next to the audio cable or the audio jack. The one closest to the E uh, USB and Ethan Outport. You’re gonna plug in your ribbon cable with the blue tape side facing the usb. Make sure you lift that latch, slide that cable in there and then close the latch. It’s kind of delicate work. Bam. Got it. Okay. Now just a little bit of work to set it up. And also if you had your raspberry pie up and you start messing with that, it just kind of breaks your pie for a second. 

So go ahead and do a reboot if you have that issue. I’m gonna do that right now. Actually I won’t even reboot. I’m just gonna unplug it. Bye. And wait for it to come back up. Once you’re back up, we’re gonna do something kind of weird. We’re going to enable legacy camera support on your raspberry pie. To do that we’ll do pseudo raspy dash config and then we’ll scroll down to option three interface options. And then I one, go ahead and hit that. We’ll hit yes to enable legacy camera support. Okay, tab over to finish and yes to reboot. We’re doing legacy because it plays the nicest right now with Python and that’s what we’re using when you’re back up. Let’s do a quick test to make sure your camera is working. I’ll use a command RAs b still. This’ll just take a quick photo with your camera, so make sure you smile. We’ll do a dash o and then we’ll name it test dot png. Ready, set, go. Let’s take a look at it. 

<laugh>. Beautiful <laugh>. So mine works. Let’s also do a video test. The command will be raspy vid, we’ll do a dash o. We’ll name that TES dot H 2 64. And because it’s the video, we’ll to set the time. So we’ll do a dash T for 10 seconds, which is 10,000 milliseconds. Ready, set, go. Now, right now it’s in that H 2 64 format. We wanna convert that to MP four so we can play it everywhere else. For that we’ll need a tool. You can install this real quick right now. Pseudo a PT install. It’s called G P A C I believe. Just like that. We’ll do a dash y to confirm that. And once installed, we’ll do this command MP four box. We’ll do a dash add, specify our file, which is test H 2 64. And then the following one to name it as four or convert it to ready, set and go Done. 

That was easy. Oh almost. Yeah, it’s done. Now let’s take a look at that. Perfect little emotion sickness. See, but <laugh>, it works. It’s actually not bad looking either. So now that we know the picture works and the video works, we can harness this to do something pretty cool for Halloween. Now to use it with Python, we will need to install one more thing, just one command pseudo a P T install Python, three dash pie camera and that’s it. So now I’m gonna add this camera to our existing scare pie script, nano scare pie dot pie. And I’ll do from pie camera import pie, capital C camera. And then just below that I’ll set some information about it. And I’ll keep in mind I’m gonna have all this documentation, all this code in a link below that you can check out and just practice with and it won’t be as messy as this. 

Let’s go ahead and set up our camera real quick. I’m gonna set a new variable called camera and have that equal the function pie camera, capital P, capital C, parenthesis. And then I’ll set the resolution and frame rates. Camera dot resolution equals and parenthesis 10 80 by 10 20. And then camera dot frame rates and I’ll have that equal 30 frames per second. Now that’s pretty much all we have to do to set it up. Now we have to do is tell Python to record it when we sense some motion with our emotion sensor. So let’s go to our wild true statement at the bottom here. So here we have it to where if we sense motion, if something equals one, then do all this stuff. We wanna have our camera start recording as well when something is one. And I want that to happen first. 

So I’m gonna do that right after something happens. So just under our if statement, I’m gonna nest it over and we’ll call our variable camera dot start under Sure recording and then parentheses, we’ll specify the file name. Now we could just hard code it right now. Actually we will do that just for testing Scared dot H 2 64. And then what I’ll also do is time dot sleep for two seconds to give it time to start recording. And then when everything’s said and done, the very last thing we’ll do at the very end is camera dot stop underscore recording and then opening closing parentheses. And that’s it like we have a camera set up and it should work when motion’s triggered. Let’s do control X, Y enter to save Python. Three scared pie to run our 


Ready, set, go. Okay, let’s test it out. So let’s call some motion, some commotion over here. Bam. Motion detected. It should start with freaking aid. 

My birthday, my breath. Oh that is 

So enough. If I do Ls, we should have a scared dot H 2 64 file there. If I convert that with MP4 box, 

We can watch it right now. <laugh>, which is just me looking crazy all the time. Now there are a couple of house cleaning things we can do to make sure things run smoothly. For example, we may want a different file name created for each video recording so it doesn’t keep overriding itself. Cause right now it’s gonna overwrite scared the H 64 every time you do this. So we can define a file name and what I wanna do is do a file name with a timestamp on it that’ll make sure it’s unique and it’s helpful. So first I’ll import at the top here. Date time, actually I’ll do from date time, import date time, and I’ll create a new variable called current. And I’ll have the equal date time dot. Now opening. Closing parentheses, which will just get the current date and time <laugh>. And then down here in our if statement, before we start recording, I’ll define the file names. 

I’ll say file name equals current. And actually I want current to be a string. So I’ll wrap that in a string function, s str, and then I’ll add that. And what I’ll do is I’ll call this pie scare. I’ll create the string pie scare. Then I’ll add this to the variable current that we just created. And actually I need to convert that to a string. So I’ll do SST r, the string function, and then I’ll add that to the file extension dot H 2 64. And then I’ll change our camera dot start recording to be the variable file name. That should do it. So let’s control X, Y enter to save. Let’s run our script. That launches 

Done. I do Ls. There’s a new video right there. Now it’s kind of messy. We could do some things to fix that, but that works. Now what you’ve seen so far, I would say is like a basic level of spookiness. It’s still very cool. I mean triggering it with motion. And actually you can do other triggers like, like I have one trigger that’s a vibration sensor, so I’m gonna put that inside a candy bowl. And you know, when kids reach for candy, something happens, which actually leads me to the next thing I’m doing, the next level of spookiness. And that’s where I decided to buy some legit haunted house Halloween props. This isn’t stuff you can buy at Home Depot in Target. So I found this website called fright or something, but it’s, it’s amazing. It’s not cheap. So you have to love Halloween. 

But I was drooling. So I bought a couple things all powered by pneumatics. So I bought a prop launcher <laugh> that’ll do this. And then I also bought an ankle blaster that will blast air. And of course I need to power this with air. So I needed a really heavy duty compressor. So I got one. Now what’s interesting is these are all controlled by a raspberry pie alike device called a pico boo. Peekaboo <laugh> it. It’s a neat name, but it’s basically a dumb version of a raspberry pie. Now what it does built in is pretty cool. They actually have a builtin relay and it does provide power to the props. So I still use the peekaboo, but I connected the peek kaaboo to my raspberry pie. That way I can control all these Halloween props, the legit haunted house props with Python. And this is something I don’t think a lot of haunted houses do. 

So if you’re watching this haunted Houses, let me help you because your stuff can get a lot more complex and a lot more crazy. So what you’re about to see here, and you’ve probably seen throughout this video, sprinkled throughout me scaring people, is a lot of python fun, powering a bunch of different props, recording videos. It’s, I got a little crazy this year. I spent way too much time on this. But a special shout out to everyone who’s helped me do this. My wife, for dealing with my craziness, buying all these props and helping me decorate my entire team. So wave team, say hi. And Luke, my kind of handyman extraordinaire, he built me a coffin. So if you know a guy who can build you a coffin, that’s a friend. Thanks Luke. So anyways, I’ll probably have a few more scares. I’m gonna show you right now, but that’s my Halloween special this year. Was it spooky? I hope it was. Oh.

Check Out Network Chuck's Coffee and MERCH Shop