49
ラズパイとBluemixIoTアプリを作ってみよう! 浦本直彦 吉忠 渡邉毅 IBM ソフトウエア & システム開発研究所 10/5/15 1

WWCT ラズパイ Bluemix 講習資料

Embed Size (px)

Citation preview

  • BluemixIoTIBM &

    10/5/15

    1

  • Agenda LANPC ()

    & Q&A

    10/5/15

    2

  • 10/5/15

    3

  • (Raspberry Pi) (Raspberry Pi Foundation)

    Raspberry Pi 2 Model B ARM 4 900MHz 1GB microSD LinuxOS (Windows 10 IoT Core!)

    General Purpose IO (GPIO) IoT

    : ?10/5/15

    4

  • IBM Bluemix

    5

    WebIoTPaaS

    API

    DevOps

  • Bluemix

    100179108

    Web

    Internet of Things

    Watson DevOps

    *20158

    6

  • BluemixIoTInternet of Things

    IBM IoT Foundation MQTT /MQTTIoT Foundation

    IBM Bluemix Node-RED Node-REDIoTIoT Foundation

    IBM Bluemix

    MQTT

    IBM IoTFoundation

    MQTT

    IoTMQTT

    MQTT

    MQTT

    MQTT

    MQTT

    IoT

  • 10/5/15

    8

    IBM IoTFoundation

    MQTT

    MQTT(Publish/Subscribe)

    IBM Bluemix

    Node-REDIoTMQTT

    Node-RED

  • LED (L)

    1: IoT Foundation

    2: Bluemix Node-RED

    10/5/15

    9

  • L

    10/5/15

    10

  • :

    10/5/15

    11

  • LED

    10/5/15

    12

    GPIO

  • GPIO (1 or 0) 1: +3.3v (high) 0: 0v (low)

    : GPIO41-> GPIO43.3V

    : GPIO63.3v->GPIO61

    ADon/off, on

    10/5/15

    13

    0

    1

    low

    high

  • L ()

    10/5/15

    14

    GND

    GPIO18

    #!/usr/bin/env pythonimport RPi.GPIO as GPIOimport timeGPIO.setmode(GPIO.BCM)GPIO.setup(18, GPIO.OUT)while True:

    GPIO.output(18, True)time.sleep(2)GPIO.output(18, False)time.sleep(2)

    $ sudo python lchika.py

    lchika.py

  • Raspberry PiIoTFoundation

    10/5/15

    15

  • Bluemix IoTFoundation (1)

    10/5/15

    16

    $ sudo dpkg -i iot_1.0-1_armhf.debSelecting previously unselected package iot.(Reading database ... 78520 files and directories currently installed.)Unpacking iot (from iot_1.0-1_armhf.deb) ...Setting up iot (1.0-1) ...Starting the iot program

    $ curl -LO https://github.com/ibm-messaging/iot-raspberrypi/releases/download/1.0.2/iot_1.0-1_armhf.deb% Total % Received % Xferd Average Speed Time Time Time Current .

    100 397 0 397 0 0 482 0 --:--:-- --:--:-- --:--:-- 644100 108k 100 108k 0 0 44019 0 0:00:02 0:00:02 --:--:-- 115k

  • Bluemix IoTFoundation (2)

    10/5/15

    17

    $ service iot status[ ok ] iot is running.

    stausstart, stop

    (MAC)$ service iot getdeviceidThe device ID is b837eb388edaFor Real-time visualization of the data, visit http://quickstart.internetofthings.ibmcloud.com/?deviceId=b837eb388eda

    URL

  • CPU

    10/5/15

    18

    b837eb388eda

  • Bluemix Node-RED

    10/5/15

    19

  • Bluemix

    10/5/15

    20

  • Node-RED Node-RED Starter

    10/5/15

    21

  • ()Bluemix

    10/5/15

    22

  • 10/5/15

    23

  • 10/5/15

    24

    URL

  • Node-RED Flow Go to your Node-RED flow editor

    10/5/15

    25

  • Node-RED Flow ibmiotdrag & drop

    10/5/15

    26

  • 10/5/15

    27

  • Authentication: Quickstart

    Input Type:Device Event

    Device IdID(service iot getdeviceid)

    Name

    OK

    10/5/15

    28

    b837eb388eda

  • DebugDrag & Drop

    10/5/15

    29

  • Deploy IBM IoT App InDebug

    Deploy

    10/5/15

    30

  • 10/5/15

    31

    Successfully Deployed

    debug

  • 10/5/15

    32

  • Debug ()

    10/5/15

    33

    ! Deploy

  • 10/5/15

    34

  • functionfunctionDrag & Drop

    10/5/15

    35

  • IBM IoT App In

    10/5/15

    36

  • CPU

    Name: Get CPU Temp

    Function: return {payload:msg.payload.d.cputemp};

    OK

    10/5/15

    37

  • Get CPU TempDebugDeploy

    10/5/15

    38

  • CPU CPU

    10/5/15

    39

  • Get CPU TempDebug

    switchDrap & Drop Get CPU Tempswitch

    10/5/15

    40

  • (1) Switch

    Name: Check Temp

    ==>=CPU46.1

    +rule

    10/5/15

    41

  • (2)
  • Check temp (1, 2)

    10/5/15

    43

  • 2 template2Drag & DropCheck Temp

    10/5/15

    44

  • 1function Name: High

    Template: : {{payload}}

    OK

    10/5/15

    45

  • 2function Name: Low

    Function return ;

    OK

    10/5/15

    46

  • Check Temp (1)High(2)LowDeploy

    10/5/15

    47

  • Debug 2templateDebug Deploytemplate Check Temp

    10/5/15

    48

  • Twitter

    IoT (Cloudant)

    10/5/15

    49