IoT: LoRa and Java on the PI
-
Upload
jworks-powered-by-ordina -
Category
Internet
-
view
2.283 -
download
0
Transcript of IoT: LoRa and Java on the PI
1
IoT - LoRa & Java on the PiCC IoT
Tim Ysewyn
Frederick Bousson
Kevin Van den Abeele
Guest speaker
Dave De Groote
2
Agenda
In today's session:
● News update● Theoretical part
○ What is LoRa○ Who is working on/with LoRa
● Practical part○ Java on the raspberry pi○ Getting started○ A simple example○ Alternatives to Java?
● Q&A
3
Can’t keep up? Don’t understand something?
4
News update
5
News update
Latest news from IoT land:
● Proximus LoRa beta has started in Belgium○ More later in this session!
● Element14 launched the new Raspberry Pi Zero○ Very very small!○ Single core CPU & 512MB Ram○ https://www.raspberrypi.org/products/pi-zero/○ Costs only 5 dollar!
6
What is LoRa
7
What is LoRa
8
LoRa Technology (Long Range Low Power)
9
LoRa Technology (Long Range Low Power)
10
LoRa Devices
Base station
Any type is possible as long as it is connected with a LoRa chipCO2, PIR, Humidity, Luminance, Temperature, Pressure, …
Sensor Types
banana for scale
11
LoRa Alliance
https://www.lora-alliance.org
12
Ordina At Proximus
- MyThings Builder▪ Charts▪ Managing containers of sensors
(Battery, temperature, luminance, …)
- MyThings Manager▪ Online onboarding of sensors▪ User management
- MyThings Scanner▪ Customer can go into the field and
onboard sensors (scanning QR code of sensor)
13
Demo
14
LoRa in Belgium
15
LoRa in Belgium
Proximus has launched its LoRa Beta program in Belgium
● Available in 10 areas (More to come in 2016)● Preview access to SEaaS (Sensor as a Service) API● 6 months free access to the network
○ There however is a message quota○ 15k messages in total => 84 upstream, 12 downstream /day○ Very limited!
Proximus LoRa website:http://www.proximus.be/nl/id_cl_iot/bedrijven-en-overheden/producten-en-diensten/internet-en-netwerken/internet-of-things.html
Dev kits (we will probably get two or three):http://www.allthingstalk.com/lora-rapid-development-kit
16
Setting up your Raspberry pi
17
Setting up your Raspberry pi
Useful links:
● Main Raspberry Pi website○ Contains many resources and is a good place to start!○ https://www.raspberrypi.org/○ Has links and images for the most common OSs
● Magpi○ Website (and magazine) focussing on the Raspberry Pi○ https://www.raspberrypi.org/magpi/○ Good source for extra information and articles
18
Setting up your Raspberry pi
● Insert SD card in your mac or windows pc/laptop.● Open “cmdline.txt” and append the following at the end: “ip=169.254.0.2”
○ Make sure to have a space after the last item before adding the ip○ Make sure NOT to add a newline after the ip!○ Save the file and put the SD card back in the raspberry pi
● Connect your raspberry pi to the power and connect it directly to the computer via an ethernet cable
● Wait a few minutes...● Open an ssh client and connect to your raspberry pi
○ On mac: ssh [email protected] (the default password is raspberry)● Execute the following command: “sudo raspi-config”
○ Have a look around in the settings and edit where required○ Finish settings and reboot your pi (this will disconnect the ssh session)
● Download the latest FileZilla release● Extract/install FileZilla● Open FileZilla and connect to your raspberry pi
○ sftp://169.254.0.2 user:pi password:raspberry
19
Java on the Raspberry Pi
20
Java on the Raspberry Pi
Java runs pretty well on the Raspberry Pi (even more so on our model 2)The Raspbian OS has Java 1.8u25 installed by default!
For updates of java:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlDownload the ARMV6/V7 Hard float ABI or update via the built in package manager!
Capabilities:● Most normal jars will run just fine (albeit slower and more memory limited)● Can run complex UIs when using JavaFx
○ Has full hardware acceleration for UI rendering○ Forget swing and awt!○ The devoxx screens were running on a Pi with JavaFx UI
21
A Simple Example
A simple web server application:
● Clone the following repo: https://github.com/ordina-oraj/IoT.git● Make sure you have gradle installed!
○ On osx: “brew install gradle”○ Import the project in IntelliJ and when asked for the gradle folder:
“/usr/local/Cellar/gradle/2.1/libexec”● Compile the application by running the gradle task “build”● Open filezilla and connect to the Pi● Copy the generated jar file (in /build/libs/) to a folder on your Pi● Connect to the Pi via SSH and go to the directory where you placed the jar● Run the following command: “java -jar NameOfYourJar.jar”
○ For remote debug prepend -jar in the command with: “-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005”
● On your host, open a browser and go to: http://169.254.0.2:8080/○ If you see a welcome page, your setup was successful!
22
A simple example… Continued
This is up to you!
Take a look in the code, and implement something fancy for the “impress” me section.
A few ideas:● A second more extensive rest service● A websocket implementation?
○ Dare we say a chat client? ● A file upload● A form to submit● ...
23
Java and IO pins
24
Java and IO pins
The Pi has a bunch of IO pins. These can be used for several things.
Model A and B:● 26 pins● https://www.raspberrypi.org/documentation/usage/gpio/● 17 of 26 pins are for GPIO
Model A+, B+, Zero and 2:● 40 pins● https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/● 26 of 40 pins are for GPIO
These GPIO pins can be used to collect data from sensors, to drive servos, LEDs and other peripherals.
http://wiringpi.com/pins/
25
Java and IO pins… Continued
26
Java and IO pins… Continued
To use the GPIO pins from within Java an extra library is needed, as there is no native support within Java.
This is where PI4J comes in. It is a easy to use library to control the GPIO pins:
Installation is easy and is documented on http://pi4j.com/install.html
Usage is also not that difficult: http://pi4j.com/usage.html
The project on our github contains the pi4j library and some example code to get you started.
=> DEMO TIME!
27
Alternatives?
28
Alternatives?
What about non Java languages on the Pi?
● Python● C / C++● Javascript (via node.js or io.js)● …
Node.js:Node is very simple to setup and use. It makes use of Google’s V8 javascript engine and is very fast.
Node itself is single threaded but dispatches operations like IO the separate threads.It can be clustered and allowed to run on multiple threads via more node workers.Program for Node run in Javascript and thus required no manual compilation before running.This makes it very handy for rapid development.
More about Node.js in our next session! ;)
29
Q&A
30
Until next time