IoT Getting Started with Intel® IoT Devkit

74
Getting Started with Intel® IoT Devkit Dr. Matthias Hahn Moscow Hackathon November 22-23 2014

description

Intel®Edison Intel® IoTDeveloper Kit Overview HW components Arduino* andLinux native programming Intel® IoTCloud Analytics

Transcript of IoT Getting Started with Intel® IoT Devkit

Page 1: IoT Getting Started with Intel® IoT Devkit

Getting Started with Intel® IoT Devkit

Dr. Matthias Hahn

Moscow Hackathon

November 22-23 2014

Page 2: IoT Getting Started with Intel® IoT Devkit

Agenda

Intel® Edison

Intel® IoT Developer Kit Overview

HW components

Arduino* and Linux native programming

Intel® IoT Cloud Analytics

* Other names and brands may be claimed as the property of others.

Page 3: IoT Getting Started with Intel® IoT Devkit

Intel® IoT Developer KitOverview

Page 4: IoT Getting Started with Intel® IoT Devkit

Important Ingredients

Development

• IDEs

Target Images

• libmraa: IO abstraction

• UPM: sensor repo

• iotkit-agent

Cloud

• Intel® IoT Analytics

Hardware

• Intel® Galileo or Intel® Edison

• Grove Sensor Kit

Page 5: IoT Getting Started with Intel® IoT Devkit

Arduino* Visual Programming

Node.JS C / C++

Target Audience

Maker Beginner Intermediate Advanced

IDE Arduino* IDE Intel® XDK Eclipse* IDE

Supporting you

Win/ Mac/ Linux

Wyliodrin*

Win/ Mac/ Linux Win/ Mac / LinuxBrowser platform

Page 6: IoT Getting Started with Intel® IoT Devkit

Intel® Galileo Gen 1 & 2

Board

Intel® EdisonArduino

Development Board

Yocto* based Linux OS image

API Bindings C/C++, Node JS, Python

UPM (Sensor/Actuator library repository)LibMraa

NodeJSsupport

C/C++ Tool Chains

Wyliodrin* agent

Ha

rd W

are

Ta

rge

t S

W

Intel® XDK IoT Edition

Eclipse* IDE Wyliodrin*

(Visual

Programming)IDE

Arduino* IDE

IoT Developing

Sensors / Actuators

* Other names and brands may be claimed as the property of others.

Page 7: IoT Getting Started with Intel® IoT Devkit

Boards

Page 8: IoT Getting Started with Intel® IoT Devkit

Intel® Galileo Development Board – Gen 2

Board I/O:

Mechanically compatible with Arduino* Uno* 20 digital input/output pins including 6 pins as PWM

outputs

6 analog inputs

2 UART (RX/TX)

1 I2C

1 ICSP 6-pin header (SPI)

USB device connector (Host)

Micro USB device connector (client)

SD Card connector

DC power jack (7V – 15V DC input)

* Other names and brands may be claimed as the property of others.

Page 9: IoT Getting Started with Intel® IoT Devkit

Intel® Edison - Mechanical Layout

Top Side Bottom Side

4 GB

eMMC Intel® SoC /

1GB LPDDR3

WiFi /BT

PMIC

USB

ULPI

70

pin

con

ne

cto

r

an

ten

na

Extern Coax

35

.5 m

m

25mm

Page 10: IoT Getting Started with Intel® IoT Devkit

Intel® Edison

Board

• 2 Intel® Atom™ cores @ 500 MHz

• 1 Intel® Quark™ MCU @ 100 MHz

• 35.5 × 25.0 × 3.9 mm

• 1 GB RAM (LPDDR3, 2ch @ 800 MT/s)

• 4 GB eMMC

• WiFi (a/b/g/n) + BT 4.0 + antenna

• 40 GPIOs : UART, I2C, SPI, I2S, PWM,

USB 2.0, SD card, clock out, GPIO

Software

• Default OS: Yocto* 1.6 Linux*

• Right now 3.10.17 kernel

• OTA upgradable

• libmraa: GPIO abstraction layer

• UPM repository: sensor libraries

* Other names and brands may be claimed as the property of others.

Page 11: IoT Getting Started with Intel® IoT Devkit

Caveats – Intel® Edison

• Not latest libmraa / UPM?

• Rootfs

• Partition too small?

• Partition empty?

• Wireless

• interfaces not available?

• xyz not supported?

• LE not supported?

Page 12: IoT Getting Started with Intel® IoT Devkit

Expansion Boards

PartnerExpansion Boards

Intel Expansion Boards

Built to OrderExpansion Boards

Page 13: IoT Getting Started with Intel® IoT Devkit

Extension Boards

Intel® Edison

• 70 pin connector

• Hirose DF40 Series

• Easy to build your own board

Intel currently offers 2 boards

• Breakout Board

• Arduino* expansion board

* Other names and brands may be claimed as the property of others.

Page 14: IoT Getting Started with Intel® IoT Devkit

Intel® Edison – Arduino* Expansion Board

• Arduino* Uno compatibility (except 4 rather 6 PWM)

• 20 digital GPIO (incl 4 PWM)

• 6 analog inputs

• 1 UART (RX/TX)

• 1 I2C

• 1 ICSP 6-pin header (SPI)

• switchable: Micro USB device | USB host

• Micro USB device (UART)

• Mini SD Card connector

• DC power jack (7V – 15V DC input)* Other names and brands may be claimed as the property of others.

Page 15: IoT Getting Started with Intel® IoT Devkit

Intel® Edison Breakout Board

• I/O: array of through-hole solder points

• USB OTG with USB Micro (AB)

• Battery charger

• USB micro (B) [UART]

• DC power supply jack (7 to 15 VDC)

Page 16: IoT Getting Started with Intel® IoT Devkit

Partner Expansion BoardsExpl: Sparkfun* Boards

* Other names and brands may be claimed as the property of others.

Page 17: IoT Getting Started with Intel® IoT Devkit

Grove* Starter Kit Intel® IoT version

Page 18: IoT Getting Started with Intel® IoT Devkit

Grove* Starter Kit Plus - Intel® IoT Version

1 Base Shield v2

2 Grove - Buzzer V1.1

3 Grove – Button

4 Grove-LED v1.3

5Grove - Sound Sensor_V1.2

6 Grove - Rotary Angle Sensor

7 Grove-Touch Sensor

8 Grove - Smart Relay

9 Grove-Light Sensor

10 Grove - Temperature Sensor_V1.1

11 26AWG Grove Cable

12 Mini Servo

13 9V to Barrel Jack Adapter - 126mm

14 DIP LED Blue-Blue

15 DIP LED Green-Green

16 DIP LED Red-Red

11 Grove - LCD RGB Backlight

USB, serial and Ethernet

cables

Page 19: IoT Getting Started with Intel® IoT Devkit

Setting up the developer environment

Page 20: IoT Getting Started with Intel® IoT Devkit

Now connect your environment

Intel® Galileo / Intel® Edison

For Windows*: first install driver from USB stick

Ref.: https://communities.intel.com/docs/DOC-23147

Serial 115200

Serial 9600

Page 21: IoT Getting Started with Intel® IoT Devkit

Connect board via serial – discover port (Windows*)

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 22: IoT Getting Started with Intel® IoT Devkit

Connect via serial e.g. using PuTTy*, goSerial* or minicom* resp

User: root, no password* Other names and brands may be claimed as the property of others.

Page 23: IoT Getting Started with Intel® IoT Devkit

Connecting Intel(R) Galileo

Wifi

connmanctl, rfkill, wpa_cli, hostapd_cli

Bluetooth

connmanctl, rfkill, bluetoothctl, hciconfig, hcidump, btmon

serial

Page 24: IoT Getting Started with Intel® IoT Devkit

Connecting Intel(R) Edison

On Windows* - first install driver from USB stick

“configure_edison --setup”

• One central way to set hostname, password and configure wifi

Wifi

connmanctl, rfkill, wpa_cli, hostapd_cli

Bluetooth

connmanctl, rfkill, bluetoothctl, hciconfig, hcidump, btmon

Eth over USB

serial

* Other names and brands may be claimed as the property of others.

Page 25: IoT Getting Started with Intel® IoT Devkit

Find your Galileo/Edison IP address and write it down: command `ip a`

Ping between board and your laptop to check

connectivity

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 26: IoT Getting Started with Intel® IoT Devkit

Programming

Page 27: IoT Getting Started with Intel® IoT Devkit

Arduino* IDE for Intel® Edison

* Other names and brands may be claimed as the property of others.

Page 28: IoT Getting Started with Intel® IoT Devkit

Arduino* IDE

Sketch

/sketch/sketch.elf

• Cross compiler

• clloader listening on

/dev/ttyGS0

• Upload via serial

• Renaming existing

sketch.elf

* Other names and brands may be claimed as the property of others.

Page 29: IoT Getting Started with Intel® IoT Devkit
Page 30: IoT Getting Started with Intel® IoT Devkit

Go to IDZ IoT page, find your sensor

Page 31: IoT Getting Started with Intel® IoT Devkit

Under References, follow Grove Wiki

Page 32: IoT Getting Started with Intel® IoT Devkit

Recap – navigating IDZ IoT - https://software.intel.com/iot

Page 33: IoT Getting Started with Intel® IoT Devkit

libmraa & UPM

Page 34: IoT Getting Started with Intel® IoT Devkit

libmraa - https://github.com/intel-iot-devkit/mraa

IO abstraction layer (C, C++, Python, Node.JS)

Used by

• UPM

• Intel(R) XDK for IoT

• Wyliodrin*

API documentation http://iotdk.intel.com/docs/master/mraa/

* Other names and brands may be claimed as the property of others.

Page 35: IoT Getting Started with Intel® IoT Devkit

Libmraa - C APIExpl: switch on GPIO #8

mraa_gpio_context gpio; // Pointer to GPIO context

gpio = mraa_gpio_init(8); // Create GPIO context for pin 8

mraa_gpio_dir(gpio, MRAA_GPIO_OUT); // GPIO direction: out

mraa_gpio_write(gpio, 1); // Write to GPIO

mraa_gpio_close(gpio); // Close GPIO

Page 36: IoT Getting Started with Intel® IoT Devkit

Libmraa - C++Expl: read analogue value on A0

mraa::Aio* a0;

a0 = new mraa::Aio(0); // Create AIO object for pin 0

std::cout << a0->read() << std::endl;

Page 37: IoT Getting Started with Intel® IoT Devkit

Libmraa – Object API (Python)Expl: interrupt triggered on IO #6

from mraa import * # Import mraa library

# define a callback function

def my_isr():

print("Button pressed")

x = Gpio(6) # Create a GPIO object for pin 6

x.dir(DIR_IN) # Set GPIO direction to input

x.isr(EDGE_BOTH, my_isr) # Set callback on BOTH

Page 38: IoT Getting Started with Intel® IoT Devkit

Libmraa – Object API (Node.js)Expl: did we have this? – switch on IO #8

var m = require("mraa") # Import mraa module

var x = new m.Gpio(8) # Create a GPIO object for pin 8

x.dir(m.DIR_OUT) # Set GPIO direction to output

x.write(1) # Write to GPIO

Page 39: IoT Getting Started with Intel® IoT Devkit
Page 40: IoT Getting Started with Intel® IoT Devkit

UPM repository - https://github.com/intel-iot-devkit/upm

List of supported sensors in C++

API documentation - http://iotdk.intel.com/docs/master/upm/

Examples directory

C++ example:

// Copyright (c) 2014 Intel Corporation. MIT license

upm::GroveTemp* s = new upm::GroveTemp(0);

std::cout << s->name() << std::endl;

for (int i=0; i < 10; i++) {

std::cout << s->value() << std::endl;

sleep(1);

}

Page 41: IoT Getting Started with Intel® IoT Devkit

UPM API documentation – which library to use?

Page 42: IoT Getting Started with Intel® IoT Devkit

Updating libmraa / UPM

cat > /etc/opkg/mraa-upm.conf <<EOF

src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic

EOF

opkg update

opkg upgrade

* Other names and brands may be claimed as the property of others.

Page 43: IoT Getting Started with Intel® IoT Devkit

Eclipse* IDE

* Other names and brands may be claimed as the property of others.

Page 44: IoT Getting Started with Intel® IoT Devkit
Page 45: IoT Getting Started with Intel® IoT Devkit
Page 46: IoT Getting Started with Intel® IoT Devkit

Eclipse(C/C++) – setting up

Copy to your computer

Extract the file you copied previously (iotdk-ide-${yourOS}.7z) with 7z

Treats long paths better, needed for this file.

If you need to download: http://www.7-zip.org/

Note: Better to extract the file to C:\ on Windows

Execute devkit-launcher.bat

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 47: IoT Getting Started with Intel® IoT Devkit

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 48: IoT Getting Started with Intel® IoT Devkit

Click on Remote System Explorer

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 49: IoT Getting Started with Intel® IoT Devkit

Fill the IP address on (3)

Ref.: https://software.intel.com/en-us/iot-c-eclipse

Page 50: IoT Getting Started with Intel® IoT Devkit

Intel(r) XDK for IoT

Page 51: IoT Getting Started with Intel® IoT Devkit

Login/create your account

Page 52: IoT Getting Started with Intel® IoT Devkit

Start with a Sample (under IoT Projects) – click on “Use this Template”

Page 53: IoT Getting Started with Intel® IoT Devkit

Should look like this

Page 54: IoT Getting Started with Intel® IoT Devkit

Select Galileo/Edison board

You might have to restart xdk-

daemon (systemctl restart xdk-

daemon)

Page 55: IoT Getting Started with Intel® IoT Devkit

Toggle the console

Page 56: IoT Getting Started with Intel® IoT Devkit

sync host / target time if needed

Page 57: IoT Getting Started with Intel® IoT Devkit

Install / build

Page 58: IoT Getting Started with Intel® IoT Devkit

Upload to target

Page 59: IoT Getting Started with Intel® IoT Devkit

run on target

Page 60: IoT Getting Started with Intel® IoT Devkit

Wyliodrin*

* Other names and brands may be claimed as the property of others.

Page 61: IoT Getting Started with Intel® IoT Devkit

Ex: programming via cloud with www.wyliodrin.com

Page 62: IoT Getting Started with Intel® IoT Devkit
Page 63: IoT Getting Started with Intel® IoT Devkit
Page 64: IoT Getting Started with Intel® IoT Devkit

Please name your board and select Intel Galileo and press Next

Page 65: IoT Getting Started with Intel® IoT Devkit

Cable (Ethernet) WiFi

Page 66: IoT Getting Started with Intel® IoT Devkit

Your SD Card is already with the Galileo Image, so all you need to do is to download (1) wyliodrin.jsonand (2) write it on the root of the SD Card. Make sure the name is exactly wyliodrin.json

1

2

Page 67: IoT Getting Started with Intel® IoT Devkit

Install the updates and the extra libraries. This make take some time to run

Page 68: IoT Getting Started with Intel® IoT Devkit
Page 69: IoT Getting Started with Intel® IoT Devkit

Intel® IoT Analytics www.enableiot.com

Page 70: IoT Getting Started with Intel® IoT Devkit

Intel® IoT Analytics - www.enableiot.com

RESTful API

iotkit-agent (UDP / TCP)

#! /usr/bin/env python

import socket

import sys

UDP_PORT = 41234

sock = socket.socket(socket.AF_INET,

socket.SOCK_DGRAM)

sock.sendto('{"n":"' + component +

‘","v":"' + value + '"}', ('localhost', UDP_PORT))

Page 71: IoT Getting Started with Intel® IoT Devkit

Login to IoT Analytics

Login in to Intel® IoT Analytics Cloud

https://dashboard.us.enableiot.com

Various login options

Page 72: IoT Getting Started with Intel® IoT Devkit

Next steps?

Page 73: IoT Getting Started with Intel® IoT Devkit
Page 74: IoT Getting Started with Intel® IoT Devkit