Monday, June 27, 2016

Cooling your RPI with NodeRED and IoT Cloud

I was concerned about the temperature of the CPU of my RPI.

In this hot summer in Rome, temperature is often above 40 degrees and I don’t want to burn my PI.

I decided to give a try and develop an IoT app that measure the temperature of the CPU and send it to a Cloud Hub (I have used IBM Watson IoT) in order to visualize it and analyze it.

The application running on the device has been developed using NodeRED. It gathers the temperature every 10 sec. and send a msg to the IBM Cloud, using the dedicated node provided by NodeRED.

It is easy.

NewImage

Then I have directed the flow of one ventilator towards the case of the PI and… it works. It is really cooled down

quickly.

See the result:

NewImage

What languages for IoT?

Ian Skerrett, from Eclipse Foundation, has written a nice blog post about
  • What are the most used languages?
  • The most adopted Cloud Providers?
  • ..
for Iot

https://ianskerrett.wordpress.com/2016/04/14/profile-of-an-iot-developer-results-of-the-iot-developer-survey/

Node-Red and IBM Bluemix

I’m progressing, in the free time, my evaluation of Cloud IoT platforms.

As I wrote in a previous blog post, IBM IoT platform is really interesting. One of her strong point is NodeRED, a Visual Programming Language for IoT and Integration, built on top of NodeJS.

I have upgraded my Raspbian Jessie image on my RPI. With the upgrade I have found a new version of NodeRED.

Inside I have discovered, already installed, nodes to communicate with IBM IoT Watson. Nice.

NewImage

Tuesday, June 21, 2016

How hot is my PI?

Risultati immagini per image sun

If you want to measure the temperature of the CPU of your Raspberry PI, you can simply issue the command

root@iotgateway1:~# vcgencmd measure_temp

temp=46.0'C

A little bit hot!

Monday, June 13, 2016

NodeJS and IoT: Node Red

Next thing I'm going to explore is Node-Red.

Node-Red is a Visual Language, developed by IBM Emerging Technologies, that can be used to rapidly develop integration flows for IoT Application.
It is based on JavaScript and NodeJS.

It is available as part of IBM Bluemix PaaS, but since it is OpenSource you can install it on any environment where NodeJS is available. For example you can install it on a Raspberry PI or on a Intel Edison Board.

I have already written a short post on the subject:

http://lsaetta.blogspot.it/2016/04/visual-integration-tools.html

Stay tuned for updates on the subject!

Friday, June 10, 2016

Running and IoT

Let me tell you one truth: very often IT has produced boring things. Tons and tons of information, with severe reports, transactional systems never-stopping-but-doing-always-the-same-thing.

Has it really changed our lives? Well, probably yes. In the past there was someone writing information on a group of papers. Now it is using a bright monitor and a keyboard. And you can search, search… if you know what you want to search.

Let’s talk about the real-world-changing technology.

Smartphone (and Apple, Google) have really changed our lives.

I live in a big town (Rome) and even if I’ve been here for more than 20 years (yes, we Italian are not so nomadic as in other countries), I don’t know all the roads. If I have to go somewhere I turn on my Google Maps App and et-voila…. a nice voice teach me where I have to turn.

IoT is already everywhere, even if you don’t know.

And the list of things that we will see is…. bigger than your imagination (for sure mine).

Now, let’s go back to the title.

I love running, and running is not only a sport. It is a science. If you train seriously you can easily figure out, with little uncertainty, what will be your time in your next race.

In every big race they give you a “chip” that you attach on your shirt. And in this way they track you at least at the beginning and the end of the track.

In most important races, like Rome Marathon (I have done it one, in 2012), they track your time every 5 km. And you can go online, during the race, and see what your friends are doing.

For now I think that the chip is only an RFID tag that is recognized by sensors put at the crossing-line. It is a matter of costs.

But, in the near future you can imagine that every racer will have its own “smart thing”, with its data. And enough computing and networking capabilities to capture and send more information real-time. For example, heart-rate. A MQTT message with all this data every minute, send over a 6LoWPan metropolitan network.

Sometime happens that someone has a problem. There are doctors along the path. But with real-time health data you can detect early signs of future problems and save lives.

This is what we should do.

By the way, I’m going to run “CorriRoma” race at the end of next week. I’ll tell you how it has gone.

 

Wednesday, June 8, 2016

Oracle IoT Cloud Service: concepts and introduction.

Risultati immagini per picture for idea concept
Probably this will become a rather long blog post. I hope interesting too.
First of all, let’s recall what we commonly mean with the name “Thing”.
A “Thing” is a real-world (physical) object, that has attached a device, with:
  • computing capability
  • sensors
  • actuators
  • connectivity to the network
A Thing, through the attached device, therefore is capable to run some code (more or less powerful), is able to measure some physical properties (for example, the location, the temperature), is able to act on the physical world, for example turning on a light or an engine, and can communicate through the network.
The last capability probably is considered the most important. Without network connectivity we can call it “an embedded device”, but we don’t use the term “Thing”, in the sense of IoT.
Now, with more and more “devices” capable of computing capabilities and connectivity, the set of solutions available in the industrial and “Makers” world is rapidly increasing.
One example? The first one that comes to my mind: imagine a fleet of trucks transporting food that needs to be kept at low temperature. Or maybe medicines.
You want to be able to:
  • control the temperature inside the truck (the fridge)
  • control the location of the truck (Is the driver taking a too long nap?)
  • verify if the fridge is open and for how long
Well, today you can.You need:
  • A “computing board"
  • A GPS sensor
  • A temperature sensor
  • A 4G shield, to connect through 4G network and send messages.
Now, what you want to do with these “travelling” devices and their streams of data?
Well, you may have many different requirements.
I’ll try to list some:
  • Security is important
  • You want to register “devices” in order to avoid that “a fake” truck drive you mad
  • Receive in a reliable way messages from devices with data
  • Analyze in real time these data, in order to identify quickly that something wrong is happening (temperature is rising above threshold) and send a SMS alert to the driver
  • reset a board.
 As I have already written in this blog before, a really interesting board is Intel Edison. It is low cost (less than 100$) but really powerful. You can connect many different sensors. It can run Linux and (Oracle) Java. The most interesting thing is that it hosts a CPU based on X86 architecture. You realize what it means.
But, how to support the collection and analysis of all the data coming from, for example, 1000 trucks traveling around your country?
You can use Oracle IoT Cloud Service.
It is a Cloud Service provided by Oracle, as part of its PaaS platform, with many interesting functionalities for IoT.
With Oracle IoT CS you can develop applications, running on the device, in Java, C, NodeJS. In the rest of the post I’ll consider Java development.
First of all, with Oracle IoT CS, you can register a device. Only registered (and activated devices) can send messages to the IoT CS.
You can register a single device, using the Web UI, or register many devices with a batch, using a csv file.
When you register a device, you associate an ID and a “secret” to the device. These will be used to uniquely identify a device and secure the communication.
Next step is to install, on the device, the Device Client Library, provided by Oracle. You can download it from the Oracle site. At the end, you will need to put in the classpath a single JAR file ( device-library.jar).
Afterwards you will need to generate “a trusted assets store”, that will contain the keys and certificates needed to protect, with TLS, the communication between the device and IoT CS. The trusted assets store (a keystore generated with a provided Oracle tool) is private to the single device.
After having registered the device (or the set of devices) you will need to define a “Device Model”. A Device Model defines the interface between your “Things” and Oracle IoT CS. Again, you do this using Oracle IoT Cs Web UI (or, as we will see in another post, calling a REST API).
The Device Model defines:  format of messages exchanged, actions (methods) that you can call on the “Thing”, format of Alert messages.
A Device can have more than one Device Model attached.
Next step is to give a name to the IoT application you’re creating. You will associate the Device Model to the application and in this way you will be able to monitor the flow of messages from the IoT CS console.
Another step is to develop, compile and test the Java application that will run on the board. It will use a set of classes provided by the Device Client Library. For example the “Device Virtualization API”, that abstracts and simplifies the interactions between the devices and IoT CS. Behind the scene, the communication is based on messages exchanged through REST calls, protected by TLS.
At this point you’re able to start sending messages to Oracle IoT CS  and monitor the flows of messages using the Web UI.


NewImage

In the picture you see that the IoT application ApplicationEdison1 has received 12 messages.
And you can imagine 1000 connected devices sending their messages. Each one identified by the device id and some other metadata.
Now, the Analytics part: you want to analyze the streams and identify when some conditions are met (for example: temperature greater than 10 degree (10 C)).
Oracle IoT gives you an already configured and integrated instance of Oracle Stream Explorer.

NewImage

You can define a Source of Data, starting from a Device Model, and can define an “Exploration”. In this exploration you can specify filters conditions and therefore you will define an output stream that will give only device-id and timestamp for those messages where the condition is met (temperature > 10 )
Lastly, you can define an action, and send the output stream to a Java app that expose a REST service. This Java app will receive a JSON message for each situation where the threshold is crossed (T > 10) and can trigger what you want (for example, send an SMS).
The Java App can be hosted in Oracle Java Cloud Services or Oracle Application Container Cloud Services (based on Docker).
Ok… this is only a first introduction to concepts and what you can do with Oracle IoT CS.

One last thing: as you can see from my Linkedin profile, I work for Oracle. But I’m interested in many (iot) things and, as I have a degree in Physics, I’m always happy when I have time to play with measures and electronics.
Stay tuned.

Monday, June 6, 2016

Working with Oracle IoT Cloud Service (1)

First tests with Intel Edison and Oracle IoT Cloud Service (IoT CS).

NewImage
I have created a simple prototype in Java, using Oracle IoT SDK for Java SE.
In this prototype, I use UPM library (upm_grove) to read a temperature sensor, and I send the temperature readings to my instance of Oracle IoT CS using the Device Virtualization API from the SDK.
Not difficult. You need only to carefully configure the keystore in order to have TLS correctly working. More details in the next blog post.

8/11/2016: I have added more blog's posts on Oracle IoT CS... have a look!

Thursday, June 2, 2016

MQTT with TLS: a quick update

I was thinking about it. It happens: sometime you think that everything is clear. But it is not (everything).
Talking about secure MQTT I told you that you need:
  • To protect the confidentiality of the communication; In other words you don’t want that anyone else connected on the network is capable of reading the data, except for the gateway and the device;
  • Authenticate the gateway: the device (thing) needs to be sure that it is sending the data to the “real” gateway and not to someone else;
  • Authenticate the thing: the gateway will use the X509 certificate sent by the thing to authenticate the thing.
If you’re using TLS (not SSL), with a “enough fresh” version, this is a very strong and secure communication channel.
But, take care that in the configuration phase someone (you?) can take an easy path and in some way weaken the communication.
For example, you can configure the MQTT broker in such a way that it doesn’t require device authentication. This way some “fake” device can connect to your gateway and send fake data.
If you look at the way Iot Cloud Providers configure communication, the client authentication is mandatory.
Well, in my tests with Mosquitto I took the easy path. Well, you know, often I work on these posts on evening, when my mind tends to be “lazy”.
In conclusion: be careful about security. “Things” can discover the real world and act on it. Imagine if someone take controls of your Air Conditioners. He can drive you mad.
And worse things can happen.