Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse...

38
End-to-end IoT solutions with Java and the Eclipse IoT stack

Transcript of Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse...

Page 1: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

End-to-end IoT solutionswith Java and theEclipse IoT stack

Page 2: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

IoT is Big

Page 3: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors
Page 4: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Open IoT Stack for Java

Page 5: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

End-to-end IoT?

Actuators/Sensors+

Gateway+

[ Cloud ]+

User front-end

Page 6: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

1. Sensors/Actuators

➔ Sense the physical environment➔ Act on it

Page 7: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

1. Sensors/Actuators

➔ Sense the physical environment➔ Act on it

That was easy, eh?

Page 8: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

1. Sensors/Actuators

➔ Manipulate sysfs directly➔ Use Pi4J to have full support of

GPIO/I2C/SPI➔ Device I/O API with Java or Java ME

Page 9: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Sensors/Actuators

➔ Pi4J – http://pi4j.com ✓ Complete access to GPIOs/I2C/SPI✓ Very mature codebase, based on WiringPi✓ Support for popular shields (PiFace,

Gertboard, …)✓ Lots of code samples

Page 10: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Pi4J in action

Gp o on o e p o Gp oFa o . e Ins an e();

Gp oP nD a Ou pu p n p o.p o s onD a Ou pu P n(

Rasp P n.GPIO_01, "M LED", P nS a e.HIGH);

Th ead.s eep(5000);

p n. ow();

Th ead.s eep(5000);

p n. o e();

p o.shu down();

Page 11: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Gateway

Page 12: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Gateway

Page 13: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Gateway

Page 14: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Gateway

Connectsensors to the world

Manage the hardware and software running at

the edge

Page 15: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Connect?

➔ CoAP✓ « HTTP over UDP »✓ Expose your device as a resource to the

Internet of Things➔ MQTT

✓ Publish/Subscribe model✓ More room for local processing

Page 16: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

CoAP: The web-of-things

/walk/hand/left/raise/eye/picture

/on/red/green/blue/mtbf

/on

/on

/buttons/buttons/1/push/bat-level

/engine/status/position/fuel /CO2

/noise/lights/on

Page 17: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Eclipse Californium

➔ Focus on scalability and usability➔ To be used in IoT cloud servers or

M2M/IoT devices running Java➔ Includes DTLS implementation

(Scandium),HTTP/CoAP bridge, Plugtests, …

Page 18: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Californium 101

oapSe e , oapResou e, oapEx han e

1. Implement custom resources (extend oapResou e)

2. Add resources to the CoAP server3. Start the server

Page 19: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Californium 101mpo s a o .e pse. a o n um. o e. oap. oAP.Response ode.*; // sho u spub ass M Resou e ex ends oapResou e { @O e de pub o d hand eGET( oapEx han e ex han e) {

ex han e. espond("he o wo d"); // ep w h 2.05 pa oad ( ex /p a n) } @O e de pub o d hand ePOST( oapEx han e ex han e) {

ex han e.a ep (); // ma e a sepa a e esponse (ex han e. e Reques Op ons() ...) {

// do some h n spe o he eques op ons}ex han e. espond( REATED); // ep w h esponse ode on (sho u )

}}

Page 20: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

MQTT: Publish & Subscribe

Sub KETTLE232/#Pub KETTLE232/temp

Payload: 21°C

Pub KETTLE232/temp

Payload: 21°CBROKER

Page 21: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Eclipse Paho

➔ Open-source MQTT clients➔ Pick your language!

✓ Java✓ JavaScript✓ C/C++, Objective C✓ Go, Lua, Python, .NET, WinRT, …

Page 22: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Paho 101 (Java)Mq en new Mq en (" p:// o .e pse.o :1883", Mq en . ene a e en Id());mq en .se a ba (new Mq a ba () { @O e de pub o d messa eA ed(S n op , Mq Messa e messa e) h ows Ex ep on { // p o ess e e ed messa e // ... }});mq en . onne ();mq en .subs be("m a ewa / ");

Page 23: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

MQTT brokers

➔ Eclipse Mosquitto✓ C implementation✓ Scalable (1000 clients == 3MB RAM)

➔ Eclipse Moquette✓ Java implementation✓ Based on Netty and LMAX disruptor

Page 24: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Manage?

➔ Gateway itself✓ wireless modem, firewall, …

➔ Applications✓ Install/Uninstall software packages✓ Start/Stop applications

➔ Sensors✓ H/W abstraction layer

Page 25: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Java VMOSGi Application Container

Device Abstraction

Gateway Basic Services

Network ConfigurationNetwork Management Field Protocols

Connectivity and Delivery

Adm

inis

trat

ion

GUI

Ope

ratio

n &

Man

agem

ent

LinuxHardware

App 1 App 2 App n. . . . Applications

Eclipse Kura

Page 26: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Installing Kurad ~

sudo ap - e upda e

w e h ps://s3.amazonaws. om/ u a_down oads/ aspb an/ e ease/1.1.0/ \ u a_1.1.0_ aspbe -p _a m 6.deb

sudo dp - u a_1.1.0_ aspbe -p _a m 6.deb

sudo ap - e ns a -

sudo eboo

Page 27: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

First steps with Kura

➔ Network management✓ Cellular Modem, WiFi✓ Firewall✓ NAT

➔ OSGi and system administration➔ IoT server communication settings

Page 28: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Kura API

➔ OSGi services that you can re-use in your own components✓ o Se e✓ Da aSe e, oudSe e✓ p oSe e (AES, base64, SHA-1)✓ Pos onSe e (geolocation)✓ … and many others

Page 29: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Demo time!

Page 30: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Practical example: Greenhouse

➔ A Senso Se e implementation leveraging Pi4J for GPIO/I2C

➔ A configurable G eenhousePub she component that:✓ consumes a Senso Se e (GPIO manipulation)✓ consumes a Da aSe e (MQTT communication)✓ exposes a Senso han edL s ene (be notified of

external GPIO updates)✓ exposes configuration metadata (Web UI config)

Page 31: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Talk is cheap…Show me the code!

Page 32: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

And how about CoAP?

➔ Californium can easily be embedded in a Kura bundle

➔ Another OSGi component can:✓ consume the Senso Se e ✓ expose CoAP resources

⚠ You need to open port 5683 in Kura!

Page 33: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

End-user interaction

➔ JavaFX Charts

➔ Eclipse BIRT

➔ Smartphone app (e.g Android)✓ https://www.eclipse.org/paho/clients/android

➔ MQTT + WebSockets = ♡✓ https://www.eclipse.org/paho/clients/js

Page 34: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

If you had to remember only 3 things...

Kura is awesome!Go download it now!

http://eclipse.org/kura

#1

Page 35: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

If you had to remember only 3 things...

Build your own greenhouse &follow the tutorial

http://iot.eclipse.org/java/tutorial

#2

Page 36: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

If you had to remember only 3 things...

Eclipse Open IoT Stack for Java is much more than Kura

http://iot.eclipse.org/java

#3

Page 37: Eclipse IoT stack with Java and the End-to-end IoT solutions IoT... · with Java and the Eclipse IoT stack. IoT is Big. Open IoT Stack for Java. End-to-end IoT? Actuators/Sensors

Get Involved!