Thursday, 28 January 2016

IoT Vaidya Update#5 : Going Bit by bit using Bit Reactive and Kura(Implementation of IoT Button )

"IoT_Button"

Whenever we get started with a new programming language, the first program which we always prefer to compile is the "Hello World" ! Similarly, whenever we are getting our hands dirty on a brand new Micro-controller board, "LED Blinking" serves the purpose. IoT Button is also based on similar concept, it is for getting started with IoT .

Diving Deeper into IoT button:(Working)
  • A push button is attached to a GPIO pin of the Raspberry Pi, which acts as an input.
  • LED is attached to another GPIO pin of Raspberry Pi, which is enabled as output.(Don't forget to attach a Resistor of 1k with led to delimit the current).
  • When the button is pressed, the status is updated on the cloud, as well as it is reflected by switching On the LED attached to Pi.
To connect the Raspberry Pi with internet, light weight protocols are preferred, MQTT is one of them.Eclipse Paho project provides open-source client implementations of MQTT  in C, Java, Python etc.
Though IoT-Button can be implemented using Pi4J library and Eclipse Paho Project, this post discusses the same using Reactive Blocks.

What are Reactive Blocks ?
According to Frank Alexander Kraemer , Technology Manager, BitReactive

" Reactive Blocks is a plugin for Eclipse, which allows to systematically  create applications from building blocks. The building blocks can encapsulate Java  code and have special interface descriptions, which goes beyond traditional  interfaces.Therefore, blocks can be easily shared with other developers and be reused  easily.The type of graphical representation makes it easy to specify and  synchronize parallel processes. Because of these properties, Reactive Blocks is  especially suitable for the future applications for the Internet of Things. The tool can  also be used wherever systems must handle multiple tasks simultaneously.


Building IoT-Button using Reactive Blocks:

Reactive Blocks provides libraries for building IoT applications.From these libraries , we can import various activity blocks and use them in our applications.

For IoT button we have used following three blocks:
1. RPi GPIO Digital OUT
2. RPi GPIO Digital In
3. Robust MQTT

A Reactive building block is a combination of tightly connected diagrams and Java code.
  • A behavior diagram is used to describe the internal behavior of a block.
  • Java code are used to describe the details of operations in a behavior diagram.
  • The block contract describes in which order the input and output pins of a block can be used.



Every application built using Reactive block has an initial node, this is the point from where the application gets started(A token is generated).
  • In this application we have attached the initial node to an operation init. 
  • init method initializes the Robust MQTT blocks by providing the broker URL. 
  • Once the initialization is done , the token is then passed to the next method/operation setOutput(which returns a GPIO pin).
  • The Gpio pin returned from the operation setOutput is set as output inside the RPi GPIO Digital OUT block(LED is connected to this pin).
  • Once the output pin is ready the token is passed to RPi GPIO Digital In block via operation setInput. setInput returns a GPIO pin to RPi GPIO Digital In block.
  • Block sets this particular pin as input.(Push Button is attached to this pin).

Note: Now all the three blocks are in active state.(Active state is the state in which token can enter any of the three blocks via any of the pin )

  • Now whenever the Button is pressed , the token is duplicated to both the  RPi GPIO Digital and LedOn method.
  • The token received by the RPi GPIO Digital Out block ,toggles the present state of led(Switches it on).
  • The token received by the LedOn is passed to operation createMesg in the form of a string("LedOn").
  • createMesg converts the string into JSON and pass it over to Robust MQTT block as a object of type MQTTMessage.
  • After receiving the token , Robust MQTT block publishes it to the broker.
Once we are done with designing our application, we need to build it. Reactive blocks can be build into various platforms , such as J2SE, OSGi, Kura etc.
We have build "IoT Button" for Kura.

Kura Bundles can be installed in Raspberry Pi using Kura Web UI.




Tuesday, 5 January 2016

Eclipse Open IoT Challenge 2.0 - Update #4 (A glimpse on few errors and a little demo)

Hi people.First off, we wish you a very happy and prosperous new year 2016.This will be our very first update in the new year.So let's get started!
This post is about showing you the glimpses of the mistakes that we committed uptil now.Why showing mistakes you might be thinking?Because we have earned them!And they play crucial part in learning and also so that we may not commit them again and more so because we promised to show them in one of our last updates!



What you see above is a snap of a plot of CPU utilisation which is hosted on IBM bluemix node server.We chose CPU utilisation as a substitute for ECG data as of now.Plotting ECG will be similar to this.We didn't go with some random data for the same.To get this we stumbled upon following few errors:
This was when connecting to mongoDB database in the local machine.





We realized this was local machine problem and sought to use MongoDB compose by IBM bluemix.The results were great initially.Connected smoothly.


But the Json data was not being saved.


So after few correction in the app.js which is responsible for controlling processes on the cloud in our case, it was resolved.

This is the log on Bluemix resulting from find query on the database.The result is intentionally kept this way by applying conditions on the query to suit our purpose of plotting.


Following snapshot shows publishing CPU utitisation data and subscription as well as saving on the cloud.

But wait!Time has yet not come for celebrations for we have another problem.This:


The plot is not as we expected it to be.The problem that we later found was with the plotly library usage.The arguements that we were passing were not in the correct order.

Finally we got our desired plot.You  can view it yourself by visiting the link http://medic.mybluemix.net/ecg .Imagine yourself as a doctor and virtually you are able to view somebody's ECG(not actually right now) data!You will be also able to recommend medications to this patient with the help of IOT VAIDYA.Currently we are working on the same.

NOTE : 
1.The website is under development phase.
2.You might have to wait for few seconds before the plot is loaded.
3.If the link is not working please understand that it's in development stage and the app has not been re-staged yet.

This was it for now.Catch us on the next update that'll be soon.Meanwhile please follow and support us on twitter @iot_vaidya










Monday, 28 December 2015

Eclipse Open IoT Challenge 2.0 - Update #3 (Getting Started with Bio-medical Sensors)

In our last two posts we have been talking about the software side of the project i.e; eclipse projects,various frameworks etc. Through this post we would like to throw some light on the hardware side too, i.e; sensors. The post guides you about the vital bio-medical sensors which we would be using to record patient's parameters.

For selecting these sensors we have taken following factors into consideration:

Doctors: we have consulted with various doctors ,to get acquainted with the type of data (parameters) required for primary diagnosis of a patient.
Invasive/Non-invasive: All the sensors, which we are using for our project are non invasive,so that any kind of infection can be avoided.
Cost: For the time being we are focusing on primary diagnosis of patient, hence we have avoided using costly complex bio-medical sensors.

We are going forward with following sensors. Once we have successfully interfaced these, we would add more,to make the diagnosis more useful.

1.Three Electrode ECG sensor:

We would be using it to monitor the ECG interval of a patient.The three electrodes are placed .The ECG is separated into two basic Intervals, the PR Interval and the QT Interval, described below.



For more details on ECG, follow the link below:
Electrocardiography

2.Pulse Sensor:

It is a noninvasive method for monitoring a person's oxygen saturation (SO2). Its reading of SpO2 (peripheral oxygen saturation) is not always identical to the reading of SaO2 (arterial oxygen saturation) from arterial blood gas analysis, but the two are reliably enough correlated that the safe, convenient, noninvasive, inexpensive pulse oximetry method is valuable for measuring oxygen saturation in clinical use.




A pulse oximeter probe applied to a person's finger


To know more about this sensor, follow the link below:
Pulse oximetry

3.GSR Sensor:

GSR, standing for galvanic skin response, is a method of measuring the electrical conductance of the skin. Strong emotion can cause stimulus to your sympathetic nervous system, resulting more sweat being secreted by the sweat glands.GSR allows you to spot such strong emotions by simple attaching two electrodes to two fingers on one hand, an interesting gear to create emotion related projects, like sleep quality monitor.

4.Temperature Sensor:

Temperature sensor would be used to monitor the patient's body temperature.We are using a waterproof temperature sensor.

This was just a getting started guide,in coming weeks we would be diving deeper into the sensors. We would upload more information such as:
1.Schematics
2.PCB
3.Datasheets
4.Hookup Guide

Please stay tuned and give your valuable feedback about the project.
Follow us on twitter : @iot_vaidya






Thursday, 24 December 2015

Eclipse Open IoT Challenge 2.0 - Update #2

Hi everyone!We are back with the second update for the Open IoT Challenge 2.0.As we have started with the hardware and software implementation,we tried to sum up our basic idea of the prototype in a block diagram.
IoT Vaidya - an IoT Medic
While we have given general description,we have not mentioned exact building blocks that we are using.Currently, we are playing with Raspberry Pi and Eclipse Kura to build the IOT Gateway.On the cloud side, we are presently using IBM Bluemix's IOTF service and it's node server.Database is being managed by MongoDB Compose ,also provided by IBM Bluemix.

TEST RUN: Firstly,we did simple test run to get the feel of MQTT implementation.We ran paho-mqtt client in python to publish JSON data to the bluemix cloud and a nodejs application on the same cloud to subscribe the data.It worked!!
Secondly,the MongoDB database is smoothly wired up with the application and it is getting data inserted and pulled.

Above achievements were not without any glitches.We did stumble upon few errors,We corrected them and got them up and running.We will be updating specifically about those errors in one of the upcoming blogs.For these updates, follow IoT Vaidya on twitter @iot_vaidya.Suggestions are welcome at iotvaidya@gmail.com


Tuesday, 15 December 2015

Eclipse Open IoT Challenge 2.0 - Update #1

There is a huge shortage of doctors in the rural areas; a huge imbalance exists in the number of doctors working in the rural areas as compared to the urban areas. This situation of lack of man power has been further worsened by unwillingness of doctors to work in these regions. In such kind of a scenario, getting basic health checkups is difficult and regular health checkup for people is a distant dream.
Enter IOT VAIDYA! - An IoT Medic which helps bridging gap between remote areas and doctors."Vaidya" is the hindi translation for Doctor.This is a standalone solution meant specifically for people living in remote places where there is shortage of doctors.It covers all the necessary steps right from the basic diagnosis to the prescription generation.
We are competing in Eclipse Open IoT Challenge 2.0 with this project.This is our very first article in the series of the updates about our progress in the project.If you have any kind of question or suggestion feel free to mail us at iotvaidya@gmail.com .We will get back with new updates soon!