Language Switcher

Collaboration between obniz and Alexa (IFTTTT)

Make things

With obniz, you can easily light LEDs and move things from your smart speaker.
I tried to link it with Alexa, which is built into Amazon Echo and other devices.

 

There is a way to extend Alexa’s functionality by developing a Skill, but this time we’ll use IFTTT so that you can extend the functionality more easily than creating a Skill.
IFTTT is a web service that makes it easy to connect various web services and devices.

Talk to Alexa and blink the LED

Let’s make a system that makes the LED blink when you talk to Alexa. The summary is as follows.

  1. Say to Alexa, “Alexa, trigger blink the LED.” 
  2. The Webhook URL of the obniz Event is called through IFTTT.
  3. The program registered in the obniz Event is run and the LED blinks.

Materials

  • obniz Board
  • Alexa-powered smart speaker(eg. Amazon Echo)
  • power supply for obniz
  • LED
  • (In case of LED without resistor, resistor, breadboard and jumper are also prepared.)

How to make

Hardware connection

Connect LED (and resistor) to an obniz Board like the table and the image below by referring to LED Library. (It’s no need to connect resistor if you use LED with a resistor. If you’re unsure, please check the datasheet.)

Also, pay attention to the direction of the LED. The longer leg (anode) is closer to the 0 pin of obniz.

obniz LED
0 Anode (the longer one)
1 Cathode (the short one)

Software

If the obniz Event calls IFTTT Webhook URL, LED will blink.

Please refer to the “Program.”

In the following part of the program, the number 0 of the obniz Board is assigned to the anode side of the LED and the number 1 to the cathode side.

let led = obniz.wired("LED", {anode:0, cathode:1});

Also, the LED blinks depending on posted JSON contents on Webhook in the statement of if(typeof req === "object").... In this program, the LED will blink every 300 milliseconds and it’s continued for 3 seconds if the value of “led” key is “true” in JSON contents.

LED is registered in the JS parts library of obniz, so you can easily control them.
LED (JS parts library) | obniz

Setting up an obniz Event

Set up the obniz Event so that the IFTTT recipe can call Webhook URL and run the Program. Learn more about obniz Events here.

First, go to the official obniz website and enter the “Developer Console”.

Next, click on “Create New” from the repository in the left menu, paste and save the program of “Program.”

Next, click on New in the “Event” field to create an event. Please refer to the following for details of the settings.

Name (arbitrary)
Webapp to run Select the name of the program saved in the repository.
Trigger Webhook

 Click “Create”.

 

In the end, please note the URL in the “Endpoint” field. This URL will be used in the next chapter, “Make a recipe with IFTTT”.

Make a recipe with IFTTT

Make a recipe with IFTTT to call Webhook URL you’ve just created when you say to Alexa, “Alexa, trigger blink the LED.”

First, you need to access IFTTTT and log in. If you use IFTTTT for the first time, you will be asked to register as a member or log in through Google or Facebook.

If you can log in to IFTTT, click “create.” And click “This” part (we call it the trigger) of the “If This Then That.”

Type “alexa” in the search bar and select Alexa. Then, select “Say a specific phrase“.

 

(If you use Alexa as a trigger for the first time, you need to log in to Amazon account.)

Type “blink the led” in the field as the phrase you talk to Alexa (only lower case letters).

Next, click on the “That” part (we call it the action).

Type “webhook” in the search bar and select Webhooks. Then, select “Make a web request.

In this page, set “URL” to the URL you noted in the “Setting up an obniz Event” chapter, “Method” to POST, “Content Type” to application/json, and “body” to {“led”:true} and click “Create action.”

Program

How to use

Let’s say to Alexa, “Alexa, trigger blink the LED.” LED probably blinks for 3 seconds like the video below.

(It might delay up to 15 minutes).

Practical use

In the previous chapter, we blinked the LED, you can also apply this to many things.

Turn the switch on and off.

For example, if you change the LED part to a servomotor, you can turn on and off the lights and outlets just by talking to Alexa.

Even if it’s not a smart home appliance, you can easily (physically) turn a switch on or off just by talking to Alexa, so it’s convenient when you’re not free or want to operate a switch in another room.

I tried it with the ON/OFF switch of the outlet. (See video below).

As you can see, you can easily operate the physical switch just by talking to Alexa.

Turn Alexa’s timer like a party↑↑↑

Since IFTTT’s Alexa’s trigger has “Your Timer goes off”, I changed IFTTT’s trigger and program a little and made the timer party-like by making the ring LED light-up colorful when Alexa’s timer goes off!

in the end

Thus, you can easily connect the obniz Board and Alexa through IFTTT.

However, IFTTT does not have Alexa on the action side, so it is impossible to make Alexa talk depending on the sensor value from obniz.

Creating an Alexa Skill gives you more flexibility to extend your functionality. Please see this article.