How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

73
Copyright © 2005 - 2016 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved. October 2016 www.paremus.com OSGi Community Event 2016 co-located at EclipseCon Europe 2016 How to build an effective IoT demo with OSGi

Transcript of How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Page 1: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 www.paremus.com

OSGi Community Event 2016co-located at

EclipseCon Europe 2016

How to build an effective IoT demo with OSGi

Page 2: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 2

about: me [email protected]

• Studied Electronic Engineering

• Only ever worked as a Software Engineer:- Unix - 1980- System III, System V, Solaris

- C/C++ - 1982-

- Linux - 1990- 0.9

- Java - 1995- 1.0

- OSGi - 2006- R4

• Until IoT came along..- First time I’ve used a soldering iron for over 30 years!

Page 3: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 www.paremus.com

OSGi IoT Demo

Brought to you by

Page 4: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 4

about: presentation

• What makes an effective IoT demo?

• Bottom-up review of OSGi IoT demo:- Mechanical Engineering (Lego®)- Electronic Engineering (Things)- Software Engineering (OSGi)

• Problems encountered• Resolutions & extensions• Questions?

Page 5: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 5

What makes an effective IoT demo?

• A cool UI?

Page 6: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 6

A cool UI?

Page 7: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 7

What makes an effective IoT demo?

• A cool UI?

• or some Things?

Page 8: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 8

Some things?

Page 9: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 9

What makes an effective IoT demo?

• A cool UI?

• or some Things?Things are more compelling as you can see them physically doing stuff.Things draw attention to your demo/product.You can then demonstrate your cool UI :-)

Page 10: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 10

June 2015: Radio Controlled Cars?

Page 11: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 11

July 2015: Remote Controlled Trains?

• Goal – Demonstrate OSGi as a viable technology to control low level IO on the device and high level control in the cloud

Page 12: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 12

Lego® Train

Page 13: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 13

Lego® Train: Actuators & Sensors

What actuators & sensors do we need?

• Actuators - perform some action (write-only)

- setSpeed(train#, speed)

- setLight(train#, on_off)

- setTrackSwitch(switch#, normal_alternate)

- setSignal(signal#, colour)

• Sensors - report some status (read-only)

- getLocation(train#)

Page 14: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 14

Lego® Train: What’s in the box?

• Working system:

• Infrared remote controlled battery-powered train

- 4 channel, capable of controlling speed and lights of 4 trains

✓setSpeed()

✓setLight()

• Track

• Lego® bricks :-)

Page 15: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 15

Lego® Train: What’s missing?

• Track signals

• Track switch actuators

• Train location sensors

Page 16: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 16

Hardware Engineering

Lego® Engineering

Page 17: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 17

Lego® Engineering

Page 18: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 18

Lego® Engineering

Page 19: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 19

Lego® Engineering

Page 20: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 20

Lego® Engineering

Page 21: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 21

Lego® Engineering

Page 22: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 22

Lego® Engineering

Page 23: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 23

Lego® Engineering

Page 24: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 24

Lego® Engineering

Page 25: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 25

Lego® VIP member

Page 26: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 26

Lego® Train: What’s missing?

✓Track signals

✓Track switch actuators

✗Train location sensors

Page 27: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 27

Electronic Engineering

Thing Engineering

Page 28: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 28

Train location sensors?

• No Lego® location sensors available :-(

• Mechanical or magnetic switches?

- too low tech?; can’t distinguish multiple trains

• Scan barcode on train?

- TBD

• Read RFID tag on train?

- cheap RFID readers available

- use 6 fixed readers and an RFID tag on each train

Page 29: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 29

MF-RC522 RFID reader

Page 30: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 30

MF-RC522 RFID reader - testing

Page 31: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 31

Lego® Train: What’s missing?

✓Track signals

✓Track switch actuators

✓Train location sensorsMF-RC522 RFID readers seem to work OK• supported on Raspberry PI using SPI bus• tested using Python RFID reader program• range not great, 1-2cm, but should be OK

Page 32: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 32

Actuator & sensors

• Train speed & lights - infrared

• Track signals - high power LEDs

• Track switch actuators - Lego® motors

• Train location sensors - RFID

Page 33: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 33

Lego® Infrared protocol?

Page 34: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 34

Lego® Infrared protocol?

Protocol consists of 38 kHz cycles:Low bit length = 16 x 1/38K = 421 usHigh bit length = 27 x 1/38K = 711 usStart bit length = 45 x 1/38K = 1184 usStop bit length = 45 x 1/38K = 1184 us

sub-ms timings require some real-time capability

Page 35: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 35

LIRC - www.lirc.com

Page 36: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 36

LIRC <-> Lego® RC

• LIRC enables control of Lego® RC functions simply by writing the correct sequence of “pulses” to /dev/lirc0.

• We converted an example C program into Java- http://www.nishioka.com/train/control.c

Page 37: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 37

Actuator & sensor drivers?

• Raspberry Pi GPIO cannot drive high-power LEDs or motors

• We need to use “driver” chips

Raspberry Pi GPIO connector

Page 38: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 38

LED driver: ULN2003A €0.50

Page 39: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 39

Motor driver: SN754410 €2.00

Page 40: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016

IoT Demo Dual Segment Controller Hardware 20-July-2015

2 x MF-RC522 RFID Readerconnected to GPIO SPI Bus

ULN2003ALED driver for signals

Raspberry Pi 2 GPIO connector

Motor driver for track switches

40

Dual segment driver

Page 41: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 41

Attach to Raspberry Pi

Page 42: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 42

Page 43: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 43

Fritzing

Page 44: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 44

Fritzing

Page 45: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 45

Fabricate

Page 46: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 46

Attach to Raspberry Pi

Page 47: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 47

fritzing.org

Page 48: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 48

Software Engineering

OSGi Engineering

Page 49: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 49

Service model

Remote services

Page 50: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 50

Deployment model

Page 51: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 51

SignalSegmentImpl

Page 52: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 52

Problems

Problems?

Page 53: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 53

Problems: RFID readers

MF-RC522 RFID readers seem to work OK• range not great, 1-2cm, but should be OK

Not OK!• unreliable, many not working at all• range insufficient for reliable train detection• help!

Page 54: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 54

Problems: RFID readers

•Use mechanical micro-switches instead of RFID

•Detect micro-switches by creating code to read GPIO pin

Page 55: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 55

Extensions

Extensions?

Page 56: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 56

RFID #2

Despite failure of RFID#1, it still seemed like the most viable detection mechanism.Previously, we did not research available RFID devices, and just used the cheapest, most readily available device.RFID#2• use a better RFID reader• mount reader on train• use multiple passive RFID tags on track

Page 57: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 57

RFID #2 - Better RFID Reader

• use a better RFID reader• RMD6300• works at 125kHz vs

13Mhz for old reader• provides serial output• still cheap: €5

Page 58: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 58

RFID #2 - Expensive Tags - >€1.00 each

Page 59: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 59

RFID #2 - Cheap Tags - €0.10 each

Page 60: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 60

RFID #2 - Perfect Tags - <€0.50 each

Page 61: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 61

RFID #2 - Better RFID Reader

• Produces serial output• How to mount in train?• Use bluetooth!

Page 62: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 62

RFID #2 - Mount on train

Page 63: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 63

RFID #2 - Mount on train

Page 64: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 64

RFID #2 - Mount on train

Page 65: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 65

Service model

Kura

MQTT

Page 66: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 66

Extensions - Hardware refactoring

Page 67: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 67

Summary

Summary

Page 68: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 68

Summary

• What makes an effective IoT demo?

• Bottom-up review of OSGi IoT demo:- Mechanical Engineering (Lego®)- Electronic Engineering (Things)- Software Engineering (OSGi)

• Problems encountered• Resolutions & extensions• Questions?

Page 69: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 69

Q & A

Questions?

Page 70: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 70

Q & A

Page 71: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 71

Q & A

Page 72: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd. May not be reproduced by any means without express permission. All rights reserved.

OSGi Community Event Nov 2016

Interim Title Slide

Page 73: How to build an effective IoT demo with OSGi - Derek Baum & Walt Bowers

Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 73

www.paremus.com @Paremus [email protected]

[email protected]

http://fritzing.org/projects/raspberry-pi-rfidmotorled-driver

https://github.com/osgi/osgi.iot.contest.sdk