working with sensors internet of things - ut · working with sensors & internet of things...

44
Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage [email protected] Satish Srirama [email protected] 10/9/2015 Satish Srirama

Upload: dangnhu

Post on 25-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Working with Sensors

&

Internet of Things

Mobile Application Development 2015/16 Fall

Mohan Liyanage

[email protected]

Satish Srirama

[email protected]

10/9/2015 Satish Srirama

Page 2: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Mobile sensing

• More and more sensors are being incorporated

into today’s smartphones

• These sensors are enabling new applications

across a wide variety of domains, such as

healthcare, social networks, safety,

environment, etc.

Image Source -http://csce.uark.edu/~tingxiny/courses/5013sp14/reading/Lane2010SMP.pdf

10/9/2015 Satish Srirama 2

Page 3: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

What is a Sensor ?

• A sensor is a physical or virtual object that can

sense events or changes in its environment,

and produce corresponding output

• Most of the times sensor output will be an

electrical/ optical pulse

10/9/2015 Satish Srirama 3

Page 4: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Mobile phone’s built-in sensors

• MIC

• Camera

• Temperature

• Location (GPS or Network)

• Orientation

• Accelerometer

• Proximity

• Pressure

• Light

Note: not every device has all kinds of sensors

Image Source -http://www.bosch-sensortec.com/en10/9/2015 Satish Srirama 4

Page 5: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

The Android platform supports three

broad categories of sensors

1. Motion sensors – These sensors measure acceleration forces and

rotational forces along X,Y,Z axes.

– Includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.

2. Environmental sensors – To measure various environmental parameters

• Ambient air temperature and pressure

• Illumination

• Humidity.

– Includes barometers, photometers, and thermometers, etc.

http://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-intro10/9/2015 Satish Srirama 5

Page 6: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Sensor Types - continued

3. Position sensors

– Measure the physical position of a device

– Includes orientation sensors and magnetometers

Note: Some of these sensors are always hardware-

based (accelerometer, gyroscope, temperature ,

light, magnetometer) and some of these sensors

(gravity, linear acceleration, rotation vector )can be

either hardware-based or software-based (virtual).

10/9/2015 Satish Srirama 6

Page 7: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Motion Sensors

• Accelerometer

– Measures the acceleration force on

all three physical axes (X,Y,Z)

– Useful for monitoring device movement

like tilt, shake, rotation, or swing

Image Source -

https://developer.apple.com

/library/prerelease/ios/docu

mentation/UIKit/Reference/

UIAcceleration_Class/index.

html

Zompopo: Mobile Calendar Prediction Based on Human Activities Recognition Using the Accelerometer and Cloud

Services:Srirama, Satish Narayana, Huber Flores, and Carlos Paniagua. NGMAST IEEE, 2011 10/9/2015 Satish Srirama 7

Page 8: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• Gyroscope

– Measures a device's rate of rotation (angular

velocity)

– When the device is not rotating, the sensor values

will be zero

Image Source https://developer.tizen.org/dev-

guide/2.4b/org.tizen.guides/html/native/system/sensors_n.htm#gyro

Motion Sensors - continued

10/9/2015 Satish Srirama 8

Page 9: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• Magnetic Field

– Monitor changes in the earth's magnetic field on

X,Y,Z axes

– With the orientation sensor, you can determine

the position of a device

Image Source - http://gadgetstouse.com/gadget-tech/magnetic-feiled-sensor-necessity-navigation-

android-devices/10620

Position Sensors

10/9/2015 Satish Srirama 9

Page 10: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Environmental Sensors

• Android provides four hardware-based

sensors to monitor

– Relative ambient humidity

– Illuminance

– Ambient pressure

– Ambient temperature

10/9/2015 Satish Srirama 10

Page 11: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• Proximity sensor

– Most proximity sensors are simply light sensors(IR) that will detect "proximity“

– Reduce display power consumption by turning off the LCD backlight

– Disable the touch screen to avoid accidental touch events (the ear contact with the screen and generating touch events while on a call)

Environmental Sensors - continued

10/9/2015 Satish Srirama 11

Page 12: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Sensor Framework

• You can access the raw sensor data by accessing the

Android sensor framework

• Android’s sensors are controlled by external services

• The framework has provided call back to obtain

sensor dataApp SensorManager

Register Callback

Sensor Event

Sensor Event

SensorEventListener call back 10/9/2015 Satish Srirama 12

Page 13: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Sensor Framework - continued

• The Android sensor framework contains the following classes and interfaces– SensorManager

• This class provides various methods for – Accessing and listing sensors

– Registering and unregistering sensor event listeners

SensorManager mSensorManager;

mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);

• ServiceManager provides access to Sensor Manager Service

– Sensor• A class representing a sensor

• Uses to create an instance of a specific sensor

Sensor mAccelerometer;

mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

10/9/2015 Satish Srirama 13

Page 14: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

– SensorEvent• The system uses this class to create a sensor event object, which

holds information such as the sensor's type, raw sensor data, of a of a sensory event

– SensorEventListener• Provides two callback methods that receive notifications (sensor

events)

• When sensor accuracy change

public void onAccuracyChanged(Sensor sensor, int accuracy) {

// Do something here if sensor accuracy changes

}

• When sensor values changepublic void onSensorChanged(SensorEvent event) {

// Many sensors return 3 values, one for each axis.

float value1 = event.values[0];

…………….

// Do something with this sensor value.

}

Sensor Framework - continued

10/9/2015 Satish Srirama 14

Page 15: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• Important : Make sure to disable any sensor when you don’t use or when the sensor activity pauses

protected void onPause() {

super.onPause();

mSensorManager.unregisterListener(this);

}

– The system will not disable sensors when the screen turns off that leads to the battery will drain in a few hours

• You can register sensor listener when the activity resumed

protected void onResume() {

super.onResume();

mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

}

Sensor Framework - continued

10/9/2015 Satish Srirama 15

Page 16: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Course Exercise 1 Identify which sensors are on the device

10/9/2015 Satish Srirama 16

Page 17: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Reading accelerometer data

Course Exercise 2

10/9/2015 Satish Srirama 17

Page 18: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

@Override

public final void onSensorChanged(SensorEvent event) {

float x = event.values[0];

float y= event.values[1];

float z = event.values[2];

tv1.setText( "X : " +x+" Y : "+y+" Z : "+z);

}

@Override

protected void onResume() {

super.onResume();

mSensorManager.registerListener(this, mAcc,

SensorManager.SENSOR_DELAY_NORMAL);

}

@Override

protected void onPause() {

super.onPause();

mSensorManager.unregisterListener(this);

}

}

10/9/2015 Satish Srirama 18

Page 19: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Working with the sensor simulator

• Download and extract

http://code.google.com/p/openintents/downloa

ds/detail?name=sensorsimulator-2.0-

rc1.zip&can=2&q=sensorsimulator

• Execute sensor simulator

– $ java –jar sensorsimulator-2.0-rc1.jar

10/9/2015 Satish Srirama 19

Page 20: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

10/9/2015 Satish Srirama 20

Page 21: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Communicate with the AVD• Install app in AVD

– adb install SensorSimulatorSettings-2.0-rc1.apk

(adb command in /android-sdk/platform-tools/)

– Set IP address in AVD

10/9/2015 Satish Srirama 21

Page 22: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Course Exercise 3

• Orientation indicator that displays the device

orientation as Left , Middle and Right

10/9/2015 Satish Srirama 22

Page 23: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Mobile Sensing and Internet of Things

http://iotworldnews.com/2014/10/qualcomm-snaps-up-bluetooth-pioneer-csr-to-capitalise-on-iot/10/9/2015 Satish Srirama 23

Page 24: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Internet of Things (IOT)

• International Telecommunication Union

defined IoT as

“A global infrastructure for the information

society enabling advanced services by

interconnecting (physical and virtual) things

based on existing and evolving, interoperable

information and communication technologies

”(ITU Internet report-2005)

10/9/2015 Satish Srirama 24

Page 25: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Internet of Things (IOT) - continued

• European Research Cluster on the Internet of

Things defined IoT as:

“The Internet of Things allows people and

things to be connected Anytime, Anyplace, with

Anything and Anyone, ideally using Any

path/network and Any service.”

10/9/2015 Satish Srirama 25

Page 26: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• A thing,

– Can be a person with a heart monitor implant

– A farm animal with a biochip transponder

– An automobile that has built-in sensors

– Other natural or man-made objects

With unique identifier and the ability tocommunicate over the internet without requiringhuman interaction.

Internet of Things (IOT) - continued

10/9/2015 Satish Srirama 26

Page 27: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Why it is so important ?

• More connected devices than people

• Cisco believes the market size will be$19 trillion by 2025

10/9/2015 Satish Srirama 27

Page 28: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Environment Protection

• Great Barrier Reef in Australia

• Buoys equipped with sensors collect

biological, physical, and chemical data to

minimize and prevent reef damage

Source : Kip Compton, VP Internet of Things (IoT) Systems and Software Group The Internet of Things: What Does it Take to Make the Internet of Everything

Real? 10/9/2015 Satish Srirama 28

Page 29: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Smart Home Scenario

Sensing as a Service Model for Smart Cities Supported by Internet of Things”, Charith Perera1, Arkady Zaslavsky, Peter Christen,

Dimitrios Georgakopoulos, TRANSACTIONS ON EMERGING TELECOMMUNICATIONS TECHNOLOGIES Trans. Emerging Tel. Tech. 2014

10/9/2015 Satish Srirama 29

Page 30: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Smart Healthcare

• Medication in The United States

• Smart pill bottles remind patients to take their medication and records that the patient has taken the correct dosage

Source : Kip Compton, VP Internet of Things (IoT) Systems and Software Group The Internet of Things: What Does it Take to Make the Internet of Everything

Real? 10/9/2015 Satish Srirama 30

Page 31: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Smart health

Dr. M, project KAIST10/9/2015 Satish Srirama 31

Page 32: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Smart Agriculture

• Minimizing the Use of Insecticides

• Smart trapping solutions compile data and

map the number of different types of insects

that have been detected

Source : Kip Compton, VP Internet of Things (IoT) Systems and Software Group The Internet of Things: What Does it Take to Make the Internet of Everything

Real? 10/9/2015 Satish Srirama 32

Page 33: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Where Mobiles can Fit?

• Most of the times IOT sensors do not have a

sufficient amount of energy and processing

power to connect directly to the internet through

Wi-Fi or mobile networks

• Especially when the sensors deploy sparsely, a

mobile device can work as a sink/relay to collect

the sensor data and upload them to the backend

servers

• Eg: Mobile crowd sensing, Wildlife tracking etc.

10/9/2015 Satish Srirama 33

Page 34: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Mobile Sensing with Non-integrated

Sensors• Mobile phones can collect data from external

sensors and upload them to the backend servers

or provide data directly to the end users(Mobile

Host*)

• Wildlife tracking, logistics, urban sensing, etc.

• Android phones can communicate with sensors

over the Air interface (Wi-Fi, Bluetooth, NFC,

ZigBee , etc.)

*S. N. Srirama: Mobile Hosts in Enterprise Service Integration, PhD thesis, RWTH Aachen University, September, 2008

10/9/2015 Satish Srirama 34

Page 35: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Arduino Sensor kit• Basic prototype board with the Arduino Mega

ADK microcontroller and the sensor shield

Microcontroller

Sensor shield 10/9/2015 Satish Srirama 35

Page 36: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• Demo

Reading ambient temperature

Setup

• Mega ADK microcontroller

• Bluetooth module and temperature sensor

• App to communicate with the Arduino

10/9/2015 Satish Srirama 36

Page 37: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Bluetooth low energy(BLE) shield

Mega ADK microcontroller

& sensor shield

Android APP

10/9/2015 Satish Srirama 37

Page 38: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

– Temperature sensor generates an analog signal according to the temperature variance

– Microcontroller do the A/D conversion and forward data to the Bluetooth module

Arduino code

How does it work?

10/9/2015 Satish Srirama 38

Page 39: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

How does it work? - continued

• Bluetooth module transmits data to the Android

device over the established connection

• The Android app reads data over the established BLE

connection, processed and present to the end user

10/9/2015 Satish Srirama 39

Page 40: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Control LEDs over the WEB

• Running a small web server on the Arduino

board which provides controlling LEDs through

Web interface

Setup

10/9/2015 Satish Srirama 40

Page 41: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

IOT research in Mobile Cloud Lab

• The goal of this research is to overcome the challenges of cyber-physical systems in the Internet of Things

• Our research interests are

– Middleware

• Energy-efficient Things Framework

• Mobile-hosted Things Middleware (MHTM)

• Mobile-hosted Cloud Middleware (MHCM)

• Mobile Resource Composition Mediation Framework (MRCMF)

– Trust

• Trustworthy Internet of Things

– Application

• Real-time Augmented Reality using Context-aware Cloud services with Mobile Hosts

10/9/2015 Satish Srirama 41

Page 42: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

Home assignment 2

• An object moves from left to right (and vice-

versa) based on the orientation of the device

10/9/2015 Satish Srirama 42

Page 43: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

• A touch event makes the object to jump over an obstacle

• Submission deadline is 22nd October 2015

Home assignment 2- continued

10/9/2015 Satish Srirama 43

Page 44: Working with Sensors Internet of Things - ut · Working with Sensors & Internet of Things Mobile Application Development 2015/16 Fall Mohan Liyanage ... • Most of the times IOT

References/Suggested readings

• C. Chang, S. N. Srirama, M. Liyanage: A Service-Oriented Mobile Cloud Middleware Framework for Provisioning Mobile Sensing as a Service, The 21st IEEE International Conference on Parallel and Distributed Systems (ICPADS 2015), December 14-17, 2015. IEEE. (Accepted for Publication)

• C. Chang, S. N. Srirama, J. Mass: A Middleware for Discovering Proximity-based Service-Oriented Industrial Internet of Things, 12th IEEE International Conference on Services Computing (SCC 2015), June 27 - July 2, 2015, pp. 130-137. IEEE.

• C. Chang, S. Loke, H. Dong, F. Salim, S. N. Srirama, M. Liyanage, S. Ling: An Energy-Efficient Inter-organizational Wireless Sensor Data Collection Framework, The IEEE 22nd International Conference on Web Services (ICWS 2015), June 27 - July 2, 2015, pp. 639-646. IEEE.

• B. Zhou, A. Dastjerdi, R. Calheiros, S. N. Srirama, R. Buyya: A Context Sensitive Offloading Scheme for Mobile Cloud Computing Service, 8th IEEE International Conference on Cloud Computing (CLOUD 2015), June 27 - July 2, 2015, pp. 869-876. IEEE.

• M. Liyanage, C. Chang, S. N. Srirama: Lightweight Mobile Web Service Provisioning for Sensor Mediation, 4th International Conference on Mobile Services (MS 2015), June 27 - July 2, 2015, pp. 57-64. IEEE. (Won Best Paper Award)

• S. N. Srirama, A. Ostovar: Optimal Resource Provisioning for Scaling Enterprise Applications on the Cloud, The 6th IEEE International Conference on Cloud Computing Technology and Science (CloudCom-2014), December 15-18, 2014, pp. 262-271. IEEE.

• C. Chang, S. N. Srirama, S. Ling: SPiCa: A Social Private Cloud Computing Application Framework, The 13th International Conference on Mobile and Ubiquitous Multimedia (MUM 2014), November 25-28, 2014, pp. 30-39. ACM.

• J. Mass, S. N. Srirama, H. Flores, C. Chang: Proximal and Social-aware Device-to-Device Communication via Audio Detection on Cloud, The 13th International Conference on Mobile and Ubiquitous Multimedia (MUM 2014), November 25-28, 2014, pp. 143-150. ACM.

10/9/2015 Satish Srirama 44