Saturday, 13 October 2012

First Step on the Internet of Things

Right, I've taken the summer off while the nights have been longer,Olympics in London, holiday etc.  However a chance encounter with a particular twitter feed inspired me to tinker some more.

Overall this stems from the stuff I did to take power measurements at home and graph them.  The question was, how can I do this more of this kind of thing in a simpler way.  It also stems from an observation that in a smartphone we have an amazing platform to do stuff with; a screen, keyboard input, WiFi and cellular connectivity,GPS, microphone and speaker, light sensor,accelerometer, application development environment.

It was the latter that always proved a blocker.  I've been able to develop an app for my Android device but always found it to be a pain.  Maybe it was my PC but the IDE and SDK was very flakey and the fact that you split GUI, code and constants across multiple files was a barrier for entry for me as a novice tinkerer.  Whenever I had spare time to do stuff I spent most of it setting up the environment and wrestling with it.  What I needed was a simpler solution....

The answer came through a Twitter feed that I subscribe to.  It's "Internet of Things" (@TheIoT) and the owner shares various interesting stories on M2M, the internet of things and the maker movement. One day they shared information on something called on{X}, an Android application + website that has been developed by Microsoft.

The idea of on{X} is that it provides a simple environment to a)detect a change in state on your handset and b)do something about it.  Best explained by a few examples "recipes" that they provide:

  • Automatically reply "I'm in a meeting, will call you back." when one of my contacts calls during a meeting
  • Text "Good morning" to my friend every Wednesday at 8:00 AM
  • Turn WiFi on when I arrive at work
So detect a time/location/change in state on your handset and do "something".

With on{X} installed on your Android handset you can write Javascript code on the partner website and automatically send it to your handset where at once it starts working.  The Javascript is very simple and insulates you from the underlying Android APIs. This means it's very quick to setup, write code, publish it to your handset, test, modify and so on.  The downside is little or no support for UI but this is not what I'm interested in.

The code segment below shows how you can the handset to detect that the screen has been unlocked,  pop a notification to the notification bar and turn WiFi on.



I've tinkered with loads of stuff but most recently I have scripts running all the time on my handset that:

  • Wake up every 15 minutes and log the battery charge level.
  • Wake up every 15 minutes and log the sound level measured by the handset microphone.
  • Wake up every 15 minutes and log my location.
  • Log when I enter and exit various "regions" (defined by lat + long and a radius value).  I also turn on WiFi when I come home (to save using cellular data). 
I now just need to work out what to do with these measurements....

No comments:

Post a Comment