Project overview:
Often this is applicable to under developed (N.Africa) and developing nations (like India) where the vaccines storage environment (temperature) tracking is a big problem. When the environment is not optimal(temperature is not within the expected range), the efficacy of these vaccines is lost. All the health worker carries is a portable box with some cold pads (door to door polio vaccine campaign). Our connected maraca has to help ensure the safety and efficacy of the vaccines. While the traveling health workers go around, based on the vaccine type and recommended environment setting, sensor data will be sent to the cloud.
Over the cloud using data analytics we can predict if a vaccine vial is about to get spoiled (predictive analysis), so that it can be moved to a safety spot on time. Also, the data will help us determine if a health worker has not followed the best practices, and take actions accordingly. Also, using smartphones and cloud, health workers can be prevented to administer spoiled vaccine. This idea can be extended to efficient storage and handling of other environment-sensitive medicines as well.
Project takes advantage of
a. Cloud connectivity:
Crucial sensor data recorded inside the portable box is periodically pushed to the cloud. Cloud has enough resource to efficiently process the huge amount of data received. The data analysis done on cloud, is not possible to do in the IoT board. The insights received from the data analysis not only helps a health worker take corrective measures on time, but also promises the building of a better solution in the future.
b. Sensors:
Multiple sensors are used to monitor the environment of the portable box carrying the vaccines. In the future GPS sensors can also be added to track the movement of the health worker, generating more insights. The amount of information gathered from the sensors in an absolutely non-intrusive way is very effective in such ground level scenarios.
Usage of each sensor data:
.i. Temperature==strict temperature range should be maintained, otherwise raise alert
.ii. Light==Over exposure to light can spoil the vials, raise alert
.iii. Air Quality==degradation in air quality means, insulation is not working properly, raise alert
.iv. Gyro==if the vial is not kept in a proper position and if it is moving too much, it can go bad, raise alert
.v. Buzzer==raise alert
Project makes use of
a. Software components:
Components used:
1. Intel XDK for IoT to write JavaScript programs to run on Galileo
2. Putty to run setup commands and install npm modules on Galileo
3. Android SDK to write Android App to receive Push Notifications from the Cloud 3. Java to write Restful web services to receive data from Galileo
4. Linux programming on Amazon EC2 to setup Amazon cloud for data analysis
5. Apache Tomcat to run Restful web services to receive data from Galileo
6. Elastic search algorithm in Java setup to do data analysis for huge amount of data
7. NoSQL database setup to store the received data
8. HTML5 CSS programming to setup Kibana dashboard displaying real-time processed data with intuitive details
9. Java program to enable real time Push Notification to Android Phones using Amazon SNS and Google Cloud Messaging Service (GCM)
10. OS used: Windows 8, Linux.
11. We have done a full setup of Intel Analytics Cloud as well, but since the connectivity was intermittent, we moved to AWS.
b. Hardware components
1. Intel Galileo board
2.Grove kit and sensors (temperature, light, air quality, gyro)
3. WiFi card
Step 1: Setup Intel Galileo Gen 2 Board (Arduino Sketch 6.1) on Windows 8.1 64 bit
1. Get the Latest guide from here
2. Software Download here
3. Do the following before connecting SD card to the board --
a. Install Arduino Driver here
b. Follow the latest guide above till the Blink LED example.
4. Do the following after connecting SD card to the board --
a. After you connect the SD card, the Galileo COM port will disappear in Device Manager, and a CDC Serial Driver will appear in Unknown Devices
b. Install CDC Driver -
b1. In 'My Computer' you will see SD Card has appeared as a Removable Disk -> GoTo folder win-driver, copy iotdk-serial-external.zip into your local, unzip it.
b2. In Device Manager, right click on CDC Serial Driver --> Click Update driver --> Choose 'Browse Computer ..' --> Browse to the folder, where you have unzipped the above file.
b3. Refresh Device Manager - Action Menu - Scan for Hardware changes
5. Connect to Internet:
a. Using Terminal (Putty) here
b. Connect to Internet -https://software.intel.com/en-us/articles/getting...
c. Connecting to WiFi - https://software.intel.com/en-us/articles/getting... (If it is not working, you will need to disable any Internet proxy you have turned on)
Step 2: Connecting Grove Sensors to Galileo Board - How To and Tips & Tricks
1. We have used Grove Starter Kit Plus - Intel® IoT Edition: http://www.seeedstudio.com/depot/Grove-starter-kit...
2. This video from YouTube will show you how to set it up -
4. One important thing to understand when connecting a sensor to the Grove Base Shield and the sensors: There are two types of sensors: Analog and Digital. Depending on this, the sensor needs to be connected to the Analog or the Digital pin. If you connect the sensor to the wring ping, the program won't complain, and you will get results back from the sensor as well. But the result won't be accurate. Hence, you need to very careful about connecting the right sensor to the right pin.
5. Reading from the sensors and Writing to the sensors: Arduino Wiring and the Intel XDK SDKs have made writing code for these very simplified. You need just one line of code to do reading and writing. But doing this in the proper way can be tricky.
Reading and writing the sensor values - With sensors we are monitoring the environment. That means, we are reading/writing the sensor values at regular intervals. Setting this interval of reading/writing is tricky.
Reading - If you set the interval too short, for reading some values will be captured by your program, but not all. This is because, the speed the reading loop in the program is much higher than the physical capacity of the sensor to read environment parameter (temperature, motion, sound, etc.). But, skipping one or two values won't affect your program logic much. Hence, you won't even understand this is happening.
Writing - But when you are trying to write to an output device (buzzer, LED, etc.), if the interval is too short and you are running a code toggling the value (ON in one round, OFF in the second) to be written, the device may not behave properly. This is because of the hardware speed limitation. By the time the device, say buzzer, get the command of on turning ON, before even it triggers the physical sounds, the OFF command reaches it. Hence, you may need to do some trial and error to set the interval here.
Step 3: Writing Code in Intel XDK IoT to read sensor value and write to peripherals
The entire project zip is attached in this post - CloudComm.zip
1. Guide to use Intel XDK IoT - https://software.intel.com/en-us/intel-xdk-iot-edi...
2. Create a new Node.js project and write your code in main.js. You don't have to edit any of the other project files. Your entire code will be in main.js. We have used the node.js template from the above link.
3. We used the sample code from the Grove Intel Starter Kit Page (shared in the previous step). Here, I have attached the project files as a zip. Let me explain some parts of the code here -
4. To install libraries you need to run commands on the board:
(a) Do a putty to the board. Keep the baud as 115200, 8 and 115200
(b) Do an ls in / to confirm the yokto is installed
> cd /
> ls
(c) You may need to update the packages to ensure the sensor reading and device writings are working fine:
> opkg update
> opkg upgrade
(b) To install ndoejs modules:
> npm -g install
> npm link
4. Code Snippets -
(a) MRAA Library to read sensor values and write out to the pins - MRAA is a Low Level Skeleton Library for Communication on GNU/Linux platforms. In the Intel XDK IoT template, the main.js files has detailed instructions how to install the libraries.
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the Intel XDK console
(b) Load Grove module -
var groveSensor = require('jsupm_grove');
var upmBuzzer = require("jsupm_buzzer");
(c) Connect to Analog/Digital pin -
var temp = new mraa.Aio(1); //analog data at pin A1
var led = new mraa.Gpio(2); // digital data at pin D2
(d) Read value of Analog/Digital pin -
tempValue = temp.read(); //read the value of the digital pin
airValue = air.read(); //read the value of the analog pin
var led = new mraa.Gpio(2);
led.dir(mraa.DIR_OUT);
led.write(1);
Step 4: Setting up Amazon Web Services (Amazon Cloud) - Rest Service on EC2
We have set up a Rest Service on AWS EC2, to communicate between the Galileo Board and Cloud. main.js in CoudComm project contains the code to send HTTP POST request to cloud. Here is code snippet -
request.post(
'http://54.174.19.249:8080/VaccineMonitor/api/readSensors?date='+date.getTime().toString()+'&temp='+tempValue+'&air='+airValue+'&light='+lightValue+'&gyro='+gyroValue, function (error, response, body) { //console.log("cloud response: "+response.statusCode); console.log("data sent to cloud"); //if (!error && response.statusCode == 200) { //console.log("success!!"); //} } );
Steps to setup Rest Service on EC2 --
1. Setting up EC2 - http://docs.aws.amazon.com/AWSEC2/latest/WindowsGu...
2. Start a Windows Instance - http://docs.aws.amazon.com/AWSEC2/latest/WindowsGu...
3. Create a Rest Web Service - We created a J2EE REST Webservice (Spring MVC Framework) using Eclipse, and ran it on Tomcat. Follow the tutorial here to setup the service - http://codetutr.com/2013/04/09/spring-mvc-easy-res...
4. Attached Zip File VaccineService.zip contains the java and jsp code for the REST service for this project.
Step 5: Push Notification Service to Android Phone - Amazon AWS SNS and GCM
We have used Amazon SNS to take values from the rest service in EC2, and push it to Android Phone using GCM (Google Cloud Messaging Service)
1. Setting up SNS: http://aws.amazon.com/sns/getting-started/
2. Setting up GCM: http://docs.aws.amazon.com/sns/latest/dg/mobile-p...
We added the SNS project in the same workspace as that of the Rest Services. The SNS Java code is attached as the zip file Vaccine-SNS.zip.
To use the sample given by Amazon with minimal changes, we passed the message from Rest Service as a parameter 'msg_EC2'.
In the java file SNSMobilePush.java, we read the message from the Rest Service into the variable 'msg_EC2'. To account for this extra parameter, we edited the method signatures in couple of the files imported (AmazonSNSClientWrapper.java, SampleMessageGenerator.java) by SNSMobilePush.java. The rest of the sample code given by Amazon is kept as is.
The method setData() inside SampleMessageGenerator.java, is used inside the rest service java code to set the message to be sent to the phone:
public static void setData()
{
this.msg_EC2 = msg_EC2;
}
Note: In the Rest Service code I uploaded here, VaccineService.zip, the setData() call is not added. You can add this method directly in the controller, or create files in /service and /repo folders as per MVC convention to read the sensor data from the Controller and then let SNS copy it from the setData() method inside the /service file.
Comments