Android logger update

The Android logger app has been updated. There have been major bug fixes that allow better functionality, proper feed updates and eliminate crashes devices. So, simply install the new app, type in your Feed ID, use the QR scanner to enter a Cosm key (make sure it has update and create rights), select a time interval and watch your mobile phone’s resources being logged on the Cloud!












Special thanks to ‘’ for helping with the bugs, beta testing and suggesting future features!

Using the TI BLE SensorTag

I just received my Bluetooth Low Energy SensorTag from TI and wanted to share my experience with it. Overall it looks like a great sensing device coming at an amazing price (25$ – free shipping- probably it is more of a promotion than an actual product).

SensorTag features 6 sensors in total (temperature, humidity, pressure, accelerometer, gyroscope and magnetometer) and it comes with a single cell coin cell battery (CR2032). Specs mention a  quiescent current consumption of 8uA, allowing years of battery life!

The device itself is quite small allowing it to be carried in your pocket.











Setting it up and pairing it with an iPhone device is easy and straightforward.

TI provides a free iOS app (TI BLE Sensor Tag) which visualizes on your phone all the sensor information polled form the device. However connecting some times (or most of the times actually) requires that the device is waken from the sleep mode by clicking on the side button. I find this pretty annoying since you cannot rely on polling data from the device at long intervals (longer than its ‘active connection’ period is set to), but that’s probably a general issue with most Bluetooth devices. On the good side, once you click the wake-up button on SensorTag, the app finds the SensorTag and connects to it right away.

Here are some screenshots form the TI app:











An interesting (free) 3rd-party app that utilizes the TI SensorTag is ‘Comfort Guide – SENSiBLE’ by Sensirion AG (btw SenorTag is based on Sensirion SHT21 humidity sensor), that combines humidity and temperature data illustrating environmental conditions to the user in an understandable manner:








Wonder how you can write your own iOS app to read sensor data? No problem, the TI app includes also its own code as a sample of how to connect with SensorTag and read data from the available sensors (this one goes beyond open source, it’s integrated open source, or embedded open source!!):


10 key questions – and some answers – about IoT

Quoting from here, answers express my own opinion.

“The IoT SIG recently ran a thought leadership event on the theme of ‘People-centred design and the Internet of Things’. The group identified ten key questions for the future of IoT which were explored and developed through the course of the day.

A full report of the meeting can be found here.

Ten key questions for the future of the IoT

  1. How can we establish and negotiate technological priorities? In a world of limited bandwidth, the growth in connectivity will challenge our current networks capacity to cope with data. We need a better way of understanding which services should be prioritised –how can we make sure vital medical data isn’t slowed by audiences streaming Eastenders? Answer: There is huge research behind prioritisation and QoS, some of it already integrated in coming standards like 6LoWPAN and CoAP, we have the technology, we need to identify the needs and deploy it appropriately. When we reach the point that medical data is streamed together with movie (as an example) data from the same property, then existing solutions (hopefully) will emerge. 
  2. How can we take a lifelong perspective on services and objects? We currently design for beginnings – getting people connected and tied into a system. How can we make sure people end relationships with service providers as easily? As more big-ticket items become connected (cars, fridges etc) and are sold on to new owners and users, this becomes increasingly important. Answer: Time will show; user needs will drive eventually the requirements and design specifications of products and services!
  3. How can we balance aspirations for the IoT with the reality of what it will be able to deliver? There are strong tensions between the aspirations and our vision of a technological future and the pragmatics of our everyday lives. There is a mismatch between a consumer’s ideal world and the lived world. Answer: Yes it is difficult to deal with that, though most of the IoT enthusiasts can deal with technical glitches, less interoperability and unfriendly interfaces (like always discovering a bluetooth device before using it). Rest of the users (i.e. the majority) will probably receive and use products and services that have overcome such issues). 
  4. Who represents who? Who stands up for, educates, represents and lobbies for people using the IoT or connected products? Is this the role of people-centred designers? Answer: Good question, too many stakeholders in the beginning, few will survive..
  5. Who are the people using it? How do we define the communities, circles or tribes that use each product and their relationship to each other? Answer: That’s a wrong I think, IoT should not be intended for a specific group of users, it should be able to penetrate every market and every aspect of life.
  6. What can we learn about the IoT from taking a historical analysis of the web? How can technological change inform technological future? Answer: Past cannot teach a lot, so many different circumstances, present can only show some different perspective of things.
  7. What is value of an agile approach? How can rapid prototyping or lean approaches help us to drive new product developments and how do they fit with a people-centred methodology. How can government nurture disruption, and is it their role? Answer: Rapid prototyping and lean approaches will at least demonstrate the use cases of IoT, facilitate initial distribution of devices and services, assist in collecting initial feedback from users and help formalize IoT requirements for success!
  8. How can we track “Things” and what will this tell us about their use? Answer: Tracking is not difficult, interpreting data was, is and will be in the near future the main challenge. Semantics is the answer, but we are a bit far from a good solution.
  9. What  are the new interfaces and dashboards that will help people to interact with the IoT? How important will the distinction be between things that have a screen and don’t have a screen? Answer: What is really the difference? Information dissemination matters, and web is ubiquitous! Interfaces will surely change to accommodate processed information and controls!
  10. Do we create value and value chains that reward creators or just users? We know that established value chains are being disrupted. Services like have become successful by identifying new consumer needs. We should ask, where’s the pain? But how to ensure that creators are rewarded for these developments. “

Using Webscript with Cosm

You all know Cosm (and if you don’t, here is a book chapter with a good introduction and examples). On the previous blog post I have mentioned briefly Webscript, a cool and easy way of running custom scripts without worrying about hosting and deployment!

Cosm is great for hosting and visualizing data from sensors and is also features a triggering mechanism. Triggers can be configured for each sensor datastream and can activate a HTTP Post to some server or make a Tweet. This feature is quite useful for being alerted when e.g., a sensor value goes over some threshold, does not change for some time or your feed goes to ‘frozen’ status (which could mean your device might have some networking/power issues). However when you need something more than a tweet (like doing some processing with the datastream data, a better alerting mechanism, etc.) you need to have your own server deployed.

This is where Webscript comes! For this purpose I have created a simple Lua library for using with the Cosm API. The library is here and it can be used directly with Webscript. Currently the following functions are provided:

  • read_current(apikey,feed, datastream): Returns the current value of a given datastream id that belongs to a given feed id. You have to provide a valid Cosm API Key with reading permissions
  • read_24h(apikey, feed, datastream): Returns a JSON object containing the average, maximum and minimum datastream values for the past 24 hours, e.g. [18.275, 81.3, 4.2]. You have to provide a valid Cosm API Key with reading permissions
  • list_datastreams(apikey, feed): Returns the number of datastreams for a given feed id. e.g., {“datastreams”: [“datastream1, timeupdated,currentvalue”, “datastream2,timeupdated,currentvalue”], “size”: 2}
  • isAlive(apikey, feed): Returns the status of a feed (“live” or “frozen”)


And here is an example of a webscript that will text you each day with some statistics (average, maximum and minimum value) about a specific datastream:

local cosm = require('hdoukas/cosm_lua/cosm')
local lom = require 'lxp.lom'
local xpath = require 'xpath'

local twilio = require('twilio')


local status = cosm.isAlive("COSM READ ACCESS API KEY","64820")
local message
local stats = cosm.read_24h("COSM READ ACCESS API KEY","64820", "cpu_0")
if tostring(status) == "live" then
message = "Feed status: live datastream stats:{avg:"..stats[1]..", max:"..stats[2]..", min:"..stats[3].."}"

local response = twilio.sms(ACCOUNTSID, AUTHTOKEN, '+123456789', '+123456789',message)

return message

The script will just text you if you run it, keep in mind that you will have to setup a cron job to schedule a daily execution.

Using to check your device status

When building an IoT system, no matter if it sends sensor information or it receives some triggers, it is always good to have a mechanism that checks the device status and alerts you in case of a power or a network failure. There are several ways to do that, and it always depends on the type of communication mechanism you use for data exchange. For example, if you use MQTT, the broker can tell when a link with a client goes down. Or, if you simply post sensor values to a service like Cosm, there are ways to check whether values are updated or not.

Most of the methods require from you to have access to the server and add some code/script that will alert you when some condition occurs (link breaks, values not updated, etc.). What if you don’t have access to the server? Another approach is to add some code at your device that regularly posts a request on some service to declare availability. But then you need to implement the service and take care of hosting as well.

I recently came across Webscript and I think it is pretty useful for (among other things) using it as a way to check your device status. Webscript allows you to write web scripts in Lua. Scripts get their own url through a user-defined subdomain on (like and can be also scheduled for periodical execution through  a cron-like manager. What I have found amazing about Webscript is that it is free and it has a very simple interface for writing and running your own script in minutes. It comes with very good documentation and many examples covering anything from simple ‘Hello world’ examples to SMS texting and payment transactions!

Webscript online Lua editor, comes with syntax highlighting!

Let’s see how you can make a script that will check your device’s status.

The concept is that your device (let’s say your Arduino) will post every x minutes to Webscript to let your script know that it is ‘alive’. At the same time the script itself will check every y minutes (y>x) through cron if the script has been updated. If not it will use twilio to send you a text message alerting you about!

Create a new script through here (preferably sign up first and login, although you can create scripts without any registration) and give it a name-subdomain so that it can be accessed remotely. Then add the following code:

local twilio = require('webscriptio/lib/twilio.lua')
local THRESHOLD = 10

live =
if live == "1" then
storage.time = tonumber(os.time())
if (tonumber(os.time()) - tonumber(storage.time)) > THRESHOLD then
dead = true
dead = false

if dead==true then
local response = twilio.sms(ACCOUNTSID, AUTHTOKEN,'+1234556789', '+1987654321','Oh no something is wrong with the Arduino!')

return {dead=dead, time=tostring(storage.time) }

The code initially imports the twilio library (for texting messages) and then reads the value of the variable ‘live’ from the URL request. If the script URL is requested by the Arduino, it will have the live=1 value, so the script saves the timestamp of the request. If the script URL is requested by cron, it just calculates the difference between current time and the saved time (last request from Arduino). If the difference is greater than a threshold (600 seconds in this example) it uses the twilio library to text an alerting message to a phone number. For debugging purposes (so you can check on your browser) it returns the status of the device and the saved timestamp. When done, remember to click the ‘Save’ button. That’s it!

To test the script, simply open in your browser the link of your script, adding the live=1 parameter:

You should get something like:

{"dead": false, "time": "1351790077"}

For testing you might want to use a smaller threshold value in your code, like 10 seconds. Now wait a bit more than the defined threshold and open the script url:

Now you should get something like:

{"dead": true, "time": "1351790320"}

and if you have properly set your twilio credentials in the script, a text message shall soon arrive on your phone!

To use the webscript with your Arduino, simply add the following method in your code and call it regularly from the loop() function:

void keepAlive() {

if (client.connect("", 80)) {
client.println("GET /?live=1 HTTP/1.1");
client.println("Connection: close");


Finally, go back to Webscript, on the Cron tab, and set your webscript to be invoked every e.g., 10 minutes:

Data Mining and the IoT

One of the most important factors for the success of the IoT is the ability of systems, services and applications to perform data mining. Why is that? Well, I think that one of the key roles of IoT is to drive smart interactions with users (like automation and decision support). To do so, systems need to collect information about users and their context (using sensors and web resources), make appropriate data analysis, filter data and present users the outcome or make smart decisions.

Before discussing about Data Mining and the IoT, let’s make first a short introduction on Data Mining. Data Mining is the process of identifying patterns in (usually) large data sets. To give you an example, consider having an activity tracker that you carry on all day long. Looking at the data the tracker collects, you see more activity during some evenings and on weekend mornings (because you go running during that time). You identify this pattern by correlating the activity value-score with time, comparing each value on the data with others. So actually you group activity values to different levels (medium, high, etc.) and then you register the time the grouped activity values take place. This process is called data clustering. While you can easily figure out such patterns yourself, imaging having hundreds or thousands of data entries and not just activity values and timestamps, but also duration, weather conditions, calories consumed, etc. To deal with such problems, computer science has applied statistical methods and built tools that allow you to perform Data Mining and exctract useful information out of the data sets. Some of the most important applications of Data Mining are data anomaly detection, data clustering, data classification, feature selection, and time series prediction.

IoT and data anomaly detection

image courtesy: Bayes Server

Anomaly detection can be a great feature for IoT applications. Let’s take again the activity tracker example. This time assume that you have set a monthly or weekly goal like loosing some weight or reaching an activity or calorie burning level. In addition to monitoring your activity, the system is also able to determine your daily calorie consumption. Let’s assume again that you go jogging every Tuesday and Thursday afternoon as well as weekend mornings. One Tuesday you neglect to go jogging and your daily activity falls low, while your calorie consumption remains the same. This is an anomaly for the system. If your tracking application was featuring data mining techniques, it would be able to remind you the following day to become more active and not to neglect your jogging on Thursday (or worse, it could tell your friends that you become lazy: interesting application for social networks + activity tracking services!).

Again, this is a simple example. But consider that you track your parents activities (like how often they leave the house, when they enter, how much time they spent in a room, etc.) through motion sensors, and their home environment conditions. If one day they go out for shopping and for some reason they are late, or if someone spends too much time in the bathroom, an anomaly detection system could alert you automatically.

IoT and data clustering

image courtesy: Bayes Server

As mentioned in the given example with the activity tracker, data clustering refers to grouping of data based on specific features and their values. It is the most common process of unsupervised machine learning. It is called so because in other processes like data classification, you need to ‘train’ the system first with data (think of the initial voice recognition systems where you had to train the system calling out specific words). Data clustering can be applied however on a new data set without really knowing much about it in advance (e.g., what kind of data, etc.). The number of clusters is usually given as an input (e.g., the number of activity levels the motion data should be divided into), but there are also algorithms that can automatically categorize data in the most optimal way. Data clustering maybe not be used directly in IoT applications, but in many cases it can be an intermediate step for identifying patterns from the collected data.


IoT and data classification

Data classification is used when the collected data is associated to a different classes. Think of the classes as groups which can correspond to situations, for instance, high or low activity in our example. Once you have some initial data of your activity tracking and you have already clustered them into high or low activity, you can use tools to build a training model. Then you can use the model to associate new tracker values into low or high activity. Data classification is not prediction (mentioned below). It is categorisation of new values. In the activity tracking example, the device you carry on senses motion using accelerometers and tilt sensors. Data classification can be one of the techniques used by the device vendor to associate the sensor values with steps, stairs climbing or sleep status. After clustering the steps and stair climbing into low, high or medium activity, the application can use again data classification in order to determine your overall activity at the end of the day.

IoT and feature selection

In data mining ‘features’ (or ‘attributes’) are called the types of data used for pattern recognition. For example, in the scenario with the activity tracker, features can be the activity level, the timestamp, the duration, the calories, etc. Most activity trackers are also able to track sleep levels (awake, asleep) and calculate a sleep quality index. These are all features too. So, let’s say that you collect all these data for some time and you also keep tracks of your daily sleep quality index. Feature selection is the process that allows you to identify features that affect your sleep quality index the most. For example, it could be that activity does not affect your sleep much but daily calorie consumption does.

Feature selection is mostly used to reduce the dimensionality in data mining problems. After some initial experimenting, you could apply feature selection, identify what are the features that affect a specific problem most, and then perform data classification, time series prediction or anomaly detection more easily (if you can reduce the feature dimensionality enough you could even perform some basic data mining even on an Arduino module!).

IoT and Time series prediction

image courtesy: Bayes Server

Time series prediction provides exactly what its name says: an estimation of what future data can be based on a specific dataset that is already collected and analysed. The most popular application of time series prediction is meteorology and weather forecasting. In our example time series prediction could work as follows: after collecting activity data for several days, the system can identify your daily activity patterns and associate them with time and date. So it can predict that on Wednesdays your activity remains low but on Tuesdays  it is supposed to be high and should alert you in case you are far from weekly target.


IoT and Big Data Mining

Big Data, in the case of IoT, is not only about lots of data generated continuously by sensors and other IoT enabled devices. Big Data is also about data heterogeneity: collecting, analysing and correlating data from different resources!  So, mining the data is not the biggest challenge here: technologies and algorithms have existed for quite some time and have been successfully used in economics, meteorology, medicine, etc. For IoT systems to be able to automatically process the data and make proper recommendations or notifications, there have to be ways to combine data efficiently (e.g., activity levels with daily calorie consumption), and annotate them properly. The latter means to label the data in a way that your pattern recognition system can identify that a specific sensor sends activity data while your mobile phone sends food calorie information. Semantics is the answer to this problem. Data standards and interoperability between devices and services is the answer to optimizing data collection and making the data available for processing and data mining.


Cloud systems are still bit cloudy….

It looks like when people refer to or talk about Cloud systems, most of them have different conceptions and perspectives.

Some users think that Cloud is a black box consisting of several computing systems that host their data and makes it available through web and their smartphone applications.

Some developers think the Cloud as a solution for avoiding the setup and maintenance of back-end systems while they can focus on developing and deploying applications that can scale.

Some researchers think of the Cloud as a huge computational engine with great memory and cpu resources that can be used to handle bid data mining and process parallelization.

But what about IoT users and developers? What is the Cloud for the IoT? Is it just data repositories where people can share sensor readings? IoT needs Cloud both for data storage, service provision (APIs for retrieving information, exchanging data, etc.) and power computing (big data mining). Cloud is the glue between applications, data, networks, embedded devices and their resources. It can be both private and public, allowing users to control access to their data. It can be both a service provider like Cosm where people can share data, but it also can be like iCloud that synchronises contacts, preferences and more, between several devices. Sure, Internet of Things will not succeed if we build independent Cloud silos: things will need to exchange information about data and users, but we can do this in a controlled manner that will respect user privacy!


The #OktoberfestOfThings

Thomas Amberg from Yaler together Marc Pous with have built the amazing #OktoberfestOfThings, an IoT-enabled beer mug that can count how often and how much beer the holder consumes during the famous Octoberfest in Munich, Germany!

The initial design has used an Arduino Nano, a BlueSMiRF-RN-v1 Bluetooth module and a Nexus S Android phone running a Bluetooth to Internet gateway app. They are using an ADXL335 accelerometer and a tilt switch to count sips. (Although it seems they initially came with much cooler ideas on that).

Data has been posted on

You can check more photos of the mug and the construction, as well as real-field testing here.

Just another proof that imagination can be the only limit for IoT-enabling devices and objects! Well done guys!

Making IoT Gateways

It is becoming more clear that ‘smart things’ at ‘smart homes’ will need IoT Gateways for communicating with the Internet and various web services. Why? Well, WiFi is good, but in most cases:

  1.  Is still expensive: You can buy a pair of RF transceivers at less than 10$ retail price. There is no way you can find WiFi modules that can beat that price (retail) yet.
  2. Power consuming: There has been a great effort into minimising WiFi power consumption, but still, you probably need your WiFi devices to be plugged to work or remember to recharge then every now and then.


These points are not to be taken as the rule, you can definitely IoT-enable a device using an electric Imp, but in the near future, there will be need for connecting devices that can’t afford a 20+$ WiFi interface.

And you might also have low signal, range issues as well.

What else you can use? You can go with RF solutions like this one that works out of the box and provides data encryption as well, maybe ZigBee and BLE (Bluetooth Low Energy). But then you need  a gateway that will provide the essential connectivity with the Internet to your devices.

Let’s briefly define what an IoT Gateway should feature:

  • It should have an interface that can connect to a Local Area Network (Lan) or a WiFi network. So, at minimum, either an Ethernet port ar a WiFi interface.
  • Interfaces to networks like Bluetooth, ZigBee, XRF, etc.
  • A way to forward communication from the device to the Internet and vice versa.

The latter requires appropriate software that will forward the device request to the Internet and transfer information back to this ‘IP-less’ device.

Preferably, the Gateway should also:

  • Provide security, like proper authentication of the devices and the services, as well as data encryption! IoT devices have limited resources and best-case they can do some symmetric data encryption. Introducing a Gateway device (like a linux board), you can even add PKI on top of that.


To enable interoperability with interfacing between devices and IoT Gateways (translation = turn on your IoT device from vendor A and it communicates with the Internet through an IoT Gateway from vendor B, simply, out-of-the box style), there has to be a new protocol/standard, at application layer or lower (network, packet).


Let’s see an example: I have a Bluetooth device that senses something from my environment and I would like that information to go to At the same time, I would like to set up some triggers for that device using Cosm trigger service.
If I use an existing IoT Gateway like this I would have to program the gateway myself to receive data from the BT Serial interface, and make a HTTP POST request to the Cosm API using that data. Then, I should also program the gateway to listen for trigger events from Cosm and forward them (again though sending something like a flag over the serial interface) back to the Bluetooth device.
It doesn’t look that hard to implement, but imagine being the BT device vendor and having no access to the IoT gateway for programming it!
How would the standard help? I could use, e.g., JSON to provide authentication credentials and describe the service endpoint from the BT device and then just forward that JSON message including the sensed data to the Gateway. In a similar way, I would describe potential requests the device might accept from the service.


Current status

Eventually, router vendors have realised the need for IoT gateways and have started to include some in their product lines. Check this Cisco M2M gateway for example. No idea how data forwarding works and how open that is in Cisco case! Also, the FI-WARE project is worth mentioning, since it looks like they are trying to build a device interfacing/communicating standard for IoT Gateways. More info here.


Hacking products and adding Internet connectivity

Although the Internet of Things is growing fast, currently there are only a few products in the market that are IoT-Enabled (Why or what the latter actually means, in terms of features and services, could be a discussion on a new post!). So, how about hacking existing products and adding the essential components/functionality for enabling communication with the Internet?

This is exactly what Simone Marra from openPicus thought before making this nice hack of an IKEA RGB Led Strip. The Led Strip comes by default with a controller that allows users to set the LED colors. Simone thought that it would be cooler to add a microcontroller with an embedded WebServer so that he could control the LED colors remotely! He used the famous Flyport WiFi module that features an embedded WebServer. Flyport WiFi can create ad-hoc WiFi network so that a user can connect directly through a mobile device or alternatively connect to an existing WiFi network so that users could connect from anywhere.

Here is a nice video demonstration of the hack:

The process for hacking the LED strip and the Flyport software are available here.

Providing Internet connectivity to the LED strip does not enable only remote configuring: With some code modifications, the strip could change the LED color based on the weather prognosis!

What’s the moral behind this hack? There is a great potential for bringing Internet connectivity to products. Makers and hackers recognise use cases (that vary from remote configuration to utilisation of information on web resources) and use existing tools to IoT-enable products. It is the right time that vendors and product manufacturers start embedding Internet functionality into their products!