raspberry pi 2 + windows 10 iot core + node.js

57
Ep.1 Developing for IoT with Web Technologies Andri Yadi CEO, DyCode

Upload: andri-yadi

Post on 11-Jan-2017

2.117 views

Category:

Software


6 download

TRANSCRIPT

Page 1: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Ep.1 Developing for IoT with Web Technologies

Andri YadiCEO, DyCode

Page 2: Raspberry Pi 2 + Windows 10 IoT Core + Node.js
Page 3: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

sponsored by

organized by

IoT4Bdg

supported by

Page 4: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Let’s talk about…

Page 5: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Andri Yadi

@andri_yadi | a at dycode dot com

http://andriyadi.me

Page 6: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

CEO of

Page 7: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

CEO of

Page 8: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Been coding in awesome languages/Frameworks for 18 years

QBasic, Pascal, c, C++, Java, PHP, Bash, C#, Visual Basic, HTML, JavaScript, Python, Objective-C, Swift

.NET, Qt/QML, Java ME/EE/SE, Android SDK, iOS SDK, Node.js, Arduino

Page 9: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

8 years in a row

Page 10: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

A custom-made, compact, autonomous machine for delivering engagements

Co-creator of

Page 11: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Inside

Page 12: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Inside

Page 13: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Disclaimer

Let’s have Fun today!

Page 14: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Disclaimer

I’ll do More demo, less Slides

Page 15: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Raspberry Pi 2

SoC: Broadcom BCM2836 (CPU, GPU, DSP, SDRAM) 900 MHz quad-core ARM Cortex A7 Memory: 1 GB (shared with GPU) GPU: Broadcom VideoCore IV @ 250 MHz Storage: MicroSD

Page 16: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Raspberry Pi 2 & GPIO

Page 17: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Raspberry Pi OS

Page 18: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

New Comer

Page 19: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Windows 10 IoT Core on Raspberry Pi 2

Page 20: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Windows 10 IoT Core Supported boards

Raspberry Pi 2 Minnowboard Max

Page 21: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

What to do after install Windows 10 IoT Core?

Code it!

Page 22: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Supported development paths

Arduino Wiring &UWP Lightning Providers

Windows Remote Arduino

Windows Virtual Shields for ArduinoNative

Page 23: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Supported development language/frameworks

Page 24: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Out focus today!

Page 25: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Why JavaScript?

Explanation in Bahasa Indonesia: http://andriyadi.me/bandung-iot-developer-day/

Page 26: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

What do you need?

tool for VS

IoT side Desktop side

NTVS IoT

Page 27: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

DemoDon’t blink!

Page 28: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Setup

GPIO 5

Page 29: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Code in Node.jsvarhttp=require('http'),uwp=require("uwp");

//EnablesUniversalWindowsPlatform(UWP)"Windows"namespacetobe //accessibleuwp.projectNamespace("Windows");

vargpioCtrl=Windows.Devices.Gpio.GpioController.getDefault();varswitchPin=gpioCtrl.openPin(5);

//SetpinasoutputswitchPin.setDriveMode(Windows.Devices.Gpio.GpioPinDriveMode.output);varcurrentValue=Windows.Devices.Gpio.GpioPinValue.high;//WriteHIGHvaluetoGPIOPIN5,tolightuptheLEDswitchPin.write(currentValue);

uwp.close();//CallthiswhenallUWPusageiscompleted.

Page 30: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

DemoSmiiiile!

Display smiley on LED matrix

Page 31: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Setup

Page 32: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Let there be a lightLet’s turn on bigger light, a light bulb

Page 33: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

1 2 3 4

A

B

C

D

4321

D

C

B

A Title

Number RevisionSizeA4

Date: 7-Oct-2015 Sheet ofFile: D:\DYCODE\Layout PCB\Demo.ddb Drawn By:

Q1TRIAC

U1

OPTOTRIAC_1

R2

1K

R1

470

LAMP

AC PLUG

GPIO

AC solid state switch

To RPi2 GPIO 5

Page 34: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

AC lamp switch setup

AC Switch

Page 35: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Motion detectedGPIO interrupt demo

Page 36: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Setup

1 2 3 4

A

B

C

D

4321

D

C

B

A Title

Number RevisionSizeA4

Date: 7-Oct-2015 Sheet ofFile: D:\DYCODE\Layout PCB\Demo.ddb Drawn By:

Q1TRIAC

U1

OPTOTRIAC_1

R2

1K

R1

470

LAMP

AC PLUG

GPIO

Page 37: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Motion CapturedAccess USB Camera

Page 38: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Setup

1 2 3 4

A

B

C

D

4321

D

C

B

A Title

Number RevisionSizeA4

Date: 7-Oct-2015 Sheet ofFile: D:\DYCODE\Layout PCB\Demo.ddb Drawn By:

Q1TRIAC

U1

OPTOTRIAC_1

R2

1K

R1

470

LAMP

AC PLUG

GPIO

Page 39: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

I made a library to Access Webcam using Node.js !

https://github.com/andriyadi/Win10IoT-AzureIotHub-SmartLamp/blob/master/SmartLamp/

lib/Camera.js

Page 40: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Control the light from Mars….or from anywhere connected to internet

Page 41: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

We need Cloud

for that…

Page 42: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

MQTT

Scenario

Raspberry Pi 2Web/desktop app

IoT Hub

AMQP/HTTP

Page 43: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

AMQP/HTTP

Scenario

MQTT

Raspberry Pi 2Web dashboard

IoT Hub

Photo storageStorage

Page 44: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Beyond BITS

Page 45: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Master (µC or µP)

SPI Serial Peripheral Interface

SCLK

MOSI

Slave (display)

Slave (sensor)

MISO

Slave (other µC)CS0CS1CSn

Page 46: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Raspberry Pi can’t read analog

as we know

Page 47: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

ADC MCP3008 via SPI

Light Sensor

Page 48: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Habis gelap, terbitlah terang….or demo to turn on the light when it’s dark,

using light sensor

Page 49: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

I made a library to read from MCP3008https://github.com/andriyadi/Win10IoT-

AzureIotHub-SmartLamp/blob/master/SmartLamp/lib/MCP3008.js

Page 50: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

All demo setup

1 2 3 4

A

B

C

D

4321

D

C

B

A Title

Number RevisionSizeA4

Date: 7-Oct-2015 Sheet ofFile: D:\DYCODE\Layout PCB\Demo.ddb Drawn By:

Q1TRIAC

U1

OPTOTRIAC_1

R2

1K

R1

470

LAMP

AC PLUG

GPIO

Sound Sensor

Current Sensor

PIR Sensor

Webcam

AC Switch

Light Sensor

Page 51: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Summary

Most common RPi features are accessible via Node.js UWP On-going project, keep checking: https://github.com/ms-iot/ntvsiot All of my demo is here: https://github.com/andriyadi/Win10IoT-AzureIotHub-SmartLamp

Page 52: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Custom IoT/hardware for your startup or any custom requirements?

[email protected]

Page 53: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

http://edu.dycode.co.id | [email protected]

a bit of ads…

Page 54: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

We contribute100+ seminars, workshops, trainings delivered

Delivered to 20+ communities, organisations,

campuses

Next event could be your event!Just drop us a message:

http://edu.dycode.co.id | [email protected]

Page 55: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Our classes

+ + [Obj-C]

+

Page 56: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Opening soon…

+

Page 57: Raspberry Pi 2 + Windows 10 IoT Core + Node.js

Thanks!Andri YadiEmail — a at dycode dot com twitter — @andri_yadi www — andriyadi.me github — github.com/andriyadi