Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11....

40
Internet of Things

Transcript of Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11....

Page 1: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Internet of Things

Page 2: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

사물 인터넷 사물끼리 인터넷으로 연결돼 정보를 주고 받는 것

Micro Controller Unit (MCU)

Arduino

Bluetooth API

Android

iOS

IoT example

IoT Services

Page 3: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

상상해 보자. 출근 전, 교통사고로 출근길 도로가 심하게 막힌다는 뉴스가 떴다. 소식을 접한 스마트폰이 알아서 알람을평소보다 30분 더 일찍 울린다. 스마트폰 주인을 깨우기 위해 집안 전등이 일제히 켜지고, 커피포트가 때맞춰 물을 끓인다. 식사를 마친 스마트폰 주인이 집을 나서며 문을 잠그자, 집안의 모든 전기기기가 스스로 꺼진다. 물론, 가스도 안전하게 차단된다.

Page 4: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

목적

Smart home (귀뚜라미 IoT 보일러, 대성쎌틱 IoT 보일러)

https://www.youtube.com/watch?v=zp6V1Ovs2oo

Wearables (smart suit : https://www.youtube.com/watch?v=D_LYKcUQrLQ )

Sports/Fitness (Shine2 : https://www.youtube.com/watch?v=oI06LiKOZgk )

Automotive

Healthcare

사물 인터넷을 위한 통신 프로토콜

HTTP (Wi-Fi)

BLE

Xbee

MQTT

RFID

Page 5: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Hardware

Arduino Uno (Yun)

Raspberry Pi

Intel Galileo/Edison

Tessel

Spark

Beagleboard

Page 6: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Arduino

Simple Microcontroller

Runs in a loop

Programmed in C

Arduino IDE

Upload Sketch

Serial Monitor

Page 7: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Arduino download

http://arduino.cc/en/Main/Software

가상 시뮬레이터

https://circuits.io/ (http://www.123dapp.com/circuits)

Arduino function

setup()

loop()

pinMode()

digitalWrite()

delay()

Libraries

Page 8: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Sketch programming

Real test : https://www.youtube.com/watch?v=bB5xmfPyyXs

int led = 13;

void setup() {// initialize the digital pin as an output.pinMode(led, OUTPUT);

}

void loop() {digitalWrite(led, HIGH);delay(1000);digitalWrite(led, LOW);delay(1000);

}

int led = 13;

void setup() {// initialize the digital pin as an output.pinMode(led, OUTPUT);

}

void loop() {digitalWrite(led, HIGH);delay(1000);digitalWrite(led, LOW);delay(1000);

}

Page 9: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor PWM (아날로그 출력)

Piezo Speaker

Switch On/Off

Light sensor (광센서)

Potentiometer (가변저항:전위차계)

Page 10: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor

PWM (아날로그 출력)

https://www.youtube.com/watch?v=poXnlZMr2es

int led = 9;int fade = 0;

void setup() {pinMode(led, OUTPUT);

}void loop() {

for(fade; fade <=255; fade+=5) {analogWrite(led, fade);delay(30);

}delay(1000);for(fade;fade>=0;fade-=5) {

analogWrite(led, fade);delay(30);

}}

int led = 9;int fade = 0;

void setup() {pinMode(led, OUTPUT);

}void loop() {

for(fade; fade <=255; fade+=5) {analogWrite(led, fade);delay(30);

}delay(1000);for(fade;fade>=0;fade-=5) {

analogWrite(led, fade);delay(30);

}}

Page 12: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor

Switch On/Off

https://www.youtube.com/watch?v=350IkiOpzyA

int led = 13;int inPin = 2;int val = 0;

void setup() {pinMode(led, OUTPUT);pinMode(inPin, INPUT);

}

void loop() {val = digitalRead(inPin);if(val==HIGH) {

digitalWrite(led, Low);} else {

digitalWrite(led, HIGH);}

}

int led = 13;int inPin = 2;int val = 0;

void setup() {pinMode(led, OUTPUT);pinMode(inPin, INPUT);

}

void loop() {val = digitalRead(inPin);if(val==HIGH) {

digitalWrite(led, Low);} else {

digitalWrite(led, HIGH);}

}

Page 13: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor

Light sensor (광센서)

Page 14: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor

Light sensor (광센서)

https://www.youtube.com/watch?v=XQtpYUGqLnA

int LDR = 1;int LED = 11;int val = 0;int final = 0;

void setup() {Serial.begin(115200);

}

void loop() {val = analogRead(LDR);final = val / 2;Serial.println(final);

analogWrite(LED, final);delay(200);

}

int LDR = 1;int LED = 11;int val = 0;int final = 0;

void setup() {Serial.begin(115200);

}

void loop() {val = analogRead(LDR);final = val / 2;Serial.println(final);

analogWrite(LED, final);delay(200);

}

Page 15: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Module and Sensor

Potentiometer (가변저항:전위차계)

소리 볼륨 조절하는데 주로 사용되는 것

https://www.youtube.com/watch?v=TFiJS68EztA

int potPin = 0;int val = 0;

void setup() {Serial.begin(115200);

}

void loop() {val = analogRead(potPin);val = map(val, 0, 1023, 0, 255);

Serial.println(val);delay(100);

}

int potPin = 0;int val = 0;

void setup() {Serial.begin(115200);

}

void loop() {val = analogRead(potPin);val = map(val, 0, 1023, 0, 255);

Serial.println(val);delay(100);

}

Page 16: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

사용자 UUID를 이용하여 소켓 연결 및 데이터 송수신 함

BluetoothAdapter 클래스 이용

getDefaultAdapter() 메소드를 이용해 내장 Bluetooth를 불러오며,

ACTION_REQUEST_ENABLE을 이용하여 블루투스 활성화 시킴

BluetoothSocket과 BluetoothAdapter를 이용하여 상호 간에 연결

Mainfest.xml에 퍼미션 설정

BLUETOOTH (커넥션 요구, 커넥션 수락, 데이터 전송 등)BLUETOOTH_ADMIN (디바이스 검색, 블루투스 설정 등)

<user-permission android:name=“android.permission.BLUETOOTH”/>

Page 17: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connection Flow

BluetoothServiceBluetoothServiceMainActivityMainActivity

BluetoothService() 실행BluetoothService() 실행 BluetoothService() 생성자BluetoothService() 생성자

getDefaultAdapter() 어댑터 생성getDefaultAdapter() 어댑터 생성사용자 대기사용자 대기

접속 버튼 터치접속 버튼 터치 getDeviceState() 메소드 실행getDeviceState() 메소드 실행

enableBluetooth() 사용가능 확인enableBluetooth() 사용가능 확인

onActivityResult()자동 실행

onActivityResult()자동 실행

scandevice()로 디바이스 검색scandevice()로 디바이스 검색

getDeviceinfo() 정보 얻기getDeviceinfo() 정보 얻기

Connect(device) 접속 후 thread 실행Connect(device) 접속 후 thread 실행

Page 18: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

BluetoothService.java

Page 19: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

BluetoothService.java

Page 20: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

BluetoothService.java

Page 21: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

BluetoothService.java

Page 22: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

MainActivity.java

Page 23: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Android Connect

MainActivity.java ( http://www.evernote.com/l/Ahibn7GtnwhM1bcYdN_52N0OVYyqlqS6sEM/ )

Page 24: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect

CoreBluetooth framework 사용

Server : CBCenteralManager와 CBPeripheral 클래스 사용

CBCentralManager를 통해 디바이스 UUID를 찾아와 연결함

CBCenteralManager : Bluetooth 연결에 중앙 역할

centralManagerDidUpdateState – Bluetooth 상태 체크

centralManager: didDiscoverPeripheral – 디바이스 발견됨

centralManager: didConnectPeripheral – 디바이스 연결 후 설정 부분

centralManager: didDisconnectPeripheral – 접속 종료

CBPeripheral : Bluetooth 연결된 후 데이터 처리를 위한 클래스

peripheral: didDiscoverServices – 연결 후 서비스 확인

peripheral: didDiscoverCharacteristicsForService – 특성 확인

peripheral: didUpdateValueForCharacteristic – 데이터 전달 처리

Page 25: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect

CoreBluetooth framework 사용

Client : CBPeripheralManager와 CBPeripheral 클래스 사용

peripheralManager : CentralManager와 연결되는 클라이언트 관리

peripheralManagerDidUpdateState – Bluetooth 연결 상태 확인

peripheralManager: central – 연결 된 후 데이터 처리

Page 26: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS ConnectBluetooth ServerBluetooth ServerBluetooth ClientBluetooth Client

CentralManager 생성CentralManager 생성

didDiscoverPeripheral 디바이스 스캔didDiscoverPeripheral 디바이스 스캔Peripheralmanager

didupdatestatePeripheralmanager

didupdatestate

didConnectPeripheral 연결didConnectPeripheral 연결

didDiscoverServices 확인didDiscoverServices 확인

Peripheralmanagercentral:

Peripheralmanagercentral:

didDiscoverCharacteristicsForServicedidDiscoverCharacteristicsForService

didUpdateValueForCharacteristicsdidUpdateValueForCharacteristics

didDisconnectPeripheral 연결 종료didDisconnectPeripheral 연결 종료

didFailToConnect

Peripheral

didFailToConnect

Peripheral

PeripheralManager 생성PeripheralManager 생성

IsReadyToUpdateSubscribers

IsReadyToUpdateSubscribers

Page 27: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (server)

Page 28: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (server)

Page 29: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (server)

Page 30: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (server)

Page 31: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (server)

Page 32: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (Client)

Page 33: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

iOS Connect (Client)

Page 34: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Arduino with Smart device 무선 조정 car

http://blog.naver.com/rkdalstkd12/220813025662

Bluetooth 모듈과 application으로 원격 조정 가능

무선 조정 tripod https://www.youtube.com/embed/xn44k7vgAaE

무선으로 카메라가 부착된 tripod를 회전 하고, 촬영 할 수 있음

특수 촬영을 위한 방송 장비

Scorpio Head SB92

동일한 카메라 움직임을 지원하여 특수 효과 합성에 이용됨

Page 35: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Arduino with Smart device

하드웨어를 무선 조정 하는 것이 가능 Scorpio – 무선 조정 카메라 특수 촬영 장비

고가의 조정 하드 웨어를 소프트웨어로 대치 가능

Page 36: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Arduino with Smart device

하드웨어 무선 조정을 위한 애플리케이션 Flow

Page 37: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Home service with IoT

사용 프로토콜:

Samsung SmartThings (Hub)

https://www.youtube.com/watch?v=q4VbJ6Rju8g

LG IoT@home (보다 현실적인 내용)

https://www.youtube.com/watch?v=tTS8yJyFg-M&feature=youtu.be

Google nest : 실내 온도 설정 및 자동 유지

https://www.youtube.com/watch?v=1qkSkOn4h-A

Philips Hue : 실내 빛의 색, 조명 등을 조정

Personal wireless lighting

스마트 화분 Planty (화분 모니터 기록: 온도, 수분양, 빛 받은 정도)

https://www.youtube.com/watch?v=0M9fOEIzfo8

Page 38: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Home service with IoT

Arduino YUN : 사물인터넷용 (Wi-Fi 내장)

Temboo : 사물인터넷 API 서비스 (웹사이트 서비스)

https://temboo.com/

위의 사이트를 이용하여 웹 API 사용이 가능하며, 프로그램 코드 생성을 자동 생성 하여 사용할 수 있음 https://www.youtube.com/watch?v=FJuBjhFKW6E&list=PL0Vl139pNHbeFywh-

pSlXd0qsmsT3ji12&index=2

Page 39: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

Home service with IoT

Samsung ARTIK

Temboo 사용 가능

https://www.youtube.com/watch?v=nvo18-n50So

Page 40: Internet of Things - SKKUmonet.skku.edu/wp-content/uploads/2016/09/MAD_Week5_IoT.pdf · 2016. 11. 2. · iOS Connect CoreBluetooth framework 사용 Server: CBCenteralManager와CBPeripheral

MCU 하드웨어MCU 하드웨어

Smart phoneSmart phone

기존 연구

MCU 하드웨어MCU 하드웨어

Smart phoneSmart phone

사물 인터넷 연구

Service APIService API

Bluetooth

BluetoothWi-Fi