This project came about when I was chatting with my friend Andrew about Halloween. He wanted to know how easy it was to trigger effects from the motion of people passing by. I mentioned that I'd been experimenting with radar-based human presence detection modules.
The effect to trigger was a smoke machine. Smoke machines are inexpensive and because I was going to be taking it apart, it made sense to get a new one rather than break Andrew’s only one. One thing that stood out in the manual was the warning that the remote control button had mains level voltages, 240v AC in the UK. I thought that a bit strange and knew it could add challenges to the project, particularly around safety.
When I took it apart to see the electronics, the main thing I noticed was that there were hardly any components. The control box consisted of a PCB with two LEDs and one button. Three wires headed back to the unit. The LEDs turn on when the heater is up to temperature. I've seen this kind of thing with welders where it is called "Duty Cycle"; you can only run the system for a period of time before you need to let it take a break. In this case, I suspect the smoke cools the heater and it needs time to warm up again.
In the smoke machine were small devices that appeared to be a pump, heating element, and some kind of temperature sensor. The rest of the box was empty, apart from a space for the bottle of smoke liquid. The temperature sensor turned out to be a simple bimetallic strip, which opened a switch when it reached the desired temperature.
The thing I've found with these really simple designs is that they can often be tuned to the components they have; this is an important factor when swapping in automation circuitry.
For the switch, I installed a relay contact, and for the LED, I used an opto-coupler. I had initially used an opto-coupler to drive the relay, but when testing, I found that needed quite a bit of current to activate. I swapped it for a TIP31C transistor, which worked reliably. It required a bit of reworking of the board, but conveniently the transistor fit in the holes left by the opto-coupler.
To prevent radio interference when the relay was activated, I added an "RC snubber", a component that resembles a large capacitor, but also contains a small resistance. This stops clicks and pops in the radio or mobile when the contacts make or break. It is important to get a device that is rated for 240V. On top of this, I added an MOV (or varistor), which suppresses spikes and prevents the relay contacts from welding shut if there is a high current due to an inductive load such as a motor, or in this case, a pump.
On the input side, I decided to add protection too. I added some TVS diodes to ensure that the voltage across the LEDs does not get too high. Next, I added a PTC fuse; this ensures that the current through the opto-coupler is restricted.
To control the system, I decided on a Pi Pico as they are inexpensive. In addition, the MicroPython coding is straightforward, making it easier to modify, if necessary. Pi Picos are easy to power from batteries.
The human presence sensor provides a logic level output, which goes high when a person is detected. I realized, however, that this is a 5V signal, and the Pi runs at 3.3V. To keep things simple, I decided on a 5V boost regulator to provide the power for the sensor and a simple resistive potential divider to set the logic level back to 3.3V.
The opto-coupler connected to "heater ready" signal is pulsed at 50Hz. But because this is an AC signal, the diode will only be conducting on half the cycle. In order to detect this, the number of pulses are counted each second. If this is above a limit (approximately 20), it would signal that the heater was ready and smoke could be triggered.
Testing
The circuit is best tested with low level signals before the mains voltages are applied.
Before populating the Pi Pico, we try driving the opto-coupler using a wire from the battery to the input pin and listen for the relay’s click on. Adding an LED and resistor to form a circuit on the high side will test that the relay circuit is working, although I mostly tested that by listening for the click when the coil was energized.
For the input side, we can apply a low voltage across our photo transistor either by using a simple AC transformer or a signal generator.
Before I soldered the Pi Pico in place I tested the other components and realized that I had also wired the inbound optocoupler to the battery VSys rather than the V3.3. So another little adjustment was needed for the board. Finally, I realized rather late that the LEDs in the remote also had a tiny resistor, hiding under the board. I reproduced that in my circuit by breaking the track and soldering across the pins of the related components.
Code
The code for the project was written in MicroPython. My friend is a professional .NET software developer, but he doesn’t have a lot of experience with C. However, I thought he’d be quite capable of maintaining a Python program. I had considered the Meadow board series, but those are quite expensive, and the Pi Pico seemed a better choice. The main challenge was detecting pulses. That was accomplished using an interrupt to look for the change of state on an I/O pin and simply counting them. A timer then checks to see how many pulses have been detected.
A second interrupt checks to see if the motion sensor has changed states, and when both conditions are met, the code utilizes some randomization to generate the effect without being too predictable.
Full code is available at: https://github.com/Workshopshed/Spiders
Bonus Content:
- Download Code
Bill of Material:
Product Name | Manufacturer | Quantity | Buy Kit |
---|---|---|---|
EQUINOX Fog Machine with On/Off Remote, 400W | EQUINOX | 1 | Buy Now |
SCHRACK - TE CONNECTIVITY Power Relay, SPST-NO, 5 VDC, 8 A, V23061, Through Hole, Non Latching | SCHRACK - TE CONNECTIVITY | 2 | Buy Now |
Plastic Enclosure, Multipurpose, Polypropylene (PP), 80 mm, 200 mm, 160 mm, IP65 | ETERNA | 2 | Buy Now |
LED, RED, 10MM | VCC (VISUAL COMMUNICATIONS COMPANY) | 10 | Buy Now |
RASPBERRY-PI SBC, Raspberry Pi Pico, RP2040, ARM Cortex-M0+, 264kB RAM, 2MB Flash, Micro-USB | RASPBERRY-PI | 2 | Buy Now |
WAGO Wire-To-Board Terminal Block, Black, 1 Ways, 20 AWG, 16 AWG, 1.5 mm², Push In | WAGO | 3 | Buy Now |
MULTICOMP PRO Rocker Switch, IP65, On-None-Off, DPST, Non Illuminated, Panel Mount, Black | MULTICOMP PRO | 2 | Buy Now |
PULSE Medium Fog Fluid, 5 Litre | PULSE | 1 | Buy Now |
TEXAS INSTRUMENTS TRANSISTOR ARRAY, NPN, 2003, DIP16 | TEXAS INSTRUMENTS | 1 | Buy Now |
ONSEMI Optocoupler, Transistor Output, 1 Channel, DIP, 6 Pins, 60 mA, 7.5 kV, 100 % | ONSEMI | 2 | Buy Now |
DFROBOT Add-On Board, Microwave Sensor, Gravity Series, Arduino, Digital Interface | DFROBOT | 2 | Buy Now |
LED, RED, 3MM | MULTICOMP PRO | 30 | Buy Now |
TVS Varistor, 275 V, 350 V, 14D Series, 710 V, Disc 14mm, Metal Oxide Varistor (MOV) | YAGEO | 1 | Buy Now |
PTC Fuse | LITTELFUSE | 1 | Buy Now |
TVS Diode 5v | LITTELFUSE | 2 | Buy Now |
1N5817 1A 20V Schottky Rectifier Diode | STMICROELECTRONICS | 2 | Buy Now |
Additional Parts:
Adafruit MiniBoost 5V @ 100mA Charge Pump AP3602A |
Spiders (1 large, 4 small) |
Resistors (various) |
Battery Holder, 3 x C Type |