Foginator-Banner-002.jpg

 

Welcome to installment #002 of my Foginator 2000 Halloween Project here at Element14. In this week's episode I am going to cover the basics of automating an ADJ VFI1300 1300W Fog MachineADJ VFI1300 1300W Fog Machine via a Raspberry PiRaspberry Pi and a Parallax PIR Motion SensorParallax PIR Motion Sensor. The process is fairly simple, and only involves a handful of lines of Python code, so even the code-beginner should easily be able to get this working.

 

20150916_212859_HDR.jpg

 

Below is a table containing the parts you will need for this project. In addition to these parts you will need a drill, drill bit, soldering iron, stranded hook up wire, and some female to female jumper wires.

 

Newark Part No.

Notes

Qty

Manufacturer / Description

38Y646738Y6467

RPi

1

RASPBERRY PI 2, MODEL B

38Y647038Y6470

SD Card

1

RASPBERRY PI 8GB NOOBS MICRO SD CARD

44W493244W4932

PSU

1

USB PORT POWER SUPPLY 5V, 1A

06W104906W1049

USB Cable

1

USB A PLUG TO MICRO USB B PLUG

53W628553W6285

WiFi Dongle

1

USB WIFI MODULE

 

 

 

MCM Part No.

Notes

Qty

Manufacturer / Description

83-14732

Relay Module

1

TinkerKit Relay Module

555-19400

Fog Machine

1

Fog Machine Hurricane 901

28-17976

Parallax PIR Sensor

1

PIR Infared Measurement Sensor Module

 

 

The Theory

 

 

The fog machine will trigger when trick-or-treaters trip its motion sensor. Throughout this project we will call this a “trick-or-treat event,” or “T&T Event” for short. So when the T&T event happens, the fog machine to fire off and begin fogging out the immediate area. To do this we need to first take a look at how a fog machine works, and methods to trigger a fog-machine based on motion detection. First we will take a quick look at how a fog machine works.

 

fog-machine-diagram1.jpg

In the image above you can see how the basic operations of a standard fog machine works. Fog liquid is pumped from a reservoir into a heater block, which flashes to a vapor and exits out of a nozzle due to the pressure created by the expanding gasses. Everything is controlled from a central control interface, and depending on the quality and brand, this could be nothing more than a few passive components all the way up to a full scale MCU-based controller.

 

On most fog machines with manual remotes, a small LED indicator is present that illuminates when the heater block has reached optimal temperature. On the ADJ 1300W that we are using, this LED, as well as the push button are powered by low voltage, but on many fog machines, these components can be powered by mains voltage. Exercise extreme caution and high voltage safety when modifying any fog machine.

 

So in theory we should be able to use a relay to trigger the fog machine using the wires that go to the push button. As an added bonus we should be able to use the signal from the “ready” led to tell the Raspberry Pi that the fog machine is armed and ready to spray fog. If your fog machine uses high-voltage for its LED, then this will not work, and you will have to design a rectifying solution. So the bulk of this blog post will be showing you how to modify the manual remote control for the ADJ VFI1300 1300W Fog Machine, this method may work on other ADJ fog machine products, but I am not sure. Remember that this will most certainly void your warranty, and you are assuming all risk associated with modifying a product to perform in a way it was not designed to do from the factory. I take on no responsibility if anything should go wrong.

 

 

The Schematic

 

 

Fog-Control-Schematic.jpg

As you can see in the image above, my plan is to utilize the TinkerKit relay module as a sort of “smart” switch to fire the fog machine. The PIR-based motion sensor will be used to sense motion which will tell the Raspberry Pi 2 to trigger the relay. I am using seven of the Raspberry Pi 2’s GPIO pins including both of its 5-volt pins, two of its ground pins, and three actual I/O pins.

 

Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated-2700x900.png

 

Using the Raspberry Pi 2 GPIO Pinout reference above, you can see that the three I/O pins I am using are (BCM schema)

  • Raspberry Pi GPIO4 to TinkerKit Relay Module
  • Raspberry Pi GPIO17 to Parallax PIR Motion Sensor
  • Raspberry Pi GPIO27 to Fog Machine Remote “Ready” Indicator LED (used in a later project update)

 

With our schematic planned out, let’s begin the build by modifying the ADJ VFI1300 1300W Fog Machine’s manual remote control. Again, if you are modifying any fog machine’s remote control other than the exact model that I am using in this tutorial, beware that it could utilize mains voltage instead of low voltage. Proceed with caution.

 

 

Modifying The Remote

 

 

20150916_222341_HDR.jpg

Here we can see the manual remote that came with the ADJ VFI1300 1300W Fog Machine. Notice the “Output” button and the “Ready” LED. These are the objects we will be hacking some wiring to in order to connect them to our Raspberry Pi and TinkerKit relay module.

 

20150916_222411_HDR.jpg

Opening the remote up is quite simple and only requires the removal of four phillips head screws. Save the screws as we will be putting this back together when the modifications are complete.

 

20150916_223556_HDR.jpg

Once the back has been removed you will see a bundle of wires attached to two leads of the momentary push button and the “ready” indicator LED. To fire the fog machine one simply needs to close the “trigger” circuit by pressing the button. This means that we can easily modify this to utilize a relay to trigger the fog machine. Additionally we can use the low-voltage signal from the indicator LED to tell the Raspberry Pi that the fog machine is armed and ready to fire.

 

20150916_225217_HDR.jpg

Before we can solder in the wiring, we need to make room to place our three binding post. Since this case is tapered, you need to drill the holes just above the ADJ logo as seen in the image above. Make sure that you space the holes so that all three binding post will fit, and their mounting hardware does not get obstructed by the adjacent binding post’s hardware.

 

20150916_225648_HDR.jpg

As it turns out, the plastic used in the casing for the remote is quite cheap, and very brittle. I used a brand new, very sharp drill bit to drill a pilot hole, and then a larger one that was just as sharp, and the plastic fractured and flaked in a few places. If this were a proper glass-filled ABS or Nylon case this would not have happened.

 

20150916_230341_HDR.jpg

Take notice of how close the nuts are that fasten the binding post to the case. I failed to account for the proper spacing when laying out where to drill the holes, and somehow I got lucky enough that everything just barely fit. I would suggest that you add a dab of CA glue, hot glue or some other adhesive to these nuts as they tend to back off the threads after some time passes.

 

20150916_230351_HDR.jpg

As you can tell, I am not using the binding post I listed in the parts list for this post. I forgot to order the correct ones when I designed the kit, and am using some I found in my scrap parts box. The ugly green binding post was painted with craft acrylic paint from a local hobby store. It did not adhere as well as I wanted, but it serves its purpose of identifying the post as being different.

 

20150916_231709_HDR.jpg

Hacking the switch to work with our relay is super simple. You simply need to solder one of the switches leads to either the red or black binding post, and then solder the other switch lead to the other binding post. While you are in here, solder a wire from the anode side of the LED to the other binding post.

 

20150916_231808_HDR.jpg

I messed up and accidentally heated the heat shrink on the LED wire with my soldering iron which caused it to no longer slide over the LED’s lead. Instead of cutting it off and adding a new piece in, I simply chose to wrap it in 3M Super 33 Electrical Tape.

 

20150917_000450_HDR.jpg

Now simply screw the bottom of the case back on, and then cut three 24” lengths (or longer depending on your needs) of the stranded hook-up wire. I chose to use red, black, and yellow. For a cleaner look, I chucked the wires up in my cordless drill, and twisted them together. I lost a few inches in length because of this, but it looks much cleaner and is easier to manage. Connect the three wires to the binding post as shown in the image above. Red to red, black to black, and yellow to yellow.

 

 

Connecting The PIR Motion Sensor

 

 

Pir-Schematic.jpg

Connecting the Parallax PIR sensor to the Raspberry Pi is quite easy as well, and only requires a few lines of code to test its functionality. To start you will need to connect the PIR sensor to the Raspberry Pi as per the diagram above, following the pinouts below.

 

  • PIR “Out” Pin  to Raspberry Pi GPIO17
  • PIR “VCC” Pin to Raspberry Pi 5V Pin
  • PIR “GND” Pin to Raspberry Pi GND Pin

 

20150916_213334_HDR.jpg

With those connected, you will need to boot up your Raspberry Pi 2 with the NOOBS SD Card installed, or any SD Card with Raspbian installed on it. It is also advisable to update your version of Raspbian to the latest. If you need to learn how to do this, I briefly cover it in part two of my other Halloween Project, Trick or Trivia.

 

The Code

 

With everything updated, and the SSH connection still open, type the following command to create a python file for testing the PIR sensor

 

sudo nano test-pir.py


This will create the file and open it in the nano text editor. Before we paste the python code in, lets take a look at it step by step and what each step does.

 

We need to import the Raspberry Pi GPIO library, the time library, and the system library. So python can execute our code.

 

import RPi.GPIO as GPIO
import time
import sys


































 

Now we need to set up our GPIO pin. Note that we are using the BCM schema to run our code. For those of you who do not know, the Raspberry PI’s GPIO pins can be configured two different ways, GPIO.board and GPIO.bcm.  When setting the GPIO pins mode, you are telling it what numbering scheme your code will be adhering too. Unfortunately the pin numbering between each of the different modes changes on various models and revisions of the Raspberry PI. So if you are not running a Model B+ or Raspberry Pi 2, you will need to search the internet for the proper pinouts for the mode you select.

 

Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated-2700x900.png

 

The GPIO.BOARD option specifies that you are referring to the pins by the number of the pin the the plug - i.e the numbers printed on the board (e.g. P1) and in the middle of the diagram above.

 

The GPIO.BCM option means that you are referring to the pins by the "Broadcom SOC channel" number, these are the numbers after "GPIO" in the green rectangles around the outside of the diagram above.

 

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.IN)

























 

Now we can build a function to test our code. We will call the function fire_fog. The code below it basically says to set GPIO 4 to True (high) for three seconds (triggering the fog machine, then set it to False (stop firing fog), then the code cleans up the GPIO Pins, and exits the script.

 

def fire_fog():
    GPIO.output(4,True)
    time.sleep(3)
    GPIO.output(4,False)
    GPIO.cleanup()
    sys.exit()
   

























 

Now we need to tell the to wait for a high signal on GPIO17 (movement detected by the PIR sensor), and to run the fire_fog function if that high signal is present. I put this in a “while” statement so that it would loop over and over until motion is detected. There are better ways to do this, but I am still brushing up on my python.

 

while 1:
    time.sleep(3)
    if GPIO.input(17)==True:
        fire_fog()

























 

Now past the following lines of code into the file. You can also download this code from it's GitHub Repo. If you are using a terminal such as putty, you can simply copy this code and right click in the terminal to paste it.

 

import RPi.GPIO as GPIO
import time
import sys

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.IN)

def fire_fog():
    GPIO.output(4,True)
    time.sleep(3)
    GPIO.output(4,False)
    GPIO.cleanup()
    sys.exit()

while 1:
    time.sleep(3)
    if GPIO.input(17)==True:
        fire_fog()

























 

Now save and exit out of the nano text editor. If everything is connected correctly, and the code is correct, we can move onto connecting the TinkerKit relay module to the Raspberry Pi and test our PIR sensor out.

 

 

Connecting And Testing The Relay

 

 

Fog-Control-Schematic.jpg

Now connect the relay as shown in the schematic above, and the pinout below. Only make the Raspberry Pi to Relay connection at this time.


  • Tinkerkit Relay + Pin to Raspberry Pi 5V Pin
  • Tinkerkit Relay Signal Pin (Middle) to Raspberry Pi GPIO4
  • Tinkerkit Relay - Pin to Raspberry Pi GND Pin

 

20150916_213438_HDR.jpg

With everything connected, we can now test the PIR and Relay systems. From the terminal, enter the following command:

 

 

sudo python test-pir.py


20150916_213558_HDR.jpg

 

 

The script will wait a few seconds before looking for motion, so wait a few seconds, and then wave your hand in-front of the sensor. It will illuminate, indicating that motion was detected. If you do not hear the relay click on, then wait a few more seconds and try again. If the click does not happen after waiting for 15 seconds, then check the code again. If the code is working, you will hear the relay click on for three seconds and then click off.

 

 

Bringing It All Together

 

 

Relay-Pins.jpg

Now connect the red and black wires to the “Comm” (Common) and “NO” (Normally Open) contacts on the relay. Don’t worry about the “ready” (Yellow) wire for the moment. We will revisit it in another post.

 

20150917_000506_HDR.jpg

If you have not filled the fog machine with fog juice yet, now would be the time to do so. (I recommend Hog Fog as it is super clean, thick, low-lying, and have used it personally many times!)  With everything connected you can connect the remote’s cable to the fog machine, and then connect the fog machine to the mains supply. Switch the fog machine on, and wait for about 5 minutes for the green light to come on. The run the script again from the terminal.

 

sudo python test-pir.py

 

If everything is correct, then the PIR sensor should begin looking for motion three seconds after the script has been triggered. These three seconds allow for you to get out of the way when setting the Foginator2000.

 

 

That is going to end it for this installment of Project: Foginator2000! Tune in next week for installment 3, in which I work on the environment sensing coding & testing aspect of the project. If you have not yet seen my other Halloween project for 2015 here at Element14, head over to Trick or Trivia: A trivia-based Halloween Candy Dispenser - Part 001. Until next time, remember to Hack The World and Make Awesome!

 

Win this Kit and Build-A-Long


  1. Project Introduction
  2. Fog Controller Hardware and Test
  3. Environment Sensing Coding & Testing
  4. Ambient Audio Hardware and Coding
  5. Lighting Coding and Testing
  6. October 16th -  Final Assembly and Testing
  7. October 23th - Project Wrap-up