Teknologi

I Bouvet er vi flere hundre teknologer som brenner for å programmere og utforme gode, digitale løsninger. I denne bloggen utforsker vi teknologien og deler det vi finner med dere.

How you can use Sesam to visualize your data with IOT tech

Sesam is ideal for Internet-of-things: A typical IOT project requires you to gather data from many sources. This little example illustrates how you can make a visual alert when data changes – using a Raspberry Pi LED Matrix. And we get to meet a cousin of LISP

Imagine you are asked to install a «snitching tool» in the CEO’s office so that he can see whenever people are overpaid, or if his favourites are underpaid! Like so…

Of course, I am underpaid!

What is this? It is a FLOW

A flow involves systems, datasets and pipes

A flow involves systems, datasets and pipes

The employee DATASET is fetched from the database SYSTEM using a PIPE. Another pipe adds a judgement, creating another dataset. Whenever this changes, a third pipe sends it off with JSON to the node-red system. Finally, a flow in Node-RED concatenates the first name with the judgement, and displays it.

The whole thing took me 15 minutes to make. Like Node-RED, Sesam is ideal to experiment with data and flows.

Getting Sesam

Sesam is available as a downloadable appliance and as a cloud service. These are in private beta and access can be requested by contacting info@sesam.io.

Defining the Database and Node-RED systems

Sesam has a lot of security features, and you can hide passwords and such using secrets. Since this is running locally, I go for the sharing policy 🙂

Sesam systems

The systems as displayed in the overview pane. They are defined thus:

Getting the data

The mysql->employee pipe is shown here, with the latest updated record of the employee dataset

A sesam PIPEThis pipe definition is really easy: Just what to get and where to put it. From now on, Sesam will check the table regularly, and update the dataset. Pipes that use the employee dataset as source will only react on changes.

A pipe that decides if you are overpaid

Here comes the logic that makes the text you saw…

Judgement pipeThis pipe copies the source dataset, and uses the Data Transformation Language transform to add a judgement:

DTL is a functional language, and it took me some time to wrap my head around it in a recent project. I guess that’s common for all of us with a background in imperative programming. It is a lot of fun once you get the hang of it!

What the entity looks like

Let’s look what a judged employee looks like after a couple of changes:

Here we see the system attributes also - used for book-keeping

Here we see the system attributes also – used for book-keeping

Based on the key-value store RocksDB, each dataset keeps previous versions. As you can see, my salaray has been CUT!

The snitch: Sending it off to Node-RED

The fskjermbilde-2016-10-16-kl-21-49-47inal Pipe adds a component to the base URL, and sends it off to the HTTP listener. In a real-life scenario you can fine-tune how Sesam will behave if the target system does not answer, set a number of retries, and eventually specify a dead letter dataset, so you can catch which updates it missed

 

 

 

The «tell_boss» pipe:

The batch_size allows us to control how many updates will be sent in each chunk.

Enter Node-RED and Sense-HAT

The Sense-HAT allows me to do a number of things, here I just use it as a marquee showing the text that it receives. What you see below is a Node-RED flow on my Raspberry

Node-RED with Sense HAT

Node-RED with Sense HAT. The delay node in front of the http response makes Sesam wait for each update, so that the text gets a chance to be displayed

Now let’s look at the data it receives and the code in the «Check & Set» node:

Debug pane in Node-RED

The message as it arrives in Node-RED

Depending on the values of the _deleted and _previous flags, the recieving system gets a heads-up on what has happened with the data – and can react accordingly. If the _deleted flag is set, it was – yes you guessed it – deleted. If the _previous value is null, it is a new entry, otherwise this is an update.

 

 

 

 

 

A little Javascript in the end

Now, let’s look at the code in the «Check & Set» function node. Sesam always sends data in arrays, and as you saw in the pipe deifintion, I have already made sure that it only receives one element in each HTTP request. So all I do now, is to concatenate the values that the boss wants to see:

That’s all there is to it…

This whole thing took me FIFTEEN MINUTES to make! As you can see, Sesam allows you to rapidly prototype stuff – and put it in production – perhaps replacing the Node-RED part with something more robust. If you want to know more about Sesam and Internet-of-Things, please have a look at the NDC presentation I gave last year (Slideshare)

 

Simen Sommerfeldt, CTO for Bouvet Øst
Rådgiver med teknologibakgrunn. Grunnlegger av bevegelsen "Lær Kidsa Koding!". Har siden 2014 spesielt fokusert på EUs nye personvernforordning, tingenes internett og semantisk integrasjon. Twitter/Insta: @sisomm

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *

Magic Mirror – version 1

Introduction A while back I discovered the exciting world of “magic mirrors”. I don’t remember how or where it caught my attention, but..

DevOpsDays Oslo 2016

5.-6. september hadde eg gleden av å delta på den første norske DevOpsDays i Oslo. Her er en oppsummering av høydepunktene..

Bouvet at JavaZone 2016

This year JavaZone celebrated it’s 15th year with with 3000 attendees and over 170 sessions. As one of Norway’s premier Java..

IT years are like dogs years

One of the characteristics of the IT industry is that time works differently for us. This is challenging and fun,..

The Future of SharePoint

Den 4. mai holdt Microsoft en virtuell event om fremtiden til SharePoint, jeg fikk heldigvis anledning til å delta de..

SharePoint 2016 er på vei!

Som lovet var Microsoft ferdig med utviklingen av SharePoint Server 2016 (RTM – release to manufacturing) rett før påske, og..

En skybasert integrasjonsplattform

SAP HANA Cloud Integration SAP HANA Cloud Integration (HCI) er en skybasert integrasjonsplattform. Denne kan benyttes i stedet for SAP..

IoT Juleverksted

Tradisjonen tro var det i starten av desember tid for det årlige juleverkstedet hos Bouvet i Sandvika. Dette var tredje..

Bouvet Battle Royale – Rematch

Vår årlige fagdag ble i fjor kjørt som showdown mellom våre avdelinger som jobber med Java- og Microsoft-teknologi. Uten å..

Key takeaways fra JavaOne 2015!

JavaOne er verdens største Java-konferanse og arrangeres hvert høst i San Francisco. Her kan du oppleve foredrag fra noen av de..

Teknologi

I Bouvet er vi flere hundre teknologer som brenner for å programmere og utforme gode, digitale løsninger. I denne bloggen utforsker vi teknologien og deler det vi finner med dere.