Posts

IFTTT, LIFX and thethings.iO

One of the most popular services that helped the Internet of Things to reach a great critical mass is IFTTT. IFTTT means if this then that. IFTTT is a fantastic IoT platform that allow people build recipes, triggers or actions with several connected devices and services.

ifttt thethings.iO

thethings.iO + IFTTT

Actually at thethings.iO we love IFTTT. And this is the main reason why we decided to connect thethings.iO with IFTTT and enable our customers and their connected things the possibility to interconnect any device that they have at thethings.iO with any service or device connected through IFTTT. Let me give you an example, imagine that you have a LIFX lightbulb and your own Arduino device. Now through thethings.iO and IFTTT it is possible to make them speak with just 3 minutes of efforts! Keep reading!

At this post we are going to show you two different examples that we built with the IFTTT Maker channel. The first example is using a thing connected to thethings.iO as the IF THIS part of the IFTTT. The second example enables a device connected to thethings.iO that is the thing connected as THAT part.

THIS

This example uses a Particle Photon with a button and a LiFX bulb. Each time the button is pushed, a message is published via HTTP to thethings.iO. This message activates a trigger in real-time, that sends an HTTP POST to IFTTT (activating the IF THIS statement).

Once the IF THIS statement is achieved, IFTTT activates a LIFX bulb from our LIFX account.

This are the steps to follow in order to do the example:

  1. Create a LIFX account and associate your light bulb your your account.
  2. Register at thethings.iO IoT platform.
  3. Create a product with your thethings.iO account.
  4. Register at particle with and flash your photon particle with the button code provided on our Particle photon github repository.
  5. Register at IFTTT and connect to the Maker channel. At https://ifttt.com/maker inside “How to trigger events”, you’ll find the associated url to send HTTP requests later. Modify the path inside the Cloud Code trigger your credentials.
  6. Create the IFTTT trigger:
    1. Select “this” and search the Maker channel. Then click on it.thethings-this-makers
    2. Click on Receive a web request.
    3. Give a name four your event.
    4. Select “that” and search for LiFX. Then click on it.thethings-that-lifx
    5. Your LIFX account credentials will be asked.
    6. Select the event that will happen on the LIFX bulb (in our case Change Color. Randomised).
  7. Go back to thethings.iO and navigate to Cloud Code.
  8. Create a trigger associated with the previous created product.
  9. Copy the following code to the trigger (remember to change your_event and your_key with your actual ones):

function trigger(params, callback){
  if (params.action !== 'write') return callback();
  
  var body = {	//Add the values that you want
    button: '1'
  };
  
   httpRequest({
    host: 'maker.ifttt.com',
    path: '/trigger/your_event/with/key/your_key', // Remember to change your_event and your_key!
    method: 'POST',
    headers:{
      Accept: '*/*',
      Connection: 'close',
      'Content-Type':'application/json'
    }

  }, body, function(err, result) {
    //and postprocess the api result here before sending to your thing
    console.log('Returned from httpRequest');

    if (err) {
      console.log('httpRequest error');
      console.error(err);
      return callback(err);
    }
    if (result) {
      console.log('httpRequest success');
      console.log(result);
    }
    callback(null, result);
  });
}

After this simple steps, this IF example is completed! Now you can play with it!

THAT

This example uses an Arduino Yun with the IKEA discoball connected with a motor (using a relay). The Yun is connected via MQTT to thethings.iO. Using IFTTT, the disco ball from the Yun spins for 2 seconds each time a new task is created in a certain list in Trello.

In order tu make the example, these are the required steps:

  1. Create a LIFX account and associate your light bulb your your account.
  2. Register at thethings.iO IoT platform.
  3. Create a product with your thethings.iO account.
  4. Create a new arduino sketch and paste this code:

#include <YunClient.h>;
#include <Bridge.h>;
#include <PubSubClient.h>;
#include <Process.h>;

#define TOKEN "youThingToken"    // Change yourThingToken with your actual thingToken

YunClient wificlient;

String topic = "v2/things/" + String(TOKEN);
String message = "";
boolean firstValue = true;

void addValue(String key, int value) {
  if (firstValue == true) {
    firstValue = false;
    message.concat("{\"key\":\"" + key + "\",\"value\":" + value+"}");
  }
  else {
    message.concat(",{\"key\":\"" + key + "\",\"value\":" + value+"}");
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
    // handle message arrived
    String text = "";
    for (int i = 0; i < length; i++) text.concat((char)payload[i]); 
    text.replace(" ", ""); //Serial.println(text);  
    if (text.indexOf("\"key\":\"party\"") >= 0) {
        if (text.indexOf("\"value\":\"1\"") >= 0) {
          digitalWrite(7, HIGH);
          delay(2000);
          digitalWrite(7,LOW);
        }
    }
    
}

PubSubClient mqtt("mqtt.thethings.io", 1883, callback, wificlient);

void publish() {
  String toSend = "{\"values\":[" + message + "]}";
  mqtt.publish((char*)topic.c_str(), (char*)toSend.c_str());
  message= "";
  firstValue = true;
  Serial.println("Published");
}

void setup() {
  Bridge.begin();
  //Serial.begin(9600); 
  //while(!Serial);
  pinMode(7, OUTPUT);
  while (!mqtt.connect("Yunclient")) {
    //Serial.println("Could not subscribe, retrying...");
  }
  //Serial.println("Client connected to mqtt broker!");
  mqtt.subscribe((char*)topic.c_str());
}

void loop() {
  mqtt.loop();
}

4. Register at IFTTT and connect to the Maker channel.

5.Create the IFTTT trigger:

  1. Select “this” and search for trello. Click on it.thethings-this-trello
  2. Choose your preferred action (Card added to board, list or assigned to you).thethings-trello-choose
  3. Your Trello account credentials will be asked.
  4. Insert the fields for the chosen action.
  5. Click on “that” and search for Maker. Click on it.thethings-that-maker
  6. Press Make web request.
  7. Insert on the URL field.
  8. Select POST method.
  9. Select aplication/json for the content type.
  10. Insert the following JSON in the body: {“values”: [{ “key”: “party”, “value”: “1” }]}
  11. Click on create action.

thethings-that-maker-details

It’s fun right? We love that people apply innovation on the top of thethings.iO! this is the reason why thethings.iO IoT platform is connected to Twilio, Twitter, and IFTTT, among other. Let us know what you build and we will publish it at the blog.

Connect a thermostat with OpenMote and thethings.iO

thethings.iO + openmote

thethings.iO + openmote

During the last months we have seen dozens of amazing projects being connected at thethings.iO. Here we are going to show you how to connect a heating system and a thermostat for your house using thethings.iO as the IoT platform and OpenMote as a hardware.

connect-a-heating-system
This project was made by Roberto Romero Jotel as his final Master’s project for the Universitat Oberta de Catalunya this past 2015, so we are going to make a quick review to his one.

OpenMote and OpenWSN

During the project, the maker Roberto connected a heating system with a thermostat using the OpenMote with OpenWSN (IEEE 802.15.4e) and thethings.iO. On the project there is also a Raspberry Pi with Internet and the OpenBase and OpenMote-CC2538 modules connected by USB at the Raspberry Pi. The Raspberry Pi was converting the messages from the OpenWSN(802.15.4e) to Ethernet (HTTPS) to send the data to thethings.iO

The OpenMote platform consists on:

  • OpenMote-CC2538: which uses SoC TI format for Cortex-M3 and CC2520. This SoC can support Contiki, OpenWSN (which is also the protocol we are going to explain later in this post) and FreeRTOS.
  • OpenBase: a plate with different ports such as Ethernet, USB and JTAG.
  • OpenBattery: also a plate with 3 digital sensors and batteries. Its operation is autonomous.
Reliable Low Power Wireless OpenMote

Reliable Low Power Wireless OpenMote

The OpenWSN is a collection of different Internet of Things protocols. It counts on the OpenOs, which is a collaborative of OpenWSN, an OpenVisualizer, the visualization program and a Python CoAP library.

The IoT platform

thethings.iO is the IoT platform of the project. It also provides write and read methods. In the first case (ThingWrite), it allows users to collect data in JSON format with POST request at the URL through the CoAP API:

coap://coap.thethings.iO/v2/things/{{THING_TOKEN}}

In the case of the ThingRead, it allows the user to read the data from a resource (KEY) with GET request at the URL:

coap://coap.thethings.iO/v2/things/{{THING_TOKEN}}/resources/{{KEY}}

thethings-io-dashboard

How to make things work together

The real question in here is how to connect the OpenMote with thethings.iO?

Project's architecture

Project’s architecture

The key is the integration of thethings.iO API on the OpenMote implementation with the Raspberry Pi. Let’s explain the two basic functions of thethings.iO that enables the thermostat to read data and write sensor’s data from and to thethings.iO.

First of all, the thermostat wants to send new data from its sensors (temperature, humidity, etc). How do we do it? Remember that we have to consider that the OpenMote is connected to a Raspberry Pi through a TCP socket. That means that thethings.iO as the IoT platform receives the data through CoAP from the Raspberry Pi thread that listens the TCP socket from the OpenMote.

Once they are connected one to each other, the client sends the Raspberry Pi process the data. All this data collected is sent by the Raspberry Pi to thethings.iO IoT platform using a CoAP POST request. thethings.iO gives an answer which can be “Success” or “Error”. Finally, when the OpenMote receives the answer, the connection ends.

The reading operation from thethings.iO is similar, the OpenMote tries to establish a socket connection with the Raspberry Pi, and the Raspberry Pi sends a request of polling to thethings.iO. Once they are connected to eachother, the client sends a request to read its data to the server. All the data is requested to thethings.iO by the server using a CoAP GET request. Then, thethings.iO sends the answer to the Raspberry Pi, giving a “Success” with the JSON, which is translated in sending all the data requested, or an “Error”.

If you want to know more about Roberto Romero’s project (in catalan) and the public code on Roberto’s github account.

And if you want to start connecting things with thethings.iO you can register here.

4 Steps to Build Your IoT Dashboard

As you know, thethings.iO is the Internet of Things platform that allows you to connect things to the Internet quickly and easily. We allow you to monitor and manage your networked devices in real-time and get flexible analytics reports. And the product goes further, as you will see in this post about the IoT Dashboard that we deployed some weeks ago.

thethingsio-dashboard
This is a quick tutorial of how to build your IoT dashboard and also how to customize it in order to make it more “yours”.

Step 0: Sign Up or Log In at thethings.iO

The first thing you need to do is, in case you have not registered yet, create a new account and Sign Up to our platform. Otherwise, if you already have an account, you just need to Log In to move to your IoT Dashboard.

Primarily you’ll notice that when you first access to your IoT Dashboard, a new window appears to introduce yourself to the platform and specifically, to the IoT Dashboard. The message is the following one:

hello-dashboard
>

Step 1: Starting with thethings.iO IoT Dashboard

The IoT Dashboard is the place at thethings.iO where all the data generated by your things will be displayed. Depending on which kind of information you want to see you may prefer one widget or another. Before start building your IoT Dashboard you should have at least one thing connected using our platform. If you want to start connecting things fast, you should not miss this quick guide of how to connect your first thing in 1 minute! Why? Because you need data to display!

Once you have done that, we can move to the option “Edit Dashboard”, on the lower right section of your screen. The icon is yellow and this tool is the one we are going to use most during this post, so keep an eye on it!

Step 2: Create a Widget

Above the yellow “Edit Dashboard” there is a a blue “Add Widget” icon. So now we are going to click on it and a pop-up you will have to work with will appear. Your screen should look like this:

add-widget

The only thing you need to do now is to complete the fields that appear in this pop-up, such as we have done in the following example:

add-widget-2

At this point, you can choose the kind of widget you want your data to be displayed on your IoT Dashboard. You have different options, such as:

  • Map
  • Doughnut
  • Lines
  • Bars
  • Logs
  • Value
  • Pie
  • Polar Area

Depending on the option you choose in “Values Range” you’ll find one or the other.

Screen Shot 2017-01-25 at 3.30.56 PM

 

Finally, you can add your new widget to your IoT Dashboard.

Step 3: Customize your IoT Dashboard

One of the coolest things you can do with your IoT Dashboard is to add, remove and replace your widgets easily. To do it you just need to click on “Edit Dashboard” again and just touch one of the widgets. Now you can change its place just moving it, change its size, and also the kind of widget you want it to be!

Look the changes we have done in our example screen:

drag-drop-widgets

 

Once you finish editing your IoT Dashboard do not forget to save it!

Step 4: Create an Image

You may think that’s all we can offer, but right now we do offer more! Now you can add images to your IoT Dashboard. How?

  1. Go to Edit Dashboard button and Add Widget.
  2. Once you are in the pop-up window, in the “Data Source” field you have to choose the option “External Image”. Here you will be able to add images from your computer or directly from an URL.

widget.extrenalimage

3. Add your Widget to your IoT Dashboard.

Step By Step Video Tutorial

You can also check these 2 tutorials in which we explain how to build and customize your IoT dashboard. In this case we use a Thermostat we’ve recently connected to thethings.iO to show you how it works.

And that’s it. Isn’t it easy? Start connecting things now with thethings.iO and get cool customizable IoT Dashboards as the one we have shown you here.
And do not forget to follow us on Twitter in order to keep you posted about the IoT World and the latest news of thethings.iO.

Beginners Guide: Connecting An Arduino To thethings.iO

Arduino loves thethings.iO

Arduino loves thethings.iO

In today’s post we are going to show you Step by Step how to connect an Arduino to our platform, thethings.iO. You will only need:

  • An Arduino or Genuino board.
  • Ethernet, Wi-Fi (or Yún or an ESP8266, for the cheaper version) or GSM shield.

Now, make sure you have an account at thethings.iO. If not, register quickly by clicking here.

Once you have done this, you can start with this Step by Step.

Step 1: Preparing the environment

First you need the Arduino software installed. Afterthat, download the thethings.iO Arduino library in our github. Extract the thethingsiO from the .zip file and install it by copying the folder to your Arduino library folder.

The default path for the libraries is:

  • Linux: /Home/your-username/Documents/arduino/libraries
  • Mac: /Users/your-username/Documents/Arduino/libraries
  • Windows: \My Documents\Arduino\libraries

Now you can use the classes and functions described in the reference part of the repository.

Step 2: Sending Values

Now you need to open the Arduino software. Navigate to Examples > thethingsiO. Choose a protocol (if you are a beginner we recommend you to choose http) and then choose your shield (Ethernet, Wifi or GSM). Next, choose Send Values. An already “done” code will appear.
Now we need to make sure that we correctly initialize our Shield. For every shield there’s a method that does the previous action.

For the Ethernet shield, we need to provide the mac address of the shield (located below the shield):


void startEthernet() {
Serial.println("Connecting Arduino to network...");

// Local Network Settings

byte mac[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; // Must be unique on local network

// Connect to network amd obtain an IP address using DHCP

while (Ethernet.begin(mac) == 0) {
Serial.println(“DHCP Failed, retrying”);
}

Serial.println(“Arduino connected to network using DHCP”);
}

For the GSM shield, we need to provide the PIN number and the apn settings for your SIM card:


// PIN Number

#define PINNUMBER “”

// APN data

#define GPRS_APN “”
#define GPRS_LOGIN “”
#define GPRS_PASSWORD “”

For the Wifi Shield, you need to provide the SSID and the password:


#define SSID YOURSSID
#define PASS YOURPASSWORD

//In case that you already activated the token with an activation code and we have the token, use the next code:

thethingsiOEthernet ethernet_thing(TOKEN);
thethingsiOWiFi wifi_thing(TOKEN);

// Choose the one depending of your shield.

thethingsiOGSM gsm_thing(TOKEN);

// If you have the activation code but not the token, add the following code:
thethingsiOEthernet ethernet_thing();
thethingsiOWiFi wifi_thing();

// Choose the one depending of your shield

thethingsiOGSM gsm_thing();
string token = activate(“Your activation code”);

// Insert this and the next line inside the setup method, after the start function of the shield

if (token > “0”) setToken(token); // If the activation code is correct, a token is provided

Now that you have your thing created, it’s time to send values.

void loop() {
thing.addValue("Power", random(1,5)); // Adding a value from a number between  1 and 5 with the identifier "Power"
thing.addValue("Temperature", random(0,40)); // Adding a value from a number between 0 and 40 with the identifier "Temperature"
thing.send(); // For sending the previous values to your dashboard }

Step 3: Arduino Monitoring with thethings.iO

Now it is time to monitor the data. Go to Things Manager and select the thing where you are sending the data, that’s the Thing Details.

Thing details with arduino data

Thing details with arduino data

Step 4: Arduino real-time dashboard

Let’s create a cool dashboard which you will be able to monitor this data in real-time.
First, we go to the thethings.iO dashboard. Here, you have to Add a Widget. You do this by pressing the blue circle in the lower right corner.

Add A Widget

Now, choose the kind of Data Source you want to see on your Dashboard.

Add a Widget_2

And select the Resource.

Add a Widget_3

After that, you have to select the Widget Type you’ll want it to appear on your dashboard. In our case we are choosing ‘Lines’ for ‘Temperature’, and ‘Pie’ for ‘Power’.
Add a Widget_Temperature
Add a Widget_Power

And this is an example of what your dashboard would look like if you added a bar graph and logs as well…

thethingio.dash

 

Start with thethings.iO

And that’s it! Easy, right? Now you have your Arduino connected with thethings.iO. Start connecting things now!

Quick Guide: Connect Your First Thing in 1 Minute

This is a quick guide to connect your first thing using our platform, thethings.iO. thethings.iO is the Internet of Things platform that enables fast and scalable connection of things to the Internet, allowing you to monitor and manage your devices in real time and get flexible analytic reports.

As you will see, it is easy, and you can do it in less than a minute. You just need to follow a few steps we’re going to quickly explain to you in this post. Ready? Let’s start now, then!

Step 0: Signing In at thethings.iO

If you haven’t registered yet, you need to do it. Go to thethings.iO page, and sign in. Remember that you can connect one thing for free, so it is worth it. Once you have done that, you’ll be signed in to your panel.

Sign in

welcome-thethingsio

Step 1: Planning the thing

Before starting with the code, you should have an idea of what you want to connect to the Internet. What kind of data do you want to store and visualize? Is it going to be temperature? Or better humidity? Or other features like strength, noise, light…?

Step 2: Activating your first thing

When you have planned that and you are in your panel, it is time to start with the code. Let’s activate your first thing at thethings.iO! To do that you will need an activation code. You will be redirect to the Things Manager screen, where you will find directly the Activation Code screen.

As you may know, activation codes are needed to activate things. When you activate the thing, you will get something called ‘thingToken’. This Token can be compared to a personal ID but for things. The Token will enable you to make API calls to thethings.iO from your thing.

To activate the code, you just need to click on the Activate More Things. After that, the next window will prompt you to Activate. Click on Activate to activate one of the Activation Codes.

activation-code-thethingsio

activation-code-thethingsio

With all of this done, you will be able to see the thing and the thingToken. You can copy your thingToken, because from now on, all the requests will be done using it. Or you can as easily press Accept and your thing will be activated.

thingtoken-thethingsio

 

Step 3: Coding your thing

Let’s start with the coding. Right now, your thing is capable of performing 3 types of actions: read, write or subscribe. You need to open the Developers Console to see the messages you will post to thethings.iO APIs.

Now let’s see the actions:

  • Write: store one or several key-values pairs.
    To store data, you have to use the next endpoint.
    Advice: only alphanumeric characters and “.”, “-”, “_” symbols are admitted for the resource named “key”.
  • Read: your thing reads the last values for a determined key.
    To read data, use the operation GET/things/ with the thing token and the key that you are using to store the values.
  • Subscribe: subscribes to the real-time streaming channel of your things.
    This last method lets you subscribe to the thing channel and get real-time updates from all the thing’s keys. This way, it is created a streaming channel. If you want to know more about the Keep Alive options, click here.

dev-console-thethingsio

Step 4: Visualizing the data

Right now, you should have your first thing connected. You can see the numeric data you store from thethings.iO Panel. You only need to click at the Things Manager menu and then click on the thing you want to visualize. Check past data on historical tab, or the real-time as the data arrives on the real-time tab.

analytics-thethigsio

 

Step 5: Build your own dashboard

thethings.iO IoT Dashboard is fully customizable with widgets that can show historical or real-time data directly from the dashboard and not going to every thing.

And that’s it! With thethings.iO it’s easy, right?

If you want to learn more about thethings.iO features then you can not miss these posts about Twilio and Sigfox! And make sure you follow us on Twitter to keep you posted about the Internet of Things world and thethings.iO latest news!

Quick Guide to Cloud Code

As you know, Internet of Things is the next big thing. Considered the fourth biggest revolution (as important as the industrial and the Internet ones), all the machines connected to the Internet are saving huge amounts of data. But data on its own form does not matter. What is really important is the information we can get from it and services that you can build on top of the information. Here is where thethings.iO can help you make IoT simple!

Cloud Code

Welcome to the new Cloud Code feature. The business logic could not be in your things or Apps but in the Cloud. thethings.iO Cloud Code feature transforms the data from your connected things into information that will be useful to your daily activities.

Nowadays, the Cloud Code is a Javascript runtime programmable tool that enables you to program business logics, artificial intelligence algorithms or others on the top of the data stored. We can find 3 different categories: triggers, jobs and functions. Let’s talk a little bit more about each one. In the future we are going to integrate other languages such as Python, GO or others. What languages would you like to have?

Triggers

Firstly, we find Triggers. A trigger is a piece of code that is executed automatically on our Cloud, after a write command is received. That means that every time a temperature sensor sends the temperature, a trigger is launched in order to convert that data into celsius degrees or launch an alarm if the temperature goes below zero.

A typical use of a trigger is to create an alert. You can code the trigger in a way that when an alert condition happens, you can send an email, send an SMS and make a call with Twilio or tweet a message. And of course, store an event to build reports later. The execution of a trigger is limited to 2 seconds.

Following the previous example, if you have a temperature sensor you can build a Javascript code with the logics of the trigger to alert you when the temperature is higher than X value. When it happens, a message is sent (SMS, e-mail or tweet) to your smartphone or tablet to notify you about the condition. Additionally, if you store an event, later via Jobs, you can generate a report that shows how many times in one day this event get triggered.

Jobs

The Jobs is Javascript code that can be executed once every hour or once a day. The Jobs allow you to set up long running tasks. The execution of a job is limited to 10 minutes. Jobs lets you create map-reduce functions, reports and analytics aggregating the data from the events that your triggers or functions generate.

Current examples of the Jobs are related with mathematical functions or artificial intelligence and predictive maintenance scenarios. For example, a job synchronized with a trigger can help you to predict malfunctions every hour. Another example is a Job that analyzes how your customers use their devices and sends a daily report to the marketing people of your company.

Functions

Finally, we have Functions. Functions are algorithms that could be executed when they are needed. Functions can be called by triggers or jobs and even from outside thethings.iO via an API REST endpoint. Jobs encapsulate business logic that you don’t want to couple into a trigger or a job and of course not into the devices or mobile apps. The execution of a Function is limited to 20 seconds.

If you are using Sigfox, the functions are the place where you need to code the Sigfox payload parser in order to visualize the Sigfox data at thethings.iO.

All Cloud Code plugins

These are thethings.iO Cloud Code plugins:

  • emailing: it sends emails.
  • httpRequest: it sends an http request.
  • console: logs in your code.
  • analytics.events: allows to create and retrieve events.
  • analytics.kpis: to create metrics to be displayed on your dashboard.
  • thethingsAPI: allows to read and write on a device resource.
  • DataSet: represents the data returned from analytics.events.getByName.
  • Twilio: it sends SMS or phone calls. In case you missed it, read the post about Twilio here.
  • Geolib: Integrates Geolib library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc.
  • Twitter.

You can find more information on thethings.iO documentation site.

Know how our Cloud Code works

Do you want to see how it works? Discover how easy it is to use thethings.iO’s Cloud Code! We have created a thing which measures temperature. The next screenshot shows how our Dashboard looks like, with the ‘Thermostat Alerts’ graphic.

In this second screenshot, we see the Job code. In this case, the job get all the Alarm events of the day and store a KPI with the total events. This KPI is consumed by the dashboard widget ‘Thermostat Alerts’ to generate the graphic.

And finally, we see the screenshot of the Trigger code. In this case, we wanted to be notified with an alarm in case the sensor gets a temperature of 50ºC or above. We also store the event ‘Alarm’, which is later consumed by the previous Job.

If you want to learn more about thethings.iO features then you can not miss these posts about Twilio and Sigfox! And make sure you follow us on Twitter to keep you posted about the Internet of Things world and thethings.iO latest news!

Keep IoT Simple, Stupid!

Innovation brings enthusiasm when you are making a product. Launching a connected device is hard and expensive. 2015 has been amazing at thethings.iO; we worked together with great projects and awesome people. The most valuable thing we discovered is that things must be more simple, from the UX to the most technological part of the projects.

Inspired by the KISS principle (“Keep It Simple, Stupid”), thethings.iO would like to advocate towards the “Keep IoT Simple, Stupid”!

Keep IoT Simple, Stupid!

Keep IoT Simple, Stupid!

The “Keep It Simple, Stupid” principle states that the most basic rule in every design is to make it simple rather than complex. That means that simplicity should be more important in design and unnecessary complexity should be avoided. The Internet of Things is a complex scenario and simplicity is much needed, so unnecessary complexity shouldn’t be made.

At thethings.iO we have grasped this concept in the essence of our system. Among the connected product and the mobile application, there are hundreds of things to worry about: electronics, mechanicals, manufacturing, packaging, logistics, data security, cloud storage, mobile applications, interoperability with other things, among dozens more.

Simply put the “Keep IoT Simple, Stupid” principle in your project. We suggest that companies focus on what they do best. Some companies are very good at design, other very good with electronics and others with algorithms. How can they bring a connected device into the market faster? The answer is by looking for partners who can make the process less complex. The best projects we worked on 2015 were projects where the consortium of companies that joined the founder team was fantastic. Don’t waste your time and money reinventing the wheel! It’s 2016!

Everyday it becomes easier and easier to connect things to the Internet. This is the main reason why the number of companies building new connected devices in China, Europe, United States or Latam has been on the rise. So, “Keep IoT Simple, Stupid”!

What is thethings.iO’s main role here?

thethings.iO - the IoT platform

thethings.iO – the IoT platform

Under this concept of keeping things simple, thethings.iO wants to offer a solution to all IoT companies, helping them into the connection, storage, monitoring and data analysis of their cool new devices. Outsourcing cloud service results in a faster implementation and reduced time to market for the new launches on the IoT landscape. Our advice is to consider taking the “simple, stupid” way to connect your product to IoT: it will be a smart choice.

Hardware companies should focus on building things. At the same time, thethings.iO makes the connectivity programation from the prototyping phase until the certification and massive production. thethings.iO offers:

  • IoT Back-End solution to store data that can be accessible in real-time.
  • Customizable front-end user interface with your brand and under your URL.
  • Real-time data analysis with AI and data mining algorithms.
  • Security, Scalability and Data Privacy.
  • Interoperability with the majority of the IoT available.

Yes, it is better when you Keep IoT simple have you not seen it yet?

,

SMS & Voice Calls from Twilio meet thethings.iO

Internet of Things is about monitoring, alarms, notifications, among other, then it’s important to get real-time updates and the best way to get informed it’s probably through phone calls and SMSs. The IoT platform thethings.iO integrated Twilio, the communication platform that leads the voice and messaging applications.

Twilio with thethings.iO

Twilio with thethings.iO

Send SMS and make voice calls from your things with thethings.iO and Twilio

thethings.iO offers notifications (SMS and Voice calls) for your things through cloud code. This feature allows you to receive voice calls, SMS (with Twilio), emails, and tweets (with Twitter), whenever you trigger these messages from your networked products.

Recently, we have integrated Twilio on our Cloud Code feature. This allows our customers to easily program business logics on the top of connected devices and send SMS messages or make a scripted voice calls when needed. In this post I’m going to go through how to integrate Twilio on your IoT solution with a simple example.

Set up Twilio at thethings.iO

To start working with Twilio on thethings.iO IoT platform, you need an account on Twilio, because you need to introduce your Twilio credentials at thethings.iO. Don’t worry if you don’t have an account on Twilio, it’s free to create one and you get a phone number to start playing.

After that, you need a thethings.iO account to start sending data from your devices to our IoT platform. It’s very simple! Register here at thethings.iO follow the configuration step by step. And when you are ready, find some examples from some of the most famous IoT hardware platforms here, such as Arduino, ESP8266, Atmel, Electric Imp and other on our github account. An account on thethings.iO is free and simple to use. You can follow our getting started document and be ready in 1 minute.

Now that your thethings.iO and Twilio accounts are created and configured, you are ready to try the Cloud Code example that sends SMS when the temperature is too high.

Receive an SMS when the temperature of your device is too high

First, go to the Cloud Code feature clicking on the ‘Cloud code’ link at the left sidebar.

Cloud code main view

Create a trigger at the ‘Add Trigger‘ button. A form to create a trigger will appear. You have to name the trigger, link it to a product and insert the Javascript code that will be executed.

Triggers are executed when an event occurs like a thingWrite (when your thing post a value). So, we are going to code a script that sends an SMS when the temperature of a thing is up to 50. Here there is the JS code:

function trigger(params, callback){
  console.log('trigger triggered!!')
  //ignore non write events
  if(params.action !== 'write') return callback()</code>

  var values = params.values
  var thingToken = params.thingToken

  //iterate over the values of the write
  for(var i=0; i<values.length; ++i){     
    if(values[i].key === 'temperature' && values[i].value > 50){
      console.log('omg too hot')
      var telf = '+346661199991111'

      var message = 'Master, it’s too hot here! Device: ' + thingToken

      var twilio = new Twilio(
        'YOUR Twilio AccountSid',
        'YOU Twilio AuthToken'
      )

      twilio.sendMessage({
          to: telf, // Any number Twilio can deliver to
          from: '+346660099991111', // A number you bought from Twilio and can use for outbound communication
          body: message // body of the SMS message
        },
        callback
      )
    }
  }
  //end the trigger
  callback()
}

Now, every time that the temperature of all the devices from the product are up to 50, you’ll receive an SMS alerting you in real-time. And all you need to include to enjoy this feature are 32 lines of JS on your thethings.iO cloud code feature.

If you prefer to receive a voice call instead an SMS, you only have to change the twilio.sendMessage to twilio.makeCall as in the following example:

  twilio.makeCall({
    to: telf,
    from: '+346660099991111',
    url: url_call // A URL that produces an XML document (TwiML) which contains instructions for the call
  },
    callback
  )

Further reading