Building the
Internet of Things
with Eclipse IoT
Benjamin Cabé – Eclipse Foundation
@kartben
Devoxx France - April 10, 2015
Java for IoT?
● 9+ million Java developers
● Java 8 & embedded are fun
● Lots of IoT devices running on ARM
● Tooling
End-to-end IoT?
End-to-end IoT?
End-to-end IoT?
End-to-end IoT?
Talking to sensors?
● 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
Talking to sensors?
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();
Gateway
Gateway
Gateway
Gateway
Connect
sensors to the world
Manage the hardware
and software running
at the edge
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
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
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, …
http://eclipse.org/californium
import static org.eclipse.californium.core.coap.CoAP.ResponseCode.*;
public class MyResource extends CoapResource {
@Override
public void handleGET(CoapExchange exchange) {
exchange.respond("hello world"); // reply with 2.05 payload (text/plain)
}
@Override
public void handlePOST(CoapExchange exchange) {
exchange.accept(); // make it a separate response
if (exchange.getRequestOptions() ...) {
// do something specific to the request options
}
exchange.respond(CREATED); // reply with response code only (shortcut)
}
}
MQTT: Publish & Subscribe
Sub
KETTLE232/#Pub
KETTLE232/temp
Payload:
21°C
Pub
KETTLE232/temp
Payload:
21°C
BROKER
Eclipse Paho
● Open-source MQTT clients
● Pick your language!
○ Java
○ JavaScript
○ C/C++, Objective C
○ Go, Lua, Python, .NET, WinRT, …
http://eclipse.org/paho
MqttClient c = new MqttClient("tcp://m2m.eclipse.org:1883",
MqttClient.generateClientId());
mqttClient.setCallback(new MqttCallback() {
@Override
public void messageArrived(String topic, MqttMessage message)
throws Exception {
// process received message
// ...
}
});
mqttClient.connect();
mqttClient.subscribe("mygateway/#");
MQTT brokers
● Eclipse Mosquitto
○ C implementation
○ Scalable (1000 clients == 3MB RAM)
● Eclipse Moquette
○ Java implementation
○ Based on Netty and LMAX disruptor
Manage?
● Gateway itself
○ wireless modem, firewall, …
● Applications
○ Install/Uninstall software packages
○ Start/Stop applications
● Sensors
○ H/W abstraction layer
Java VM
OSGi Application Container
Device Abstraction
Gateway Basic Services
Network Configuration
Network Management Field
Protocols
Connectivity and Delivery
AdministrationGUI
Operation&Management
Linux
Hardware
App 1 App 2 App n. . . .
Applications
Eclipse Kura
Installing Kura
cd ~
sudo apt-get update
wget https://s3.amazonaws.com/kura_downloads/raspbian/release/ 
1.1.0/kura_1.1.0_raspberry-pi_armv6.deb
sudo dpkg -i kura_1.1.0_raspberry-pi_armv6.deb
sudo apt-get install -f
sudo reboot
First steps with Kura
● Network management
○ Cellular Modem, WiFi
○ Firewall
○ NAT
● OSGi and system administration
● IoT server communication settings
First steps with Kura
First steps with Kura
First steps with Kura
First steps with Kura
First steps with Kura
First steps with Kura
First steps with Kura
First steps with Kura
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
● And of course you can leverage a huge
ecosystem of Java and OSGi libraries
Your typical Kura component
● Uses Modbus, CAN-Bus, etc. built-in device
abstraction services
○ Or implement your own service
Your typical Kura component (2)
• Uses Kura built-in transport services to talk to
the cloud
– TransportService – « raw » protocol
– DataService – local storage, auto reconnect
– CloudService – optimized binary payload, advanced
device management
Your typical Kura component (3)
• Implements ConfigurableComponent
– Enables configuration from the UI
– … as well as from the cloud
Your typical Kura component (4)
• Bundled with other bundles/components in a
deployment package
– Zip file containing a Manifest & OSGi bundles
• Can be deployed from Kura Web UI or over the air
Read more:
http://eclipse.github.io/kura/doc/kura-setup
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
Kura is awesome!
Go download it now!
http://eclipse.org/kura
If you had to remember only 3 things...
#1
Build your own greenhouse &
follow the tutorial
http://iot.eclipse.org/java/tutorial
If you had to remember only 3 things...
#2
Eclipse IoT is much more than
Kura and Java!
http://iot.eclipse.org/
If you had to remember only 3 things...
#3
Get Involved!
● Open bugs / fix bugs
● Request new features
● Write articles, tutorials
● Participate on the mailing
lists
● Propose your project!
Coming next?
Coming next?
● Device Management
○ LwM2M, LwM2M over MQTT, IPSO Smart Objects
● Security
○ TinyDTLS
● Open-source IoT server?
○ Several members interested in defining and
implementing the OpenStack for IoT
Thank you! Questions?
benjamin@eclipse.org
@kartben
http://iot.eclipse.org

Devoxx 2015 - Building the Internet of Things with Eclipse IoT

  • 1.
    Building the Internet ofThings with Eclipse IoT Benjamin Cabé – Eclipse Foundation @kartben Devoxx France - April 10, 2015
  • 9.
    Java for IoT? ●9+ million Java developers ● Java 8 & embedded are fun ● Lots of IoT devices running on ARM ● Tooling
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
    Talking to sensors? ●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
  • 15.
    Talking to sensors? Gpo 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();
  • 16.
  • 17.
  • 18.
  • 19.
    Gateway Connect sensors to theworld Manage the hardware and software running at the edge
  • 20.
    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
  • 21.
  • 22.
    Eclipse Californium ● Focuson scalability and usability ● To be used in IoT cloud servers or M2M/IoT devices running Java ● Includes DTLS implementation (Scandium), HTTP/CoAP bridge, Plugtests, … http://eclipse.org/californium
  • 23.
    import static org.eclipse.californium.core.coap.CoAP.ResponseCode.*; publicclass MyResource extends CoapResource { @Override public void handleGET(CoapExchange exchange) { exchange.respond("hello world"); // reply with 2.05 payload (text/plain) } @Override public void handlePOST(CoapExchange exchange) { exchange.accept(); // make it a separate response if (exchange.getRequestOptions() ...) { // do something specific to the request options } exchange.respond(CREATED); // reply with response code only (shortcut) } }
  • 24.
    MQTT: Publish &Subscribe Sub KETTLE232/#Pub KETTLE232/temp Payload: 21°C Pub KETTLE232/temp Payload: 21°C BROKER
  • 25.
    Eclipse Paho ● Open-sourceMQTT clients ● Pick your language! ○ Java ○ JavaScript ○ C/C++, Objective C ○ Go, Lua, Python, .NET, WinRT, … http://eclipse.org/paho
  • 26.
    MqttClient c =new MqttClient("tcp://m2m.eclipse.org:1883", MqttClient.generateClientId()); mqttClient.setCallback(new MqttCallback() { @Override public void messageArrived(String topic, MqttMessage message) throws Exception { // process received message // ... } }); mqttClient.connect(); mqttClient.subscribe("mygateway/#");
  • 27.
    MQTT brokers ● EclipseMosquitto ○ C implementation ○ Scalable (1000 clients == 3MB RAM) ● Eclipse Moquette ○ Java implementation ○ Based on Netty and LMAX disruptor
  • 28.
    Manage? ● Gateway itself ○wireless modem, firewall, … ● Applications ○ Install/Uninstall software packages ○ Start/Stop applications ● Sensors ○ H/W abstraction layer
  • 29.
    Java VM OSGi ApplicationContainer Device Abstraction Gateway Basic Services Network Configuration Network Management Field Protocols Connectivity and Delivery AdministrationGUI Operation&Management Linux Hardware App 1 App 2 App n. . . . Applications Eclipse Kura
  • 30.
    Installing Kura cd ~ sudoapt-get update wget https://s3.amazonaws.com/kura_downloads/raspbian/release/ 1.1.0/kura_1.1.0_raspberry-pi_armv6.deb sudo dpkg -i kura_1.1.0_raspberry-pi_armv6.deb sudo apt-get install -f sudo reboot
  • 31.
    First steps withKura ● Network management ○ Cellular Modem, WiFi ○ Firewall ○ NAT ● OSGi and system administration ● IoT server communication settings
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
    Kura API ● OSGiservices 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 ● And of course you can leverage a huge ecosystem of Java and OSGi libraries
  • 41.
    Your typical Kuracomponent ● Uses Modbus, CAN-Bus, etc. built-in device abstraction services ○ Or implement your own service
  • 42.
    Your typical Kuracomponent (2) • Uses Kura built-in transport services to talk to the cloud – TransportService – « raw » protocol – DataService – local storage, auto reconnect – CloudService – optimized binary payload, advanced device management
  • 43.
    Your typical Kuracomponent (3) • Implements ConfigurableComponent – Enables configuration from the UI – … as well as from the cloud
  • 44.
    Your typical Kuracomponent (4) • Bundled with other bundles/components in a deployment package – Zip file containing a Manifest & OSGi bundles • Can be deployed from Kura Web UI or over the air Read more: http://eclipse.github.io/kura/doc/kura-setup
  • 45.
    End-user interaction ● JavaFXCharts ● Eclipse BIRT ● Smartphone app (e.g Android) ○ https://www.eclipse.org/paho/clients/android ● MQTT + WebSockets = ♡ ○ https://www.eclipse.org/paho/clients/js
  • 46.
    Kura is awesome! Godownload it now! http://eclipse.org/kura If you had to remember only 3 things... #1
  • 47.
    Build your owngreenhouse & follow the tutorial http://iot.eclipse.org/java/tutorial If you had to remember only 3 things... #2
  • 48.
    Eclipse IoT ismuch more than Kura and Java! http://iot.eclipse.org/ If you had to remember only 3 things... #3
  • 49.
    Get Involved! ● Openbugs / fix bugs ● Request new features ● Write articles, tutorials ● Participate on the mailing lists ● Propose your project!
  • 50.
  • 51.
    Coming next? ● DeviceManagement ○ LwM2M, LwM2M over MQTT, IPSO Smart Objects ● Security ○ TinyDTLS ● Open-source IoT server? ○ Several members interested in defining and implementing the OpenStack for IoT
  • 52.