How to use IFTTT with micro:bit

What is IFTTT?

IFTTT is a very useful “glue” services that helps us to connect to different Internet services. For example, we can glue the Facebook service to our mobile phone’s camera application so that whenever there is a new photo taken, the photo would be uploaded to Facebook automatically, creating a new post. The name IFTTT in fact is the abbreviation of If This Then Thatwhich is one of the most common logics used in every programming language. The IFTTT back-end connects different services and devices by using their own API (application programming interface), offering a very intuitive and straight forward trigger and action logic.

What is IFTTT?

IFTTT is a very useful “glue” services that helps us to connect to different Internet services. For example, we can glue the Facebook service to our mobile phone’s camera application so that whenever there is a new photo taken, the photo would be uploaded to Facebook automatically, creating a new post. The name IFTTT in fact is the abbreviation of If This Then Thatwhich is one of the most common logics used in every programming language. The IFTTT back-end connects different services and devices by using their own API (application programming interface), offering a very intuitive and straight forward trigger and action logic.

Due to IFTTT’s easy-to-use web service, it has gained huge popularity and is often considered a must-learn feature as the first entry point into the world of IoT. It is equal to the “Hello world” of programming for IoT beginners.

The MuseLab micro:bit Booster works directly with the IFTTT services. MuseLab has developed some very simple to use blocks within the mirco:bit PXT “make code” web page (https://makecode.microbit.org/). Below are the basic steps on how to connect your micro:bit to IFTTT using the MuseLab micro:bit Booster.

Step 1. First you have to set up your network connection on the MuseLab micro:bit Booster. If you have already done so, please continue with “Step 2”, otherwise click below link and follow the instructions.

How to connect micro:bit to the internet

Step 2. Then you have to create an IFTTT account, if you haven’t done it yet.

Go to IFTTT at http://www.ifttt.com and signup.

Step 3. After signing in, Click “New Applet” at the right upper corner.

Step 4. To create a new applet, there are 2 things we need to set, which are “This” and “That” for IFTTT (If This Then That). Click on “This”

Step 5. For the service on “This”, we search and select “Webhooks”. “Webhooks” is an event and we need to set an event name to it . Let’s set the Webhooks event name to be “fire_accident” and click ”Create trigger”.

Step 6. After that, we set the “That”. We click “That”

Step 7. Now we will choose Gmail as an performing service when the “fire_accident” is triggered. From the next selection, action of choice is “send yourself an email“.

Quick review:

Let’s have a look what we did: If the fire_event happened, then trigger Gmail.

Of course, you can set different event and use different cloud services as you like!

Step 8. Now we need to get the API Key for our IFTTT account. Go to the upper menu and click “Search”, search for “Webhooks” and select it.

Step 9. You can see “Documentation” on upper right corner, click it!

Step 10. Now copy your personal API Key. Keep it confidential!

Step 11. Go back to the micro:bit block editor page. Get the “on button A pressed”-listener, find the Send IFTTT block from MuseIoT. Paste the key you have just copied from step 10. And type the event name you have just created in your IFTTT.

Make sure everything matches correctly!

* Be aware that no spaces (at the beginning and the end) of your copied IFTTT API Key.

** Be aware that the event_name is case-sensitive (capital letter or small letter must be the same). You can go to “My applets” to see if you not sure.

The full initialize script would be as follow:
After the shield has been connected to the Internet:
Press the button A on the micro:bit, you will get the below message on the screen:
Go to the email box and check email, you got the email!

Please enjoy discovering the amazing possibilities of IFTTT to create your own fantastic IoT projects!