Web services and IoT using Littlebits and IFTTT

Web services and IoT using Littlebits and IFTTT

Cybersecurity First Principles in this lesson

Introduction and goals

In this lesson, we will explore a cool hands-on technology called Littlebits. Littlebits follows a component-based design paradigm using GPIO (or general purpose input/output) to let you easily make apps. We will learn how to plug and play bits together to make some simple inventions. Littlebits will be the central platform for the rest of camp and you will be using them in other lessons.

Goals

By the end of this tutorial, you will be able to:

Materials Required

Prerequisite lessons

Intro to components using Littlebits Droids

Table of Contents

Before We Start

In the last lesson, you saw how versatile, modular, and cool Littlebits was to work with. It was easy to plug and play different modules together following simple design patterns to make cool, simple apps. Now, imagine everything you saw before can be hooked up to the internet and controlled using a smartphone or online app. We are going to do THAT now!

Step 1: Create an Account / Login to Littlebits portal!

To start we need to create an account:

Step 2: Pair your Cloudbit with the portal

Now that we have an account, we need to pair our cloudbit (an orange module with cloud written on it) with the Littlebits Cloud Platform. To do that:

tim

setup

setup

Step 3: Don’t Push Push the Red Purple Button

red button

The purple button on your screen is linked to your cloudbit output.

It works! With that, you just made your first IoT app.

You should see your gauge go up! Now you have input and outputs routed through the cloud controller!

Step 4: Using web services - connecting to IFTTT

Web services are, as the name implies, services that live on the web. You use these all the time - mostly without knowing it. The internet is built on top of them. Google, Dropbox, Youtube, Twitter, and Facebook are just a few juggernauts that provide and use many different web services. In this lesson, we are going to use a mashup service called IFTTT (which stands for If This, Then That ). IFTTT is a great platform that talks to all kinds of other web services. One service it connects with is, conveniently, Littlebits. This is an example of modularity because IFTTT can swap out components for others easily.

Step 5: Web Service Wizardry - Make an Easy Button

Lets create a new applet that sends an email when you press the button module. For flair, lets make it an easy button™ (Staples).

applet

applet

If (littlebits) then that

applet

Check your email!

email worked

It worked!

This is a simple, but powerful tool. It also shows off resource encapsulation and abstraction. In terms of resource encapsulation, each of the services connected to IFTTT have many functions. These functions are encapsulated in a service (e.g. email in this example). The functions are also abstract because IFTTT doesn’t need to know how they work, just that they achieve a certain purpose (e.g. send an email). This helps model or abstract the implementation away from the design.

Step 6: Email / SMS trigger

Lets make an applet that allows us to turn the cloudbit output on with an email or text.

You should see: trigger

Pretty cool, imagine - instead of turning on a light we can turn anything on.

Lets make a second applet to do the same thing, but via SMS.

trigger

Step 7: Twitter watcher

Lets make an app that lights up every time a new tweet on a certain topic happens. This requires a Twitter account. If you don’t have and don’t want to create a Twitter account, feel free to skip this, but it’s fun!

twitter

Step 8: Control your world

Lets go beyond simple triggers and make something that you might use in your home. First, we’re going to create a service-controlled light switch.

light config

Subject:

() It's dark at home: Want to turn the lights on?

Body:

Want to turn the lights on? Reply with  <a href="mailto:trigger@applet.ifttt.com?subject=#lightson&body=#lightson">`#lightson`</a>

Cover the light sensor up with your finger to turn it on (simulating it being dark).

light email

You should see the power outlet light turn on - and you should hear a short audio clip play.

light config

Self Exploration

Try some different designs yourself. You can combine any services with any Littlebits sensors. You could make an app that opens the curtains when you text it #opencurtains. You could make an app that listens for sounds and sends you an alert if sounds are detected. You could make an email or tweet counter. The possibilities are real and endless!

Test you Bits, err… Wits!

Quiz

Cybersecurity First Principle Reflections

In this lesson, we saw web services, such as IFTTT, can abstract away details about devices and instead focus on recipes or design patterns to describe how things work. We also saw that by keeping functionality modular, IFTTT can combine Littlebits with many other services.

Web services use resource encapsulation to ensure that all functions related to the execution of an app or service are neatly within the scope of the service itself. IFTTT relies on services to be encapsulated so that they can provide external services with the ability to use them without worrying about connecting to multiple other related services.

Data hiding is also important to prevent internal data in the service from being released outside of the service invocation. Local data remains hidden, while interfaces expose only what the service wants to release (for instance to IFTTT). This also relates to minimization because services can turn ports and other access off except for the specific interfaces it wants to leave open for other services to use.

Additional Resources

For more information, investigate the following.

Lead Author

Acknowledgements

Special thanks to Dr. Robin Gandhi for reviewing and editing this lesson.

License

Nebraska GenCyber Creative Commons License
is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Overall content: Copyright (C) 2017-2018 Dr. Matthew L. Hale, Dr. Robin Gandhi, Dr. Briana B. Morrison, and Doug Rausch.

Lesson content: Copyright (C) Dr. Matthew L. Hale 2017-2018.
Creative Commons License
This lesson is licensed by the author under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.