Web services and IoT using Littlebits and IFTTT (w/ droids)

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
Computational Thinking and Design Process 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 simple designs and inventions. 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

Note if you are trying to pair multiple cloudbits for the first time it can be difficult to make sure you are pairing to the right one, we will do them in sequence in the camp. Don’t worry though - once paired you shouldn’t need to pair them again unless you change the network.

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: connecting to the droid.

Unplug all of the modules on the CloudBit

wait for your cloudbit to reconnect (it will turn solid green)

scratch input

Step 5: 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 6: Web Service Wizardry - Make an R2 Button

Lets create a new applet that sends an email when you press the button module. For flair, lets assume R2 is talking to us.

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 7: Email trigger

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

You should see: trigger Before we test it, make sure your scratch program is still running

Step 8: 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

Self Exploration

Try some different designs yourself. You can combine any services with any Littlebits sensors.

You could swap the sound maker output for move forward.

You could write a scratch app that listens for different voltage levels on the inputs and then uses if conditions to switch between them. Then you could send those different signal levels from either the littlebits cloud or from IFTTT.

E.g.

twitter

Test you Bits, err… Wits!

TBA

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.