Internet Of Things and K2 too


We are all connected! Yes i am even connected to you right now in some sort of way. What I am talking about? Well I am talking about we are all connected to each other by the internet probably through some traditional device like a laptop/pc and then followed by smartphones and over the last 4 years we have tablets and we are all interacting with different systems like Email,Facebook,Twitter,CRM,Custom Bespoke systems,SAP,Banking etc..

Connected Devices

But slowly over the last few years there has been this boom in off the shelf connected devices. Like Home Appliances,Lights,Health trackers, drones,smartwatches, micro controllers and even cars.

All these connected devices are sending and receiving data to us and to each other. That is a lot of data we potentially can have access to and one day in the very near future everything that we interact with will be connected to the internet.

If we takes the words of someone very wise, this big world of data is like this.

So yes Obi Wan is explaining the force, but that’s how these connected devices this ‘internet of things’ will be like in that everywhere we go and everything we interact there will be data being sent somewhere.

So lets travel into the future again and see what this connected world would look like

It is science fiction, but we are not far from this now. Your right. we can’t scan everyone’s eyes as they walk past to give each one a personalised message from GAP, but we can get near enough to this with iBeacons or proximity sensors that can trigger something to happen on a mobile device. So it could be you are in GAP and you walk through the store where there is an iBeacon  which is giving out a signal. Your phone picks up the signal which triggers your GAP app on your phone to give you some personalised information about any special offers you might be interested in.

Doesn’t that look cool and we can do this now. Let’s look at one more example, Skype Real time translator is like something from Star Trek with their universal translator.

What do we do with all this data?

So what do we do with all this data? Well we start with data that matters to you, information about your health, what the temperature is of a fridge, power in your car or how many lifts are currently running or even what music is currently trending on Spotify. Apple’s health kit does this, it collects all the data from these connected health devices and make’s it available to us to show how healthy we are or in my case how unhealthy.


This network of connected data allows businesses to receive data that is important to them and then act on it accordingly. Used with other solutions businesses can in real time make informed decisions and have this information delivered to them where ever they are and on any device. Azure Machine learning can predict what will come next based on existing data coming from these devices. Companies can see how many people are looking at a particular products with the use of iBeacons.


Another example could be using sensors to monitor roasting ovens that chickens are being cooked in. If the oven drops in it’s temperature this could then start off a workflow for someone to go and check the oven and more importantly the chickens are ok. This is where the K2 part comes into play.

True power of K2

K2 has this one unique feature that allows this interaction between internet connected devices and a workflow engine and web form builder with th SmartObjects.

With Smartobjects K2 can talk to virtually any data source whether it’s a SQL , Oracle database, Dynamics CRM,SalesForce, SAP  and endpoints whether it’s a dll assembly or web services. The last two are the key for K2 to be able to talk directly to connected devices and in some cases this can be a two way conversation.

The majority of these connected devices come with a API in the form of restful services as this allows for 3rd parties on different platforms to build apps around these devices.

Robotics (K2D2)


A example of using dlls with K2 can be viewed here in of my previous posts here K2D2. In that example we can K2 to send commands to the robot to move the robot around, but we can also get the robot to send  it’s sensor information back to K2. So we can have a Smart form that acts as a controller for the robot and this could be used on a mobile device or within SharePoint if needed.  With the data coming from the robot we can record this into in a sharepoint list or in another data source. The sensor data could also be used in a workflow to navigate the flow of the workflow.  With this two way communication we could use a workflow to navigate the robot around based on the sensor information coming back from the robot.

Other Sensors

So what about other connected devices like microprocessors and even Health Trackers.  Well K2 can talk to those too. We can take the data from Health Trackers and use it to build a health tracking system for patients. So if the patient heart rate dropped or they were not taking enough exercise then medical practitioners could be notified in any changes.

With Microprocessors we can build complex systems that monitor the environment around them  and for the information it gathers be monitored via K2.  Example could be a tempiture sensor monitoring a room or if a button is pressed for it to start a workflow and because this K2. The last example could be booking a meeting a room and the lights in the room are then activated at the time of the meeting.

These were just a few examples of what could be done and there is so much more we can do with the endpoints it doesn’t just have to be connected devices that K2 can use, but other services such as an SMS Service or any number of Azure data services.

Machine Learning

How about sending all this data into Azure Machine Learning, so we can start predicting the behaviour of these devices and then feeding that data back in K2. So we could be monitoring the data coming back from a lift and depending on the results from Azure it could trigger a workflow for maintenance to go and check the lift for any repairs that might be needed.


With K2 Smartobjects, we can talk to virtually anything via the endpoint assemblies and this opens up a whole world of possibilities. In what K2 can treat as a data source and also with it’s own API it allows third party services to trigger a workflow. This makes K2 a very powerful platform for this ever increasing market of  Internet of Things to interact with. As these type of devices become cheaper and types of devices that become internet enabled increases, there will be a ever growing demand for businesses to interact with these and K2 is in the perfect place to handle this.

Connecting Lego MindStorms to K2 Blackpearl

One of the tools that comes with K2 Blackpearl is Smartobjects and it has this brilliant feature of being able to talk to endpoint assemblies (.dlls). Which opens up K2 to  a whole world of possibilities.

So after an afternoon sat searching the internet on API’s and to make things easier started with researching .Net APIs. I came across this excellent community project on codeplex Lego Mindstorms .Net API. So with this in hand. I started to build a endpoint assembly that would allow K2 talk to Lego. How cool is that?

Creating these endpoint assemblies is easy enough. Your methods need need to be public and static.  (I will publish step by step guide on how to do this.)

Like in the example code below

public async static void MoveBackwards(int Power)
brick.BatchCommand.TurnMotorAtSpeedForTime(OutputPort.B, Power, 1000, false);
brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.C, Power, 1000, false);

brick.BatchCommand.PlayTone(50, 1000, 500);
await brick.BatchCommand.SendCommandAsync();
catch (Exception ex)
{ }

All you need to is the build the project and drop any third party dlls into service broker folder on your K2 server and then register the dll of your project with the ServiceObject Tester. This will then expose your  methods as objects which you can then use to build your Smartobjects which you can then use in Smartforms and in your workflows.


You can download the code for the endpoint assembly here K2 Lego Robot Source code

Here is a link of K2D2 in Action at DevWeek 2014

I will post the step by step instructions on how to set it up soon