[IoT 교육 ] 사물인터넷디바이스개발 KETI (Korea Electronic Technology Institute) 안일엽책임 (iyahn@keti.re.kr)
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
OCEAN Open Sources http://www.iotocean.org Have more platforms become complicated 2
1.1 오픈소스종류및 onem2m 표준준수 오픈소스종류별 onem2m 표준지원여부 Mobius ncube CSE AE Framework ASN MN IN Blue Octopus Spring Yellow Turtle Node.js Java Rosemary Node.js Java Lavender Node.js Java Thyme Node.js Latest Release onem2m Release 1 Software name Framework version Publication date Standard Server(IN-CSE) Mobius : Blue Octopus Mobius : Yellow Turtle Spring Framework Node.js v1.1 v2.1.2 2015-09 2016-08 TS-0001 Functional Architecture v1.6.1 TS-0004 Service Layer Core Protocol v1.0.1 TS-0009 HTTP Protocol Binding v1.0.1 Gateway(MN-CSE) TS-0010 MQTT Protocol Binding v1.0.1 Device(ASN-CSE) Application(AE) &Cube : Thyme Node.js v1.6.2 2016-08 3
1.1 오픈소스종류및 onem2m 표준준수 Mobius: Yellow Turtle Node.js Java Script 기반 IoT Server Platform (onem2m IN-CSE) HTTP, MQTT 연동지원 경량 / 저용량시스템으로간편한설치가능 시스템요구사항 System requirements Operating System Open Source Framework Web Application Server Database CoAP Framework - MQTT Broker 표준리소스지원 CSEBase, remotecse, AE, container, contentinstance, subscription, latest, oldest, timeseries, timeseriesinstance, locationpolicy, group, fanoutpoint, semanticdescriptor 표준 Primitive 지원 XML/Json 지원 short-name 리소스지원 Remarks WindowsX, Linux Redhat and CentOS, Mac, Raspbian Node.js Node.js MySQL Mosquitto 1.4.x 4
1.1 오픈소스종류및 onem2m 표준준수 &Cube: Thyme HTTP, MQTT 연동지원 Node.js Java Script 기반 IoT Application (onem2m AE) 경량 / 저용량시스템으로간편한설치가능 시스템요구사항 System requirements Operating System Remarks WindowsX, Linux Redhat and CentOS, Mac, Raspbian Open Source Framework Node.js Web Application Server Node.js Database MySQL CoAP Framework - MQTT Broker Mosquitto 1.4.x 표준리소스지원 CSEBase, remotecse, AE, container, contentinstance, subscription, notification, latest, oldest 표준 Primitive 지원 XML/Json 지원 short-name 리소스지원 5
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
1.2 Select open source platform in OCEAN to build the use case with onem2m IoT/M2M Device IoT/M2M Gateway IoT/M2M Server Admin/ User &Cube : Thyme for Java &Cube : Thyme for Node.js &Cube : Rosemary for Java &Cube : Rosemary for Node.js Mobius-BO &Cube : Lavender for Java Mobius-YT &Cube : Lavender for Node.js 7
Construction Server Platform S/W name onem2m Nodes AE CSE ASN MN IN Framework Mobius Blue Octopus Spring Yellow Turtle Node.js Rosemary Java Node.js &Cube Lavender Java Node.js Thyme Java Node.js
Construction Device Application Platform S/W name onem2m Nodes AE CSE ASN MN IN Framework Mobius Blue Octopus Spring Yellow Turtle Node.js Rosemary Java Node.js &Cube Lavender Java Node.js Thyme Java Node.js
Thing Adaptation Software (TAS) REST API REST API IoT Open Source, OCEAN How IoT Devices Work? Things IoT device platform IoT service platform IoT application Data upload Data retrieve Send command &Cube Control request 10
1.2 &Cube:Thyme 활용디바이스개발방법 &CUBE:Thyme 11
Development Procedure for IoT Product Idea! (functions) Things (Sensors & actuators) Hardware Software Product! New! Smart! &Cube Creative! TAS * *TAS: Thing Adaptation Software 12
1.2 &Cube:Thyme 활용디바이스개발방법 Product = Idea + H/W + &CUBE + TAS IoT Server = Server(H/W) + Mobius Rosemary water pump Lavender Yellow Turtle temperature sensor &CUBE-Lavender Thyme Blue Octopus idea! led light H/W (Open Platform) Product humidity sensor TAL S/W supporting S/W Product design
1. 개요 1.1 오픈소스종류및 onem2m 표준준수 1.2 &Cube: Thyme 활용디바이스개발방법 1.3 &Cube 연동구조
1.3 &Cube 연동구조 Raspberry Pi TAS TAS AE (&Cube:Thyme) Laptop SmartPhone Smart Socket IN-CSE (Mobius: Yellow Turtle) AE (Remote Lighting Service) mobius-yt seahorse ss_1 Subscription contentinstance contentinstance contentinstance contentinstance ss_1_ctrl Subscription
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및개발환경구축 2.3 &Cube: Thyme 구동환경구축
Mobius Yellow Turtle 서버플랫폼 S/W 아키텍처 Mobius Yellow Turtle : Node JS 를기반으로 Java Script 로개발 DB 는 MySQL 을지원하고있으며통신프로토콜은 HTTP, MQTT 를지원 17
Mobius Yellow Turtle 서버지원 Resource 구조 http://hostname:port/in-cse_name/ae_name/container_name/contentinstance_name 18
Construction Server Platform with Mobius : Yellow Turtle Reference install guide of Yellow Turtle in OCEAN 19
Construction Server Platform with Mobius : Yellow Turtle MySQL 설치 (MySQL Server, MySQL Workbench) 20
Construction Server Platform with Mobius : Yellow Turtle MySQL 데이터베이스생성 (mobiusdb) 21
Construction Server Platform with Mobius : Yellow Turtle MySQL mobiusdb 테이블가져오기 (www.iotocean.org) 22
Construction Server Platform with Mobius : Yellow Turtle MQTT 서버설치 Mobius Yellow Turtle Platform 은디바이스와의통신을위해 MQTT 프로토콜을지원하고있으며이를위해서오픈소스로제공되는 MQTT broker Mosquitto 서버를설치 http://mosquitto.org 사이트에서다운로드 MQTT 를지원하지않는다면설치하지않음 23
Construction Server Platform with Mobius : Yellow Turtle Node.js 고성능의비동기 IO (Async/Non-blocking IO) 를지원하는 single thread 기반네트워크서버 2009 년 Ryan Dahl 에의해개발이시작되었고현재수많은지원모듈을가지고있는오픈소스프로젝트중하나 Google Chrome V8 엔진으로개발되어있고 Event 기반의프로그래밍모델로써프로그래밍언어로는 Java script 를사용 현재많은인터넷기업들이 node.js 를도입 Node.js 설치 http://www.nodejs.org Node.js 설치확인 24
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및 &Cube 개발환경구축 2.3 &Cube: Thyme 구동환경구축
2.2 사물인터넷디바이스 Open H/W 소개 Raspberry Pi 3 Model B 영국의라즈베리파이재단이개발 기초컴퓨터과학교육을증진시키기위해만든싱글보드컴퓨터 Raspbian (Debian 계열 Linux) 운영체제사용 기타운영체제포팅가능 상세정보는 http://www.raspberrypi.org/ 홈페이지에서확인가능 CM1106 CO2 Sensor 공기 CO2 평균농도값측정 UART 통신방식지원 PL2303 USB UART Board UART 데이터 USB로변경 3.3v 5v 출력 RGB 3 Color LED Red, Green, Blue 동시표시가능 26
2.2 사물인터넷디바이스 Open H/W 소개 Raspberry Pi 3 Model B 영국의라즈베리파이재단이개발 기초컴퓨터과학교육을증진시키기위해만든싱글보드컴퓨터 Raspbian (Debian 계열 Linux) 운영체제사용 기타운영체제포팅가능 상세정보는 http://www.raspberrypi.org/ 홈페이지에서확인가능 Smart Socket 전력량측정을수행하고 ON/OFF 신호를통해전력차단이가능한디바이스 TI CC2530 을이용한 ZigBee RF 무선통신수행 Sink node TI CC2530 CP2103 USB-to-Serial Mini USB 활용연결인터페이스제공 Temperature / Humidity 센서 AM2315 I2C 인터페이스 Raspberry-Pi Camera 27
2.2 Open H/W 기반개발환경구축 원격접속환경구축 (SSH client 사용 ) SSH client 프로그램다운로드및설치 (PuTTY) http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY 프로그램설정및연결 Raspberry-Pi의 IP address 입력을통해접속 호스트키확인메시지출력시 예 를눌러캐쉬에등록 접속완료시로그인진행 (Raspberry-Pi 초기설정 ID : pi, PW : raspberry) 25
2.2 Open H/W 기반개발환경구축 Samba 서버구축 Repository 업데이트 pi@raspberrypi ~ $ sudo apt-get update Reading package lists Done Samba 서버설치 pi@raspberrypi ~ $ sudo apt-get install samba samba-common-bin Do you want to continue [Y/n]? Y Samba 서버구축 Samba 서버사용자추가 pi@raspberrypi ~ $ sudo smbpasswd a pi New SMB password: ( 원하는패스워드입력 ) Retype new SMB password: ( 원하는패스워드입력 ) Added user pi. Samba 서버사용자설정 pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf ( 가장마지막줄밑에 ) [pi] comment = raspberry pi folder path = /home/pi valid user = pi writable = yes browseable = yes <Ctrl>+<X> Y <Enter> 29
2.2 Open H/W 기반개발환경구축 Samba 서버구축 Samba 서버재시작 pi@raspberrypi ~ $ sudo service samba restart [ ok ] Stopping Samba daemons: nmbd smbd. [ ok ] Starting Samba daemons: nmbd smbd. Samba 폴더연결 Windows 탐색기실행 주소입력창에 \\Raspberry-Pi IP 주소입력 예 ) \\203.254.173.126 pi 폴더더블클릭 계정및패스워드입력 계정 : pi, 패스워드 : Samba 서버설치시지정한패스워드 30
2. 사물인터넷디바이스개발환경구축 2.1 사물인터넷모비우스플랫폼구동환경구축 2.2 사물인터넷디바이스 Open H/W 및 &Cube 개발환경구축 2.3 &Cube: Thyme 구동환경구축
Install Node.js Make Download Check a the directory and version install to of install Node.js Node.js and package package manager >> pi@raspberrypi ~/node $ mkdir $ sudo node wget v https://node-arm.herokuapp.com/node_archive_armhf.deb >> pi@raspberrypi ~/node $ cd $ node sudo npm -vdpkg i node_archive_armhf.deb 32
2.2 &Cube: Thyme 구동환경구축 Node.js 패키지설치 Node.js 다운로드및설치 pi@raspberrypi ~ $ mkdir node pi@raspberrypi ~ $ cd node pi@raspberrypi ~/node $ sudo apt-get update pi@raspberrypi ~/node $ sudo apt-get upgrade pi@raspberrypi ~/node $ sudo apt-get remove nodejs pi@raspberrypi ~/node $ sudo wget https://node-arm.herokuapp.com/node_archive_armhf.deb pi@raspberrypi ~/node $ sudo dpkg i node_archive_armhf.deb ( 패키지설치명령어 ) pi@raspberrypi ~/node $ node v ( 버전확인명령어 ) pi@raspberrypi ~/node $ npm -v ( 추가라이브러리설치도구버전확인명령어 ) 33
3. 사물인터넷디바이스개발실습 3.1 &Cube:Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
How to Develop Software for IoT Devices? Install &Cube Develop TAS Test Device Download &Cube Install Node.js Configure &Cube Run &Cube Download TAS sample Develop TAS Configure TAS Run TAS Download Mobius API collection Install test program Test device 35
하드웨어준비 Connect CO2 Sensor 36
하드웨어준비 Connect RGB LED - -> pin0(wiringpi) G -> pin1(wiringpi) B -> pin2(wiringpi)
Download &Cube Go Download to the OCEAN &Cube:Thyme homepage (Download (www.iotocean.org) &Cube and Thyme) log in (or sign up) 38
IoT 장치연결 IoT 장치 (Raspberry-Pi) 연결
3.2 &Cube: Thyme 구동실습 &Cube: Thyme 샘플다운로드및구동테스트 www.iotocean.org 에서 &Cube:Thyme 다운로드 Thyme 생성 Move the thyme source to Raspberry Pi with samba Unzip the thyme source file Access Raspberry Pi with putty pi@raspberrypi ~/node/thyme $ cd thyme pi@raspberrypi ~/node/thyme $ unzip thyme-1.6.2.zip pi@raspberrypi ~/node/thyme $ sudo npm install ( 추가라이브러리설치명령 ) 40
Development Device Platform with &Cube : Thyme { } "useprotocol": "http", "cse": { "cbhost": "203.253.128.151", "cbport": "7579", "cbname": "mobius-yt", "cbcseid": "/mobius-yt" }, "ae": { "aeid": "S", "appid": "0.2.481.1.1", "appname": "keti01", "appport": "9727", "bodytype": "json", "tasport": "3105" }, "cnt": [ { "parentpath": "/keti01", "ctname": "homepot01" }, { "parentpath": "/keti01", "ctname": "homepot01_ctrl" }, { "parentpath": "/keti01", "ctname": "cnt_2" } ], "sub": [ { "parentpath": "/keti01/homepot01_ctrl", "subname": "sub_1", "nu": "mqtt://localhost/ssklpsg89" } ] Reference development guide of &Cube : Thyme in OCEAN Install modules needed with npm install at prompt in device then Configure conf.json 41
3.2 &Cube: Thyme 구동실습 &Cube: Thyme 샘플다운로드및구동테스트 구동테스트 &Cube: Thyme 실행 pi@raspberrypi ~/node/thyme $ node thyme.js ( 실행명령 ) 42
&Cube:Thyme 실습 43
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Download TAS Sample Go Download to the OCEAN TAS Sample homepage (Download (www.iotocean.org) &Cube Thyme) and log in (or sign up). 45
Develop TAS Open Edit TAS sample source, `app.js >> pi@raspberrypi ~/node/thyme_tas $ sudo nano app.js 46
Configure TAS Open Edit TAS config file, `conf.xml (enter information about Things) >> pi@raspberrypi ~/node/thyme_tas $ sudo nano conf.xml 47
Run TAS Set Install root Node.js user password libraries of for the installing working Node.js project libraries and run TAS >> pi@raspberrypi root@raspberrypi ~/node/thyme_tas $ sudo $ sudo passwd npm install root >> pi@raspberrypi root@raspberrypi ~/node/thyme_tas $ su $ node rootapp.js 48
&Cube:TAS 실습 49
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Download Mobius API Collection Go to the OCEAN homepage (www.iotocean.org) and log in (or sign up). Download Mobius API Collection (Download Mobius Yellow Turtle) Version example: mobius-yt-releasexxx.json.postman_collection 51
Install Test Program: Install Postman REST Client & Import Collection Install Import and Test run API Postman collection REST Client Google Collections Chrome Import Browser Collection Menu More tools Extensions Get more extensions Upload Search files postman Choose rest mobius-yt-releasexxx.json.postman_collection client ADD TO CHROME Import 52
Test Device: Data Retrieval Data retrieval example using Mobius API Collections mobius-yt-releasexxx contentinstance retrieve 53
Test Device: Control Request Control request example using Mobius API Collections mobius-yt-releasexxx contentinstance create 54
Test Device 실습 55
3. 사물인터넷디바이스개발실습 3.1 &Cube:Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Configuration for My Lighting Service Bulb Raspberry Pi TAS TAS AE-Bulb (&Cube:Thyme) SmartPhone Laptop IN-CSE AE 디바이스등록센서연결데이터업로드데이터조회디바이스제어 (Mobius: Yellow Turtle) CSE-Mobius AE-Bulb CNT_Status CNT_control (Remote Lighting Service) Subscription contentinstance contentinstance contentinstance contentinstance Subscription 57 contentinstance
AE-CSE (&Cube-Mobius) MSC Example &Cube:Thyme Mobius mca
TAS (Thing Adaptation Software) Example &Cube:Thyme Mobius mca { ctname : <Target container name>, con : <data> } 예 ) { ctname : cnt_1, con : TAS2015 } { ctname : temp, con : 29.8 } { ctname : temphumi, con : 29.8, 47 } { ctname : 4491, con : 29.8, 47 } 59
Case study for Smart Pot Service (Demo) Yellow Turtle Temperature / Humidity ncube: Thyme ncube:thyme- Tweet Camera LED 60
Configuration for Smart Pot Service (Demo) Camera Raspberry Pi Temp/Humi &Cube:Thyme _Tweet SmartPhone Sensor TAS (homepot01) LED ryeubi (&Cube:Thyme) IN-CSE (IoT-CP) Laptop IN-CSE ryeubi homepot01 Subscription contentinstance contentinstance contentinstance contentinstance 61
ToT (Tweet of Thing) mobius-yt Mobius-YT
ToT (Tweet of Thing) mobius-yt ryeubi Mobius-YT homepot01 create AE (ryeubi) create container (homepot01) ncube:thym e (ryeubi)
ToT (Tweet of Thing) mobius-yt ryeubi Mobius-YT homepot01 ncube:thym e (ryeubi) create contentinstance contentinstance contentinstance contentinstance contentinstance { ctname : homepot01, con : 20.1,64.2 } Tas (am2315, led) Am2315: Temperature, Humidity Sensor Led
ToT (Tweet of Thing) mobius-yt ryeubi Mobius-YT homepot01 create subscription sub_1 for /mobius-yt/ryeubi/homepot01 contentinstance ncube:thym e (tweet) ncube:thym e (ryeubi) contentinstance contentinstance contentinstance sub_1 Tas (am2315, led) Am2315: Temperature, Humidity Sensor Led
ToT (Tweet of Thing) mobius-yt ryeubi Twitter Mobius-YT homepot01 tweet notification of homespot01 create contentinstance contentinstance contentinstance ncube:thym e (tweet) ncube:thym e (ryeubi) contentinstance contentinstance push notification { ctname : homepot01, con : 20.1,64.2 } sub_1 Smart Phone Tas (am2315, led) Am2315: Temperature, Humidity Sensor Led
3. 사물인터넷디바이스개발실습 3.1 &Cube: Thyme 구동실습 3.2 &Cube:TAS 개발실습 3.3 Test Device 3.4 서비스시나리오 3.5 Yellow Turtle 구축실습
Construction Server Platform with Mobius : Yellow Turtle Mobius-YT 서버설치 OCEAN Alliance 사이트 (http://www.iotocean.org) Download Mobius:Yellow Turtle from OCEAN 68
Construction of Mobius:Yellow Turtle Extract zip and run npm install in command prompt at the folder of mobius 69
Construction of Mobius:Yellow Turtle Setting of configuration file (conf.json) for mobius in-cse: 서버의정보설정 csebase: 서버의 root 이름, root path cseport : 서버가오픈하는포트번호 dbhost: DB 서버주소 dbpass: DB 접속암호 mqttproxy: mqtt proxy 호스트주소 mqttproxyport: mqtt proxy 포트번호 { } "m2m:conf": { "csebase": "mobius-yt", "cseport": "7579", "dbhost": "localhost", "dbpass": "dksdlfduq2", "mqttproxy": "localhost", "mqttproxyport": "9726" } 70
Mobius-YT 실습 71
Conclusion - OCEAN (Open alliance for iot standard) http://iotocean.org To Be Continue... 72
감사합니다. 안일엽, iyahn@keti.re.kr 성낙명, nmsung@keti.re.kr