micro:bit Workshop Level 5

  • micro:bit Wi-Fi Extension
  • Applications with Cloud Platform ThingSpeak
  • Applications with Web-based Service Platform IFTTT

Introduction to Web-based Service Platform IFTTT

  • IFTTT stands for IF This Then That
  • "This" represents the event trigger
  • "That" represents the follow-up action
IFTTT Square 600px

Examples of IFTTT

Here follows two examples of IFTTT.

Example: Greeting Bot

If the time is currently 07:00 and today is a weekday, then post "Good morning" on Facebook.

Trigger

Weekday at 07:00.

Action

Post "Good morning" on Facebook.

Example: Temperature Alert

If the temperature goes below 15 ℃, then send a message (email etc.) to remind the user to bring his/her coat.

Trigger

Temperature < 15 ℃.

Action

Send reminder.

Prerequisite to using IFTTT on micro:bit

There are a few things to do before you can use IFTTT with your micro:bit.

IFTTT Square 600px

Register for IFTTT Account

Log-in your IFTTT account with your email.

microbit Workshop IFTTT Register
microbit Workshop MakeCode MuseLab Package

Add Package for micro:bit MakeCode

Search for "MuseLab" in MakeCode Add Package screen.

Extend Wi-Fi for micro:bit

Prepare the MuseLab WiFi IoT Robotic Shield Kit for accessing the web-based services on IFTTT.

Hands-on: Temperature Alert on IFTTT

In this section, you will learn the following.

  • Upload your sensor data through micro:bit
  • Send email to the user along with sensor data
IFTTT Square 600px

Setup for IFTTT - Webhooks Activation

Webhooks act as a event trigger in this hands-on project. More on this topic when you setup the applet.

  1. Head to Webhooks homepage.
  2. Press the "Connect" button.

Before

microbit Workshop IFTTT Webhooks Connect Before

After

microbit Workshop IFTTT Webhooks Connect After

Setup for IFTTT - Applets

An applet is the combination of a "Trigger" and an "Action."

Applet=Trigger+Action

Procedures in My Applets

Press the "My Applets" tab at the top. On the My Applets homepage, press the "New Applet" button.

My Applets Homepage

microbit Workshop My Applets Homepage

Procedures in New Applet Step 1

  1. Press the "+this" button.
  2. Focus on the "Search services" textbox.
  3. Enter "Webhooks" and select "Webhooks" service.

New Applet Step 1 Procedure 1

microbit Workshop My Applets New Applet Step 1 Procedure 1

New Applet Step 1 Procedure 2

microbit Workshop My Applets New Applet Step 1 Procedure 2

New Applet Step 1 Procedure 3

microbit Workshop My Applets New Applet Step 1 Procedure 3

Procedures in New Applet Step 2

  1. Select the "Receive a web request" option.
  2. Focus on the "Event Name" text box.
  3. Enter "temperature_alert_cold" as the event name.

New Applet Step 2 Procedure 1

microbit Workshop My Applets New Applet Step 2 Procedure 1

New Applet Step 2 Procedure 2

microbit Workshop My Applets New Applet Step 2 Procedure 2

New Applet Step 2 Procedure 3

microbit Workshop My Applets New Applet Step 2 Procedure 3

Procedures in New Applet Step 3

  1. Press the "+that" button.
  2. Select "Email" service.

New Applet Step 3 Procedure 1

microbit Workshop My Applets New Applet Step 3 Procedure 1

New Applet Step 3 Procedure 2

microbit Workshop My Applets New Applet Step 3 Procedure 2

Procedures in New Applet Step 4

Select the "Send me an email" opton.

New Applet Step 4

microbit Workshop My Applets New Applet Step 4

Procedures in New Applet Step 5

Press the "Create action" button.

New Applet Step 5

microbit Workshop My Applets New Applet Step 5 Procedure 2

Procedures in New Applet Step 6

  1. Modify your applet description.
  2. Press the "Finish" button.

New Applet Step 6 Procedure 1

microbit Workshop My Applets New Applet Step 6 Procedure 1

New Applet Step 6 Procedure 2

microbit Workshop My Applets New Applet Step 6 Procedure 2

Setup for IFTTT - Webhooks Functionality Test

In Webhooks service, everyone has a unique identification key. Let's retrieve the key and put it in our micro:bit.

Procedures in Webhooks

  1. Head to "Webhooks" homepage. Press the "Documentation" button.
  2. Focus on the "{event}" textbox.
  3. Enter "temperature_alert_cold" as the event name.
  4. Focus on the textbox after the "value1" JSON property.
  5. Enter "12" as the parameter.
  6. Press the "Test It" button. If the applet was setup correctly, you should receive an email.
  7. Copy the 43-character key for later use.

Webhooks Homepage

microbit Workshop IFTTT Webhooks Connect After

Webhooks Documentation Before

microbit Workshop IFTTT Webhooks Documentation Procedure 1

Webhooks Documentation After

microbit Workshop IFTTT Webhooks Documentation Procedure 2

Expected Result

A email should be sent to you with the temperature reading included in the body. The reading should be shown as the first value of "Extra Data."

microbit Workshop IFTTT Webhooks Test It

Setup for micro:bit - MakeCode

Let's create our micro:bit program.

Procedures in Webhooks

  1. Search "MuseLab" in the MakeCode "Add Package" screen.
  2. Add the MuseLab "wifi-shield" package.
  3. With the additional programming blocks in the "MuseIoT" tab, create the program as shown in the picture.
  4. Replace the IFTTT key with your Webhooks key accordingly, and enter the event name used in this project "temperature_alert_cold" with value1 set as the temperature.

Webhooks Documentation After

microbit Workshop IFTTT MakeCode

Contact Us and Stay Tuned for More Workshops

Stay tuned to this website for future events! Contact us if you are interested in the items we discussed in the previous workshops.