Halloween is upon us, and this year I'm building a series of smart Halloween decorations that are also Raspberry Pi projects. So far, I’ve created a Raspberry Pi-powered zombie arm that slaps guests and a person-following creepy head.
However, one of my all time favourite decorations is a fog machine. The only unfortunate thing about them is that they're analog. Now, with a bit of hacking, we're going to be connecting a fog machine to a Raspberry Pi, and activating it with person detection. This way, we only use fog juice when there are people close by. Here's how to get started.
What You’ll Need For This Project
- Raspberry Pi 4 (opens in new tab)
- A relay module compatible with the Raspberry Pi (opens in new tab)
- At least 6 jumper cables
- A soldering iron and solder
- A fog machine with a remote control (I picked mine up from walmart)
- Wyze Cam V2 / V3 or Raspberry Pi camera
How To Build a Smart Fog Machine with a Raspberry Pi
1. Set up your Raspberry Pi. If you don’t know how to do this, check out our story on how to set up your Raspberry Pi for the first time or how to set up a headless Raspberry Pi (without monitor or keyboard).
2. Install git as necessary, and clone the repository to your Raspberry Pi.
cd ~/ sudo apt-get update && sudo apt-get -y install git git clone https://github.com/rydercalmdown/smart_fog_machine.git
3. Descend into the cloned repository and run the installation command to install all lower-level and python-based requirements for the project to work.
cd ~/smart_fog_machine make install
4. Test your fog machine. Pressing the button once should cause the fog machine to turn on, pressing it again should cause it to turn off. Holding the button on my particular machine results in the same behavior as pressing it.
5. Remove the screws from the back of your remote and open up the back panel.
6. Put the batteries in your remote if they are missing, and locate the solder points that are connected to the fog button.
7. Using a jumper cable, short the pins until you find the ones that cause the LED on the front of the remote to flash. In my case, that was the top right and bottom left pins when the remote is on its back and the IR LED is pointed upwards. If your remote doesn’t have a status LED on the front, you can view the activity of the IR LED with the front-facing camera on your phone.
8. Once the pins are found that activate the LED, solder two jumper wires onto them.
9. Create a hole for the jumper wires to exit the back of the case. I used my soldering iron to burn a small divot in the side of my remote.
10. Close up your remote and test it. The status LED should blink upon push of the button, as well as shorting the two jumper wires coming out from the case.
11. Connect the VCC pin of your relay to the BOARD pin #4 on your Raspberry Pi.
12. Connect the Ground pin to Raspberry Pi BOARD pin #6.
13. Connect the channel 4 pin of your relay to the Raspberry Pi BOARD pin #5.
14. Connect the two jumper wires coming from the remote to the common, and normally open ports of channel 4 of your relay. On my relay, these are the leftmost ports. You should not see your LED flash at this time.
15. Flash the custom RTSP firmware to your Wyze camera using this tutorial (opens in new tab). Installing RTSP support allows us to connect to the camera and grab frames directly with Python.
16. Get the RTSP URL value from your Wyze application, and edit the RTSP_URL variable in the Makefile to point the Raspberry Pi to your camera. You can find the RTSP URL in the “Advanced Settings” section of your Wyze application on your phone.
nano Makefile # Edit the file with your RTSP URL from your camera RTSP_URL=rtsp://your_username:your_password@your_camera_ip/live
17. Test your system with the make run command. The LED should flash on your remote briefly as the system starts up and tests itself. It should also flash when a person is detected by the camera.
18. Position the remote so it has a clear line of sight to your fog machine.
19. Plug in your fog machine, use the make run command, aim the camera at a person, and the fog machine in your desired direction, and enjoy!
If you’re looking for more of a challenge, I’d recommend cloning the IR code with an IR receiver compatible with the Raspberry Pi, and retransmitting it with an IR LED. This was my original plan, but I unfortunately wasn’t able to get things functional on time - but there’s always next year! Happy Halloween!
Still have not quite figured out the PEM7D IR photoelectric beam sensor, but working on it.