Introduction: Gesture Controlled IoT Switch (with IFTTT)

We LOOOVE the internet-of-things. But always using a phone to turn a light on-and-off again is kind of a pain ain't it? We're going to fix that by building a gesture controlled light switch in this example! Don't have your phone in your pocket when you walk into your room? Just wave on your light switch and bam - light turns on.

We're going to use the following parts:

Hover + Particle Photon + LIFX + IFTTT = Gesture controlled light switch

The same combination can be used to control any IoT device that's supported on IFTTT -- use gestures to control your Nest Thermostat, August Lock and more. More ideas can be found here.

Step 1: Parts

What we need:

  • Particle Photon or Core: This dev-board is great for internet connected projects. Particle can be purchased here.
  • Hover: It's a gesture sensor that lets you detect touch-less gestures. It detects multiple gestures such as swipes and circular motion. It can also pinpoint your hand position in 3D space. In addition, Hover can also be used as a touch sensor with 5 distinct touch points. Hover can be purchased here.
  • Wires and a breadboard.

Step 2: Hookup Particle to Hover

On the backside of the Hover PCB, there is a female connector that can be used to connect to the your host microcontroller.

  • HOST_V+: Connect to either 5V or 3.3V depending on your microcontroller. For example, if using the Arduino UNO, this pin should be tied to 5V since it is a 5V microcontroller. The Particle Photon is a 3.3V microcontroller, so this pin should be tied to 3.3V instead.
  • 3.3V: Connect to the 3.3V pin on your host microcontroller
  • GND: Connect to ground pin.
  • TS: Connect to any Digital pin on your microcontroller.
  • RESET: Connect to any Digital pin on your microcontroller.
  • LED: Optional - can be used to connect to an LED + resistor to indicate a successful tap or gesture. Mainly used for debug purposes.
  • SCL: Connect to SCL pin on your microcontroller
  • SDA: Connect to SDA pin on your microcontroller.

Step 3: Setup the IFTTT Recipe

    In this step, we're going to setup an IFTTT Recipe that will enable us to connect the Particle cloud to the LIFX bulb. Refer to the screenshots above for each of the steps below.

    1. Sign in to IFTTT and click on Create. Then click the 'this' link.
    2. Type in Particle in the search box and select it.
    3. Next, select the 'New event published' button.
    4. In the next step, type in the text as shown. You can select a different Event Name and Event Contents but keep note of it because the event names used here must match our particle code later.
    5. Now click on the 'that' link.
    6. In the search box, type lifx and select it. Note that if this is your first time setting up the LIFX channel on IFTTT, you may be redirected to a popup to log in with your LIFX credentials. Once you've done that, it should redirect to the page shown below.
    7. Now select the actions that should happen when this event is triggered. We select 'Turn lights on' in this example to match our 'lifxup' event.
    8. Finally, select your preferences when this action is triggered and hit 'Create'. You just finished setting up one recipe! Now every time an event named 'lifxup' is published by Particle, this recipe will trigger and cause your LIFX bulb to turn on.

    You'll need to repeat the steps above to setup other recipes corresponding to different gestures like swiping down (to turn lights off) or swiping left and right (to change light colors).

    Step 4: Get the Code

    Download the library and navigate to the /examples/Hover_IFTTT_LIFX_Demo folder. Copy the library over as well to the Particle IDE and flash!

    Grab the library here.

    Step 5: Code

    A few notes on the code:

    To publish an event for each gesture, we use the Particle.publish() method shown below. Each gesture corresponds to a different call to Particle.publish() using the same event names we used to setup IFTTT above. The publish method enables us to generate different events based on different conditions - specific gestures in our case.

    if (g.gestureID == 1){
        switch (g.gestureValue){
            case 0x01:
              Particle.publish("lifxleft", "swipeleft");
              waveLeft();
              break;
            case 0x02:
              Particle.publish("lifxright", "swiperight");
              waveRight();
              break;
            case 0x03:
              Particle.publish("lifxup","swipeup");            
              waveDown();
              break;
            case 0x04:
              Particle.publish("lifxdown","swipedown");            
              waveUp();
              break;
            default:
              break;
        }
    }
    

    Once you flash the code, give it a whirl! Try swiping in different directions and your LIFX bulb should trigger.

    Step 6: Taking It Further.

    We've taken this basic setup further by 3D printing a case to house Hover and the Particle Photon as shown above. Hover can be covered up by any insulating material (like plastic, acrylic, etc) and gestures and taps will still be recognized! We left a small circular opening in the middle for design purposes but you can cover it up completely if you like.

    To take it even further, you could fit a NeoPixel ring on top of Hover as shown in the last image to get instant feedback when swiping. The code you grabbed from the github link above already incorporates NeoPixels. If you don't have a set of Neopixels lying around, feel free to comment it out or ignore it to test your code. In this example, we used the 24 count ring NeoPixel available from Adafruit.

    Comments

    author
    nicashwil made it! (author)2017-01-12

    holy geex this is sick

    About This Instructable

    2,900views

    58favorites

    License:

    Bio: We're Hover Labs! We build beautiful and interactive electronic tools for makers.
    More by Hover Labs:Feel the Force With HoverGesture Controlled IoT Switch (with IFTTT)LED Transit Clock - Never Miss the Bus Again!
    Add instructable to: