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
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!
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
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?
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?
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 6
A cool UI?
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?
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 8
Some things?
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 :-)
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?
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 12
Lego® Train
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#)
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 :-)
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
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 17
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 18
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 19
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 20
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 21
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 22
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 23
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 24
Lego® Engineering
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 25
Lego® VIP member
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
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
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
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
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
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
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 33
Lego® Infrared protocol?
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
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
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
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
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
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
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
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 42
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 43
Fritzing
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 44
Fritzing
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 45
Fabricate
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 47
fritzing.org
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
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 50
Deployment model
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 51
SignalSegmentImpl
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 52
Problems
Problems?
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!
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 55
Extensions
Extensions?
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
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
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
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
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
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!
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
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
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
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
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 66
Extensions - Hardware refactoring
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 67
Summary
Summary
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?
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 69
Q & A
Questions?
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 70
Q & A
Copyright © 2005 - 2016 Paremus Ltd.May not be reproduced by any means without express permission. All rights reserved.October 2016 71
Q & A
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
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]
http://fritzing.org/projects/raspberry-pi-rfidmotorled-driver
https://github.com/osgi/osgi.iot.contest.sdk
Top Related