Combine a Spark Core with IFTTT(If This Then That) and you can do anything. If This Then That is a service that allows you to perform a wide variety of conditional statements to do pretty much anything. You use it by creating recipes that put the internet to work for you. A Spark Core is an Arduino compatible wifi development board. The company has created an amazing software package and partnered up with IFTTT. This means that you can create IFTTT recipes that monitor variables on your Spark Core and do what ever you want. You can connect it to a WeMo switch. A WeMo switch is a wifi connected outlet. With a Spark Core, a WeMo switch and IFTTT, you can have the outlet turn on or off when a button is pressed or a sensor value has exceeded your set threshold.
Step 1: Bill of Materials
1. Spark Core, Spark Photon, or Spark Electron(Cellular) development board. For information on setting your dev board up, visit their Getting Started page.
2. 6 Momentary Push Buttons.
4. Vibration Sensor.
5. PIR Motion Sensor.
6. Piezo Buzzer or Speaker.
8. Adafruit Neo Pixel.
9. Eight 10K Resistors.
10. Power Button.
11. Three 4-40 screws.
12. Hot Glue.
There are three files to print. The enclosure front panel, the base, and the LED tunnel. I designed the LED tunnel to fit one of these Adafruit Neopixels. I printed my enclosure with an Ultimaker 2 using Colorfabb Shining Silver for the enclosure and Taulman PLAtinum for the clear led tunnel. There are also enclosures you can buy. Then you can drill the holes and make the cutouts for the buttons and sensors. Also, if you don’t have access to a 3D printer, you can use a service like 3D Hubs to get your enclosure printed for you.
Step 3: Create the Circuit
Use the circuit diagram to plan your circuit out. Prep all of the buttons and sensors using heat shrink tubing where necessary. Cut one end off of a usb cable and strip the black and red wire. We will not need the green and white wire because we can flash our code via wifi.
Step 4: Assemble Your Command Center
Use hot glue where needed to secure all of your sensors in place. Take care to not use too much hot glue at a time because you can warp your enclosure if it gets too hot. If you are using the hdx vibration sensor, be sure to place it somewhat vertical as my testing found that it had more responsive readings when it was positioned vertically.
Step 5: Tweak Your Code
Now that you have set up the circuit that you want, it’s time to tweak your code. Just copy my code from the txt file into your Spark Build Web IDE. Click flash to upload the code to your Spark Core over wifi. I have broken the code down to publish events when each button is pressed. There is a Spark Variable for each sensor of the 7 sensors. You can create IFTTT recipes to monitor each of these variables and trigger a specific action when the value rises above or falls below a threshold of your choice. Use the tinker app to play around with sensor values to adjust your desired threshold. You can also create IFTTT recipes to listen for the button events and trigger your action when the buttons are pressed. If you are using a DHT11 temperature and humidity sensors instead of the DHT22 that I used, you will have change the 22 to an 11 in the code. You can also view your variable values at any time using Spark’s Rest API.
I will be improving the code over the next few weeks and updating is here.