A fog machine can greatly affect the ambience of Halloween displays but unless you invest in an expensive one they can be impractical. The machines that pop up around the holiday must be plugged in to the wall, are not weatherproof, and have relatively small "fog juice" reservoirs. Requiring AC power isn't uncommon for Halloween decorations and they are often installed close to the house, under the eaves or porch covering, so workarounds for the first two challenges are familiar. The obvious solution to the fog juice shortage is to only make fog when someone is around to appreciate it -- but how?
Why Bluetooth Mesh?
Although standing around for several hours on Halloween night waiting to press buttons on remote controls might be an option for the most dedicated among us, ideally the remote controls would be able to activate themselves -- either in response to motion or the state of other devices. Similarly, running wires around the yard is fine in some situations but wireless communication is usually superior. A decade ago I would have advocated using IR to build a network that essentially consisted of a bunch of TV remote controls and receivers but now inexpensive radios are an attractive option because they:
- Are arguably easier to work with
- Don't require line-of-sight (or a convenient reflection)
- Aren't affected by ambient light or fog
- Allow bidirectional communication
- Offer a path to smart device interoperability
Fog machine operation
The main components of a fog machine are a heater, a pump, and a fog juice reservoir. More sophisticated machines can also include features like timers, lights, or chillers but you probably won't find such extravagances on $40 machines like this one.
The large block on the right is the heater. The red wires above it are connected to a thermostat that acts as a switch -- it closes whenever the heater drops below a temperature threshold. Insulating material helps the heater stay hot for as long as possible and is visible next to the thermostat, poking out of the enclosure.
The silver cylinder to the left of the heater is the pump. Its job is to pull fog juice out of the plastic reservoir and push it into the heater so it can be vaporized and expelled from the front of the machine.
The entirety of the machine's wiring fits in a single diagram:
Wired remote controls typically have
a button and at least one LED. An LED that indicates when the machine
is currently capable of producing fog is useful because it wouldn't be obvious otherwise.
This remote has two LEDs: one is on when the machine is capable of producing fog, the other when the machine is currently producing fog.
The original remote is a very simple device:
In summary:
- When the machine is ready to produce fog the thermostat is open and AC is available to the remote control via the BROWN and YELLOW/GREEN wires.
- Connecting the YELLOW/GREEN and BLUE wires together powers the pump
Replacing the remote
Nordic's Thingy:52 is a prototyping platform that combines an nRF52832 SoC, rechargeable battery, and a bunch of sensors into a neat little package. Putting a 3V microcontroller in control of the fog machine requires solving two problems:
- Detecting the presence of AC to determine that the machine is ready to produce fog
- Operating a switch to open and close an AC circuit
The first problem can be solved with the help of a cheap 5V wall wart. By taking it apart and connecting it to two of the wires from the original remote the Thingy:52 will think that it's plugged into USB whenever the fog machine is ready. As a bonus, this will also recharge its battery -- the same battery that keeps it from browning out when the heater becomes active!
The 5V from the wall wart is also hardwired to an LED on the top of the new remote's enclosure, to replicate the original remote's functionality. This 5V also supplies power to a separate board -- a board that solves the second problem by using a BJT transistor to open and close a 5V relay. This allows a GPIO output from the Thingy:52 to operate the relay, effectively replacing the functionality of the original remote's button.
Manual operation is useful, especially when positioning the fog machine during setup, so a large push button was also added to the new remote.Finally, an external power switch is needed so the rechargeable battery can be disconnected when the fog machine is in storage. The addition of seven wires, including one from VDD to the external power switch's LED, is the extent of the required modifications to the Thingy:52 itself.
Firmware
The Thingy:52 already has a USB_DETECT pin that is pulled high when 5V is present on the USB port so keeping track of when the fog machine is ready only requires enabling a pin change interrupt on a GPIO. The button for manual operation is handled the same way. Using a GPIO output to control the relay is even easier.
Adding Bluetooth Mesh is also pretty straightforward, at least when starting from the Light Switch sample in NCS. The original Light Switch sample enumerates four Elements, one for each of the LEDs on a typical Nordic development kit. Each Element has a Generic OnOff Server that allows the other devices on the mesh network to read and write the state of one of the LEDs.
The remote control only needs two of these servers:
- The server in the first element works like the button. Setting this element to 1 will produce fog until
it is written back to 0 or the heater becomes active. It is
automatically set back to 0 when the heater becomes active. If the fog
machine is not able to produce fog then setting it to 1 has no effect.
- The server in the second element is set to 1 when the
fog machine is capable of producing fog and 0 when the heater is active.
Writing to this element has no practical effect because the written
value will be immediately reverted. A client can read this value to
determine whether or not the fog machine will be able to immediately
produce fog.
The firmware, along with details for provisioning the node, are posted here. The nRF Mesh app is used for provisioning and configuring the node. It also presents a nice GUI that enumerates the Elements and their servers:
The app also allows for interaction with both of the servers. Selecting one of them and then scrolling down leads to a "Generic On Off Controls" widget:
The "READ STATE" button at the bottom does exactly what it claims and the state of the server can be toggled by pressing the "ON" button.
No comments:
Post a Comment