I co-organize Bellingham.Codes, a monthly meetup of software and hardware developers in Bellingham, WA. For our May 2017 event, we partnered with Particle to run a workshop around Photon devices and an earlier version of their excellent Relay Shield.
At my house every Friday night, my family and I make finger-friendly food (usually pancakes or pizza) and throw on a movie. It seemed only natural that I would wind up on a popcorn kick as a result, making my own stove-top popcorn from scratch. Since I knew we would have access to high-powered relays, I decided to rig up a hot air popcorn popper.
Serendipitously, a local church had a huge rummage sale were I bought not one, but _two_ hot air poppers. After a quick head-to-head test, the larger—and more powerful—Poplite popper earned the role of primary popper. (The other popper would later be sacrificed for its motor.)
Growing up in rural Pennsylvania, a certain "old man" (as he asked to be called) really wanted me to develop skills in electronics; try as I might, those skills never materialized. Though the hard parts of circuit design and fabrication were done, I decided to call that old man up and work with him on dissecting the popcorn popper and planning out the integration.
After much puzzling and scratching of chins adorned and unadorned with facial hair, we decided the internal mechanisms were too risky to mess with. Instead, we decided it was best to hook into the main power cable.
To replicate this yourself (and this works for more than just popcorn poppers!):
- Unplug the device. Seriously. [It doesn't hurt to have someone watch what you're doing, either, even if it's just over a video call!]
- Separate the two wires coming out of the device.
- Clip _one_ of the wires, and remove some of the insulation.
- Fasten the Relay Shield onto the device. I recommend 3M Mounting Tape, which is magical.
- Using large-gauge wire and wire nuts:
- a. Connect one exposed side of your device's power line to the ground (middle) post.
- b. Connect the other exposed side to the NO post. It should be marked on the shield. [If you're using the same version of shield, see the image below.]
- Plug in the Relay Shield. [Using the power supply.]
- Plug in your device.
Now that your device is built, you'll need to program it. Assuming you use the same version of relay shield, the attached code will work. If you are using the latest (version 3), you should use their
RelayShield library instead. To set this up for your device:
- Add the Photon to your Particle account.
- In the Particle Web IDE, create a new project.
- Replace the displayed code (the empty
loopfunctions) with the provided code.
- Click the "flash" button in the upper-right. [You may need to assign a specific Photon to the application in the Devices tab first.]
If you look closely at the code, you'll notice there is a "cloud function" called
. This is the function we want to call to, well, make popcorn.
When I planned the event for Bellingham Codes and Particle, I surveyed the attendees to get an idea of how comfortable everyone would be with hardware and with programming. Since some of the attendees weren't software developers, I decided to show off how you could get this device working using nothing but web tools. To trigger this Photon function, then, I chose Losant.
Here's how to configure Losant for yourself:
- If you want to use Losant Go (as I did), the individual steps are outside the scope of this tutorial.
- To install the app, start here.
- To configure the app, start here.
1. One way or the other, create an Application in Losant.
2. In that Application, create a Workflow. [If you're using Losant Go, the Application and Workflow may already exist.]
3. Edit the workflow, adding at least one Trigger and one HTTP Output.
- I recommend adding a Virtual Button as a trigger, even if only for testing.
- If you're not using a Virtual Button, test your trigger on its own. You should see it working in the Workflow editor of Losant.
4. We need two pieces of information from the Particle Web IDE:
- From the Settings tab, make a note of your "Access Token".
- From the Devices tab, click on the > button for the Photon you're using and copy the "Device ID".
5. Back in Losant, edit the settings for the HTTP Output you created:
- The "Request Method" should be POST.
- The "URL Template" should be
MY_DEVICE_IDwith the "Device ID" you copied earlier.
- The "Body Template" should be
MY_ACCESS_TOKENwith the "Access Token" you noted earlier.
At this point, you're ready to test everything! Once you trigger your Losant workflow, it will make an HTTP POST request to the Particle Cloud API, which will call that
function on your Photon, starting the hot air popper.
Good question. I went back to the "old man", and we talked at length about how to automatically reload the popcorn. I built a couple of prototypes, and it proved to be a much harder problem than I anticipated. Nevertheless, I built a basic version of what I think is the best design: using an auger.
Unfortunately, the first version didn't work at all. The motor was way too powerful without gearing it down, I could not get it to work with the Photon's PWM capabilities to otherwise slow it down, and I ran out of both time and ideas. This is what that auger looked like after a day of testing (and videotaping for hilarious posterity):
Though my attempts at automatically reloading may have been foiled, controlling the popper itself with a Photon was still a delicious, delicious success.
Thanks again to Particle for being awesome and sponsoring our event. We had a great time, and the Bellingham folks learned a lot. [One of the attendees was a 12-year-old, and he made an IKEA lamp blink S-O-S. It was awesome.] Stay tuned for more ridiculous devices from our labs.