Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the...
Transcript of Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the...
![Page 1: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/1.jpg)
Panche Chavkovski2018-02-06 / Jfokus
The SkopjePulse.mk case
Gluing the IoT world with Java and LoRaWAN
![Page 2: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/2.jpg)
Who am I?
2
Senior Software Engineer @ netceterajug.mk Leader
Codefu.mk administratorHardware & IoT enthusiast
TTN SK Initiator
http://pance.mk/ and @hsilomedus
Panche Chavkovski
![Page 3: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/3.jpg)
3
![Page 4: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/4.jpg)
SkopjePulse
§ extreme air pollution
§ Excessive urban noise§ Flash floods
No clear means for improvement
§ Leverage technology§ Crowd-sourced sensor network§ Data analysis and availability§ Warnings§ Clearer insights§ Data-driven basis for action
https://skopjepulse.mk/faq
SolutionProblems
4
![Page 5: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/5.jpg)
System overview
Analytics
MobileappsData Storage
LoRaWAN
Devices
Data FetchingFront-end &
API
Warnings
5
!
![Page 6: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/6.jpg)
LoRaWAN
6
![Page 7: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/7.jpg)
LoRa & LoRaWAN
§ Based on FSK & CSS, multiple channels
§ Low Power§ Low Cost§ Long range
§ Free ISM bands: 433, 868, 915 MHz§ Proprietary by Semtech
§ MAC layer on top of LoRa
§ IoT communication standard
§ Standardized stack
§ Driven by LoRa Alliance
Long Range Wide Area NetworkLong Range
7
![Page 8: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/8.jpg)
Fully bi-directional
End-to-end security
Easy commisioning
Built-in positioning
Network scalability
Features
8
![Page 9: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/9.jpg)
Limitations
Low speed (default BW)§ SF12: 250bps with the farthest distance and the longest air-time§ SF7: 5470bps with the shortest distance and the shortest air-time
Small package sizes: ~1-20bytes
Less frequent§ 2-200 uplinks per day§ 1-10 downlinks per day
9
![Page 10: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/10.jpg)
LoRaWAN architecture
10
End nodes Gateway / concentrator Network server(s) Application server(s)
LoRa RFLoRaWAN
TCP/IP SSLLoRaWAN
TCP/IP SSLSecure payload
AES secured payload
![Page 11: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/11.jpg)
LoRaWAN devices
Different classes§ Class A, rare async devices (current): one uplink with two downlink windows§ Class B, always on, timed: beacon downlink windows§ Class C, always on, always listening.
Network sign on:§ Over The Air Authorization (OTAA): App EUI and Key§ Authorization By Personalization (ABP): App / Network keys and Device address
11
![Page 12: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/12.jpg)
TheThingsNetwork
12
Global, crowdsourced Internet Of Things data network
§ Community driven with local initiators and teams
§ Provided network and back-end
§ Free for fair use
§ Can be elevated to SLA (private – public partnership)
§ Multiple integration options
§ LoRaWAN as base technology
https://www.thethingsnetwork.org/
![Page 13: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/13.jpg)
How to use TTN
https://console.thethingsnetwork.org/
§ Applications§ Devices§ Keys, UIDs, Credentials
§ MQTT
§ HTTP§ Data storage§ Amazon AWS
§ Cayenne§ EVRYTHNG
IntegrationsRegistration
13
![Page 14: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/14.jpg)
Devices
14
![Page 15: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/15.jpg)
Microchip RN2483 (LoRaWAN stack)
Arduino (MCU)
RFM95W (LoRa transceiver)
El. Design & PCB CAD Software
The start up kit
15
![Page 16: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/16.jpg)
KiCAD usage
16
Scheme design
PCB design
3D render and gerbers
![Page 17: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/17.jpg)
Assembly
17
PCB fabrication
Solder and connect
3D printed enclosure
![Page 18: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/18.jpg)
Make it work
§ Arduino or other embedded code
§ Restricted environment– 32KB flash
– 2KB RAM
– 16MHz CPU
§ Perpetual non-observed execution
§ Select and inspect used sensors
§ Test and / or calibrate§ Check for factory defects§ Plan for hardware wear-out and lifespan
§ Don’t assume anything
BewareCode
18
![Page 19: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/19.jpg)
System design
19
![Page 20: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/20.jpg)
Rules to go by
§ Data transceiver
§ Data Store§ Web and API§ Analytics & processing
§ Robustness
§ Scaling§ Fallbacks§ Data sanity
Aim for and produceDecouple
20
![Page 21: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/21.jpg)
Our approach
SpringBoot framework§ Self contained web server / application§ Modular§ Starter packs for needed spring pieces§ Less configuration, more conventions§ Light(er)weight§ Container and orchestrator friendly (Cloud native)
21
![Page 22: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/22.jpg)
Data fetching
22
![Page 23: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/23.jpg)
Communication first!
(almost) No overhead§ Use binary protocols if possible§ Always on connection
– reconnect fast– plan for fallback
React first, store later!
Get closer to the data source.
23
![Page 24: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/24.jpg)
Our approach
TheThingsNetwork MQTT Integration
Spring Boot + Eclipse Paho client + Gson§ @Component client implementing MqttCallback§ Connect in @PostConstruct§ @Scheduled(fixedrate = …) watchdog @Component
Details on MQTT URL, credentials and message formats:https://www.thethingsnetwork.org/docs/applications/mqtt/api.html
24
![Page 25: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/25.jpg)
Data storage
25
![Page 26: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/26.jpg)
IoT data
IoT data is almost always impartial and time-series based
Use data store that is designed for sorted time-series§ Utilize recent data caches or TTLs§ Don’t hold on redundancies§ Always just append data§ Never aggregate, but process and store§ Design to live with eventual consistency
26
![Page 27: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/27.jpg)
Our approach
Cassandra DB 3.7
Spring Boot + Cassandra Driver Core + Extras§ Cassandra Cluster wrapped in @Service§ InstantCodec for java.time interoperability§ QueryBuilder§ No data filtering.
* spring-data-cassandra seemed like a poor choice.
27
![Page 28: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/28.jpg)
Analytics
28
![Page 29: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/29.jpg)
Averaging data
§ A lot of (impartial) data
§ Observed system load§ Possible downtime§ Retroactivity
§ Side-running SpringBoot microservice
§ Runs a few times a day§ Checks first§ Calculates last two days, week and month
§ Uses intermediary data§ Uses simple heuristic
Our approachSituation
29
![Page 30: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/30.jpg)
Warnings
30
!
![Page 31: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/31.jpg)
Early warning system
Keep a track on what’s happening§ Periodically fetch the recent data§ Analyze, produce and save current state§ Notify if the state has changed significantly§ Don’t spam§ Periodically cleanup
Our approach: SpringBoot + SpringSocial + Firebase
31
![Page 32: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/32.jpg)
Front-end & API
32
![Page 33: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/33.jpg)
Provide and visualize the data
Interactive cockpit and data explorers§ D3js client side visualizations§ Leaflet.js + OpenStreetMap
(+ Stamen designs)
Provide open to use API§ SpringBoot + SpringMVC +
SpringSecurity§ Set rules to avoid easy DOS§ Log usage§ Circuit breakers
33https://skopjepulse.mk/new
![Page 34: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/34.jpg)
Control the system
SPA for device and user management§ Angular2§ ng2-admin
System health dashboard
34
![Page 35: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/35.jpg)
Mobile apps
35
![Page 36: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/36.jpg)
Native Android and iOS apps
36
![Page 37: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/37.jpg)
Extras
37
![Page 38: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/38.jpg)
WiFi devices
Where you *really* can’t do LoRaWAN§ ESP8266 powered device § HTTPS communication§ provision device address securely§ implement own address -> key mapping
More: http://pance.mk/index.php/securing-esp8266-communication/
38
![Page 39: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/39.jpg)
AWS This is my architecture
39
http://tiny.cc/awsttn
![Page 40: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/40.jpg)
40
Discussion
![Page 41: Gluing the IoTworld with Java and LoRaWAN...Limitations Low speed (default BW) SF12: 250bps with the farthest distance and the longest air -time SF7: 5470bps with the shortest distance](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ecd4ea7bdf3a53aec2fad8b/html5/thumbnails/41.jpg)
41
Thank you