SlideShare a Scribd company logo
Let’s Get Physical: 
I/O Programming with Java on 
the Raspberry Pi using Pi4J 
Robert Savage 
The Pi4J Project 
Project: 
http://pi4j.com 
Blog: 
http://savagehomeautomation.com 
#Devoxx #pi4j @savageautomate | @pi4j
Agenda 
Pi4J Overview 
Pi4J Introductory Concepts 
Smart Devices & IoT 
DIY Smart Devices 
MQTT 
#Devoxx #pi4j @savageautomate | @pi4j
What is Pi4J 
Pi4J is an open-source project providing a library for Java 
programmers to interact with the low-level I/O capabilities 
on the Raspberry Pi platform. 
• Open Source Project 
• Low Level I/O Library 
• Object Oriented API 
• Event Based 
• Java & C (JNI + Native) www.pi4j.com! 
#Devoxx #pi4j @savageautomate | @pi4j
Low Level I/O Interfaces 
Digital Interfaces 
• GPIO General Purpose Input Output 
• PWM Pulse Width Modulation 
Data Interfaces 
• UART, SERIAL Universal Asynchronous Receiver/Transmitter 
• SPI Serial Peripheral Interface 
• I²C Inter-Integrated Circuit 
Analog Interfaces * 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO 
• Input or Output 
• Digital States 
• HIGH ~ 3.3 VDC 
• LOW ~ 0 VDC 
• Models 
• A & B = ~21 GPIO 
• B+ = 28 GPIO 
• Compute Module = 46 GPIO 
(images from raspberrypi.org) 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Digital States 
GPIO 
HIGH (+3VDC) 
GPIO 
LOW (0 VDC) 
3.3 VDC 
0 VDC 
#Devoxx #pi4j @savageautomate | @pi4j
Pi4J GPIO Pin Addressing 
Visit pi4.com for a detailed pin addressing diagram! 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Outputs 
GPIO Outputs can be used to control things 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Output Circuit 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Output Circuit 
Active-High Relay Board! 
12 VDC " 
Strobe" 
Light! 
12 VDC 
Illuminated " 
Switch! 
12 VDC" 
Power Source! 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Output Example 
// 
create 
GPIO 
controller 
final 
GpioController 
gpio 
= 
GpioFactory.getInstance(); 
// 
create 
a 
GPIO 
output 
final 
GpioPinDigitalOutput 
output 
= 
gpio.provisionDigitalOutputPin( 
RaspiPin.GPIO_12, 
PinState.LOW 
); 
! 
// 
control 
GPIO 
output 
pin 
output.high(); 
output.low(); 
output.toggle(); 
// 
invert 
current 
state 
output.pulse(1000); 
// 
set 
state 
for 
a 
limited 
duration 
#Devoxx #pi4j @savageautomate | @pi4j
Demo 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Inputs 
GPIO Inputs can be 
used to “sense” things 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Circuit 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Reference 
•GPIO inputs require a “reference” voltage. 
•Without a reference, a GPIO pin can “float” 
•The Raspberry Pi includes internal PULL-UP and 
PULL-DOWN resistor settings that can be 
configured via Pi4J. 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Reference 
PULL-DOWN 
Resistance provides a reference (bias) to 
GROUND (0 VDC). If your circuit expects to 
provide +3.3VDC to signal the GPIO pin HIGH, 
then you need a PULL-DOWN reference. 
PULL-UP 
Resistance provides a reference (bias) to 
+3.3 VDC. If your circuit expects to provide 
GROUND to signal the GPIO pin LOW, then 
you need a PULL-UP reference. 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Circuit 
Alternatively, you can build the PULL-UP or PULL-DOWN 
reference in the hardware circuit. 
The circuit below demonstrates a PULL-UP resistor at R1. 
This circuit signals the GPIO 
input pin to LOW when the 
switch closes the circuit and a 
path to GROUND is complete. 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Example 
// 
create 
GPIO 
controller 
final 
GpioController 
gpio 
= 
GpioFactory.getInstance(); 
! 
// 
create 
a 
GPIO 
output 
final 
GpioPinDigitalInput 
input 
= 
gpio.provisionDigitalInputPin( 
RaspiPin.GPIO_02, 
PinPullResistance.PULL_DOWN); 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Input Listener 
// 
create 
event 
listener 
for 
GPIO 
input 
pin 
input.addListener((GpioPinListenerDigital) 
Java 8 
Lambda 
(GpioPinDigitalStateChangeEvent 
event) 
-­‐> 
{ 
! 
// 
set 
output 
state 
to 
match 
the 
input 
state 
output.setState(event.getState()); 
! 
}); 
#Devoxx #pi4j @savageautomate | @pi4j
Demo 
#Devoxx #pi4j @savageautomate | @pi4j
Pi4J Component API 
• The component APIs provides an abstraction layer from 
the hardware I/O layer. 
• This allows hardware design/circuitry to change with 
*less* impact to your implementation code. 
• For example, a RELAY could be controlled from GPIO, 
RS232, SPI, or I2C. You program defines the RELAY impl 
up front based on the hardware interface, but the rest of 
your program logic works against the RELAY component 
#Devoxx #pi4j @savageautomate | @pi4j
Pi4J Component API 
• Keypad 
• Light / LED 
• Dimmable Light 
• LCD 
• Power Controller 
• Relay 
• Momentary Switch 
• Toggle Switch 
• Analog Sensor 
• Distance Sensor 
• Motion Sensor 
• Temperature Sensor 
#Devoxx #pi4j @savageautomate | @pi4j
GPIO Components Example 
! 
// 
create 
LED 
component 
final 
Light 
light 
= 
new 
GpioLightComponent(output); 
! 
// 
usage 
example 
light.on(); 
(or) 
light.off(); 
! 
// 
create 
momentary 
switch 
component 
final 
MomentarySwitch 
ms 
= 
new 
GpioMomentarySwitchComponent( 
input, 
PinState.LOW, 
// 
“OFF” 
pin 
state 
PinState.HIGH); 
// 
“ON” 
pin 
state 
#Devoxx #pi4j @savageautomate | @pi4j
Demo 
#Devoxx #pi4j @savageautomate | @pi4j
Smart Devices / Internet of Things 
“A smart device is an electronic device, generally connected to 
other devices or networks via different protocols such as 
Bluetooth, NFC, WiFi, 3G, etc., that can operate to some extent 
interactively and autonomously. It is widely believed that these 
types of devices will outnumber any other forms of smart 
computing and communication in a very short time, in part, 
acting as a useful enabler for the Internet of Things. “ 
(reference: http://en.wikipedia.org/wiki/Smart_device) 
#Devoxx #pi4j @savageautomate | @pi4j
Smart Devices / Internet of Things 
• Network/Internet Accessible (Connected) 
• Autonomous Behavior 
• Interactive Capability 
• Notifications 
• Control 
#Devoxx #pi4j @savageautomate | @pi4j
Create A “Smart” Home 
• Recently moved into a new home. 
• I want to automate the subsystems 
in the home and make it a “smart” 
home. 
• I want to remotely control and 
monitor my home. 
#Devoxx #pi4j @savageautomate | @pi4j
Off The Shelf Smart Devices 
• Lots of emerging IoT Devices 
• Proprietary Hardware, Software/Apps & Protocols 
• Limited Interconnectivity or Interoperability 
#Devoxx #pi4j @savageautomate | @pi4j
D.I.Y. Smart Devices 
• Using Raspberry Pi + Java + Pi4J 
• Augment existing “dumb” devices and 
sensors to create new interactive 
capability and autonomous 
intelligence. 
• With simple GPIO and a little 
circuitry you can create all kinds of 
“Smart Devices”. 
Pi4J 
#Devoxx #pi4j @savageautomate | @pi4j
Basement Flood Alarm: 
• Take a water level sensor and instrument it to add 
intelligent monitoring and notification capability 
Pi4J 
Notifications 
Control 
other 
devices 
Water Level Sensor Remotely 
Monitor 
#Devoxx #pi4j @savageautomate | @pi4j
HVAC Alarm: 
• Take a HVAC moisture sensor and extend it to add 
intelligent monitoring and notification capability 
Pi4J 
Notifications 
Control 
other 
devices 
Remotely 
Monitor 
HVAC Condensate Leak Detector 
(Moisture Detector) 
#Devoxx #pi4j @savageautomate | @pi4j
Mail Notification: 
• Instrument a mailbox to get notified when mail arrives. 
Pi4J 
Notifications 
Control 
other 
devices 
Remotely 
Monitor 
Magnetic Door Sensors 
#Devoxx #pi4j @savageautomate | @pi4j
Driveway Alarm: 
• Add a sensor to driveway to get notified when someone 
approaches the house. 
Pi4J 
Notifications 
Control 
other 
devices 
Infrared Beam Sensors 
#Devoxx #pi4j @savageautomate | @pi4j
Garage Door Opener: 
• Remote control and monitoring of garage door 
• Auto-close if left open 
Garage Door Opener 
Door Sensor Pi4J 
Notifications 
Timer 
Remotely monitor 
and control 
#Devoxx #pi4j @savageautomate | @pi4j
Sprinkler System 
• Remotely control, configure and schedule the system. 
• Skip watering schedules if raining or if rain is forecasted 
Pi4J 
Sprinkler Controller 
Rain Sensor 
Schedule 
Notifications 
Weather Forecasts 
Remote Control 
and Monitoring 
#Devoxx #pi4j @savageautomate | @pi4j
Security System 
• Remote control and monitoring of the system 
• Activate other devices based on the state of the system 
Pi4J 
Security System 
Notifications 
Remote 
Control 
and 
Monitoring 
#Devoxx #pi4j @savageautomate | @pi4j
HVAC System 
• Interface with HVAC thermostat to remotely monitor and 
control the HVAC system. 
Pi4J 
Thermostat 
Notifications 
Remote 
Control 
and 
Monitoring 
#Devoxx #pi4j @savageautomate | @pi4j
Let’s Build a Proof of Concept Demo 
• Driveway Alerts 
• Flood Alerts 
Pi4J 
• Mailbox Notifications 
• HVAC System Alerts 
#Devoxx #pi4j @savageautomate | @pi4j
Demo 
#Devoxx #pi4j @savageautomate | @pi4j
What About Connectivity? 
• How do we aggregate monitored data? 
• How do we share information between sensors and 
devices to make intelligent automation decisions? 
• How do we access data and control these “smart” 
devices remotely? 
Basement Attic Mailbox Garage 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT 
Basement 
Attic 
Mailbox 
Garage 
MQTT 
BROKER 
MQTT Client 
MQTT Client 
MQTT Client 
MQTT Client 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT 
Desktop 
Tablet 
Web Server 
Mobile 
MQTT 
BROKER 
MQTT Client 
MQTT Client 
MQTT Client 
MQTT Client 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT Overview 
• MQTT == “Message Queuing Telemetry Transport” 
• M2M connectivity protocol 
• Lightweight Communications 
• Small Code Footprint 
• Open Standards Based 
• Asynchronous Messaging 
• Emerging protocol competing to be an IoT “standard” 
protocol 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT Features 
• Publish / Subscribe Messaging Transport (topics) 
• Last Will & Testament 
• QOS (Quality of Service) 
• Message Persistence 
• Supports Binary Data (Payloads) 
• TCP Based 
• Security (SSL/TLS) 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT Topics 
• Publishers, Subscribers & Broker 
(images from eclipse.org) 
#Devoxx #pi4j @savageautomate | @pi4j
MQTT Software 
• Mosquito Broker (Server) 
http://www.mosquitto.org/ 
! 
• Eclipse Paho (Client) 
http://www.eclipse.org/paho/ 
! 
• MQTT.Fx 
http://mqttfx.jfx4ee.org/ 
by Jens Deters (@Jerady) 
#Devoxx #pi4j @savageautomate | @pi4j
Demo 
#Devoxx #pi4j @savageautomate | @pi4j
2015 Goals 
• Start creating DIY “smart” devices using Raspberry Pi, Pi4J, 
and Java. 
• Create a blog article for each project and publish the wiring 
diagrams, source code, and materials listing. 
• Implement these DIY smart devices throughout my home 
and create a “smart” home. 
• Aggregate the information from these connected smart 
devices to start creating an intelligent and automated home 
#Devoxx #pi4j @savageautomate | @pi4j
Questions 
#Devoxx #pi4j @savageautomate | @pi4j
Savage Home Automation Blog The Pi4J Project 
pi4j.com 
savagehomeautomation.com 
@savageautomate @pi4j 
Sides & source code available now at http://www.savagehomeautomation.com/devoxx 
#Devoxx #pi4j @savageautomate | @pi4j

More Related Content

What's hot

02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
Mr.Nukoon Phimsen
 
Con3187 Creating Industrial Middleware with Java ME and Single-Board Computers
Con3187 Creating Industrial Middleware with Java ME and Single-Board ComputersCon3187 Creating Industrial Middleware with Java ME and Single-Board Computers
Con3187 Creating Industrial Middleware with Java ME and Single-Board Computers
Julio Palma Vázquez
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
Sulamita Garcia
 
Hackathon Taiwan 5th : Arduino 101
Hackathon Taiwan  5th : Arduino 101 Hackathon Taiwan  5th : Arduino 101
Hackathon Taiwan 5th : Arduino 101
twunishen
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel Edison
FITC
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
Eduardo Gulias Davis
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin ControlIntroduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin Control
Pradip Bhandari
 
PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_AyanPyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_Ayan
Ayan Pahwa
 
Building your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry Pi
Jeff Prestes
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
Dobrica Pavlinušić
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
CAVEDU Education
 
Python for IoT, A return of experience
Python for IoT, A return of experiencePython for IoT, A return of experience
Python for IoT, A return of experience
Alexandre Abadie
 
Getting Started with Embedded Python: MicroPython and CircuitPython
Getting Started with Embedded Python: MicroPython and CircuitPythonGetting Started with Embedded Python: MicroPython and CircuitPython
Getting Started with Embedded Python: MicroPython and CircuitPython
Ayan Pahwa
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
Kevin Hooke
 
Android Things Linux Day 2017
Android Things Linux Day 2017 Android Things Linux Day 2017
Android Things Linux Day 2017
Stefano Sanna
 
Raspberry pi tutorial
Raspberry pi tutorialRaspberry pi tutorial
Raspberry pi tutorial
Imad Rhali
 
Pi Is For Python
Pi Is For PythonPi Is For Python
Pi Is For Python
Brad Fortner
 
Open Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IOOpen Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IO
Jingfeng Liu
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
Indraneel Ganguli
 
Advanced view of projects raspberry pi list raspberry pi projects
Advanced view of projects raspberry pi list   raspberry pi projectsAdvanced view of projects raspberry pi list   raspberry pi projects
Advanced view of projects raspberry pi list raspberry pi projects
WiseNaeem
 

What's hot (20)

02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
02 Raspberry Pi GPIO Interface on Node-RED (Some correction)
 
Con3187 Creating Industrial Middleware with Java ME and Single-Board Computers
Con3187 Creating Industrial Middleware with Java ME and Single-Board ComputersCon3187 Creating Industrial Middleware with Java ME and Single-Board Computers
Con3187 Creating Industrial Middleware with Java ME and Single-Board Computers
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
Hackathon Taiwan 5th : Arduino 101
Hackathon Taiwan  5th : Arduino 101 Hackathon Taiwan  5th : Arduino 101
Hackathon Taiwan 5th : Arduino 101
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel Edison
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin ControlIntroduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin Control
 
PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_AyanPyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_Ayan
 
Building your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry Pi
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Python for IoT, A return of experience
Python for IoT, A return of experiencePython for IoT, A return of experience
Python for IoT, A return of experience
 
Getting Started with Embedded Python: MicroPython and CircuitPython
Getting Started with Embedded Python: MicroPython and CircuitPythonGetting Started with Embedded Python: MicroPython and CircuitPython
Getting Started with Embedded Python: MicroPython and CircuitPython
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
 
Android Things Linux Day 2017
Android Things Linux Day 2017 Android Things Linux Day 2017
Android Things Linux Day 2017
 
Raspberry pi tutorial
Raspberry pi tutorialRaspberry pi tutorial
Raspberry pi tutorial
 
Pi Is For Python
Pi Is For PythonPi Is For Python
Pi Is For Python
 
Open Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IOOpen Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IO
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
 
Advanced view of projects raspberry pi list raspberry pi projects
Advanced view of projects raspberry pi list   raspberry pi projectsAdvanced view of projects raspberry pi list   raspberry pi projects
Advanced view of projects raspberry pi list raspberry pi projects
 

Similar to DEVOXX Let's Get Physical: I/O Programming with Java on the Raspberry Pi using Pi4J

Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
GlobalLogic Ukraine
 
Raspberry PI Based Home Appliances Control System using Microcontroller
Raspberry PI Based Home Appliances Control System using MicrocontrollerRaspberry PI Based Home Appliances Control System using Microcontroller
Raspberry PI Based Home Appliances Control System using Microcontroller
ijtsrd
 
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
Hackito Ergo Sum
 
Io t basic-exercises
Io t basic-exercisesIo t basic-exercises
Io t basic-exercises
Fermin Galan
 
Uvais
Uvais Uvais
Internet of Things With PHP
Internet of Things With PHPInternet of Things With PHP
Internet of Things With PHP
Adam Englander
 
Using Python for IoT: a return of experience, Alexandre Abadie
Using Python for IoT: a return of experience, Alexandre AbadieUsing Python for IoT: a return of experience, Alexandre Abadie
Using Python for IoT: a return of experience, Alexandre Abadie
Pôle Systematic Paris-Region
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & Community
FIWARE
 
IoT from java perspective
IoT from java perspectiveIoT from java perspective
IoT from java perspective
Dmytro Panin
 
REP.01 PROJ-FX01 Smart Home RP-v2
REP.01 PROJ-FX01 Smart Home RP-v2REP.01 PROJ-FX01 Smart Home RP-v2
REP.01 PROJ-FX01 Smart Home RP-v2
Ricardo Pereira
 
From the internet of things to the web of things course
From the internet of things to the web of things courseFrom the internet of things to the web of things course
From the internet of things to the web of things course
Dominique Guinard
 
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс....NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
NETFest
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
Amarjeetsingh Thakur
 
Build a Java and Raspberry Pi weather station
Build a Java and Raspberry Pi weather station Build a Java and Raspberry Pi weather station
Build a Java and Raspberry Pi weather station
Marco Pirruccio
 
PHARO IOT
PHARO IOTPHARO IOT
PHARO IOT
Marcus Denker
 
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotelyPharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
ESUG
 
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICONOSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
jochen.hiller
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOps
Simon Su
 
Swift hardware hacking @ try! Swift
Swift hardware hacking @ try! SwiftSwift hardware hacking @ try! Swift
Swift hardware hacking @ try! Swift
Sally Shepard
 
IntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProjectIntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProject
Nicholas Parisi
 

Similar to DEVOXX Let's Get Physical: I/O Programming with Java on the Raspberry Pi using Pi4J (20)

Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
Java Webinar #9: “Raspberry Pi Platform for Java Programmers”
 
Raspberry PI Based Home Appliances Control System using Microcontroller
Raspberry PI Based Home Appliances Control System using MicrocontrollerRaspberry PI Based Home Appliances Control System using Microcontroller
Raspberry PI Based Home Appliances Control System using Microcontroller
 
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
 
Io t basic-exercises
Io t basic-exercisesIo t basic-exercises
Io t basic-exercises
 
Uvais
Uvais Uvais
Uvais
 
Internet of Things With PHP
Internet of Things With PHPInternet of Things With PHP
Internet of Things With PHP
 
Using Python for IoT: a return of experience, Alexandre Abadie
Using Python for IoT: a return of experience, Alexandre AbadieUsing Python for IoT: a return of experience, Alexandre Abadie
Using Python for IoT: a return of experience, Alexandre Abadie
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & Community
 
IoT from java perspective
IoT from java perspectiveIoT from java perspective
IoT from java perspective
 
REP.01 PROJ-FX01 Smart Home RP-v2
REP.01 PROJ-FX01 Smart Home RP-v2REP.01 PROJ-FX01 Smart Home RP-v2
REP.01 PROJ-FX01 Smart Home RP-v2
 
From the internet of things to the web of things course
From the internet of things to the web of things courseFrom the internet of things to the web of things course
From the internet of things to the web of things course
 
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс....NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
.NET Fest 2018. Андрей Тарарака. Как порулить грузовиком в Австралии, находяс...
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
 
Build a Java and Raspberry Pi weather station
Build a Java and Raspberry Pi weather station Build a Java and Raspberry Pi weather station
Build a Java and Raspberry Pi weather station
 
PHARO IOT
PHARO IOTPHARO IOT
PHARO IOT
 
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotelyPharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
Pharo IoT: Using Pharo to playing with GPIOs and sensors on IoT devices remotely
 
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICONOSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
OSGi Users' Forum Germany - Meeting Darmstadt 2014-04-14 - QIVICON
 
IThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOpsIThome DevOps Summit - IoT、docker與DevOps
IThome DevOps Summit - IoT、docker與DevOps
 
Swift hardware hacking @ try! Swift
Swift hardware hacking @ try! SwiftSwift hardware hacking @ try! Swift
Swift hardware hacking @ try! Swift
 
IntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProjectIntrotoSmartBuildingsFinalProject
IntrotoSmartBuildingsFinalProject
 

Recently uploaded

Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
norina2645
 
655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf
KhnhTrn343305
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
neshakor5152
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
rachitkumar09887
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
OnePlan Solutions
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
SimonedeGijt
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
SSTech System
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
sofiafernandezon
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024
TaskSprint | Employee Efficiency Software
 
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdfBuilding infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
mohitd6
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
attueb
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
SOCRadar
 
Odoo E-commerce website development guides
Odoo E-commerce website development guidesOdoo E-commerce website development guides
Odoo E-commerce website development guides
jhkdigitalmarketing
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
confluent
 
To Avoid Mistakes When Using Online Attendance Sheets
To Avoid Mistakes When Using Online Attendance SheetsTo Avoid Mistakes When Using Online Attendance Sheets
To Avoid Mistakes When Using Online Attendance Sheets
Task Tracker
 
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
josephinedrea942
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
Jersey (CHE-PING) Su
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
bhumivarma35300
 

Recently uploaded (20)

Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
Celebrity Girls Call Mumbai 🛵🚡9910780858 💃 Choose Best And Top Girl Service A...
 
655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
 
How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024How To Fill Timesheet in TaskSprint: Quick Guide 2024
How To Fill Timesheet in TaskSprint: Quick Guide 2024
 
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdfBuilding infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
Building infrastructure with code_ A deep dive into CDK for IaC in Java.pdf
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
 
Odoo E-commerce website development guides
Odoo E-commerce website development guidesOdoo E-commerce website development guides
Odoo E-commerce website development guides
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
 
To Avoid Mistakes When Using Online Attendance Sheets
To Avoid Mistakes When Using Online Attendance SheetsTo Avoid Mistakes When Using Online Attendance Sheets
To Avoid Mistakes When Using Online Attendance Sheets
 
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
HIRE A HACKER FOR CHEATING HUSBAND/WIFE)
 
當測試開始左移
當測試開始左移當測試開始左移
當測試開始左移
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
 

DEVOXX Let's Get Physical: I/O Programming with Java on the Raspberry Pi using Pi4J

  • 1. Let’s Get Physical: I/O Programming with Java on the Raspberry Pi using Pi4J Robert Savage The Pi4J Project Project: http://pi4j.com Blog: http://savagehomeautomation.com #Devoxx #pi4j @savageautomate | @pi4j
  • 2. Agenda Pi4J Overview Pi4J Introductory Concepts Smart Devices & IoT DIY Smart Devices MQTT #Devoxx #pi4j @savageautomate | @pi4j
  • 3. What is Pi4J Pi4J is an open-source project providing a library for Java programmers to interact with the low-level I/O capabilities on the Raspberry Pi platform. • Open Source Project • Low Level I/O Library • Object Oriented API • Event Based • Java & C (JNI + Native) www.pi4j.com! #Devoxx #pi4j @savageautomate | @pi4j
  • 4. Low Level I/O Interfaces Digital Interfaces • GPIO General Purpose Input Output • PWM Pulse Width Modulation Data Interfaces • UART, SERIAL Universal Asynchronous Receiver/Transmitter • SPI Serial Peripheral Interface • I²C Inter-Integrated Circuit Analog Interfaces * #Devoxx #pi4j @savageautomate | @pi4j
  • 5. GPIO • Input or Output • Digital States • HIGH ~ 3.3 VDC • LOW ~ 0 VDC • Models • A & B = ~21 GPIO • B+ = 28 GPIO • Compute Module = 46 GPIO (images from raspberrypi.org) #Devoxx #pi4j @savageautomate | @pi4j
  • 6. GPIO Digital States GPIO HIGH (+3VDC) GPIO LOW (0 VDC) 3.3 VDC 0 VDC #Devoxx #pi4j @savageautomate | @pi4j
  • 7. Pi4J GPIO Pin Addressing Visit pi4.com for a detailed pin addressing diagram! #Devoxx #pi4j @savageautomate | @pi4j
  • 8. GPIO Outputs GPIO Outputs can be used to control things #Devoxx #pi4j @savageautomate | @pi4j
  • 9. GPIO Output Circuit #Devoxx #pi4j @savageautomate | @pi4j
  • 10. GPIO Output Circuit Active-High Relay Board! 12 VDC " Strobe" Light! 12 VDC Illuminated " Switch! 12 VDC" Power Source! #Devoxx #pi4j @savageautomate | @pi4j
  • 11. GPIO Output Example // create GPIO controller final GpioController gpio = GpioFactory.getInstance(); // create a GPIO output final GpioPinDigitalOutput output = gpio.provisionDigitalOutputPin( RaspiPin.GPIO_12, PinState.LOW ); ! // control GPIO output pin output.high(); output.low(); output.toggle(); // invert current state output.pulse(1000); // set state for a limited duration #Devoxx #pi4j @savageautomate | @pi4j
  • 12. Demo #Devoxx #pi4j @savageautomate | @pi4j
  • 13. GPIO Inputs GPIO Inputs can be used to “sense” things #Devoxx #pi4j @savageautomate | @pi4j
  • 14. GPIO Input Circuit #Devoxx #pi4j @savageautomate | @pi4j
  • 15. GPIO Input Reference •GPIO inputs require a “reference” voltage. •Without a reference, a GPIO pin can “float” •The Raspberry Pi includes internal PULL-UP and PULL-DOWN resistor settings that can be configured via Pi4J. #Devoxx #pi4j @savageautomate | @pi4j
  • 16. GPIO Input Reference PULL-DOWN Resistance provides a reference (bias) to GROUND (0 VDC). If your circuit expects to provide +3.3VDC to signal the GPIO pin HIGH, then you need a PULL-DOWN reference. PULL-UP Resistance provides a reference (bias) to +3.3 VDC. If your circuit expects to provide GROUND to signal the GPIO pin LOW, then you need a PULL-UP reference. #Devoxx #pi4j @savageautomate | @pi4j
  • 17. GPIO Input Circuit Alternatively, you can build the PULL-UP or PULL-DOWN reference in the hardware circuit. The circuit below demonstrates a PULL-UP resistor at R1. This circuit signals the GPIO input pin to LOW when the switch closes the circuit and a path to GROUND is complete. #Devoxx #pi4j @savageautomate | @pi4j
  • 18. GPIO Input Example // create GPIO controller final GpioController gpio = GpioFactory.getInstance(); ! // create a GPIO output final GpioPinDigitalInput input = gpio.provisionDigitalInputPin( RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN); #Devoxx #pi4j @savageautomate | @pi4j
  • 19. GPIO Input Listener // create event listener for GPIO input pin input.addListener((GpioPinListenerDigital) Java 8 Lambda (GpioPinDigitalStateChangeEvent event) -­‐> { ! // set output state to match the input state output.setState(event.getState()); ! }); #Devoxx #pi4j @savageautomate | @pi4j
  • 20. Demo #Devoxx #pi4j @savageautomate | @pi4j
  • 21. Pi4J Component API • The component APIs provides an abstraction layer from the hardware I/O layer. • This allows hardware design/circuitry to change with *less* impact to your implementation code. • For example, a RELAY could be controlled from GPIO, RS232, SPI, or I2C. You program defines the RELAY impl up front based on the hardware interface, but the rest of your program logic works against the RELAY component #Devoxx #pi4j @savageautomate | @pi4j
  • 22. Pi4J Component API • Keypad • Light / LED • Dimmable Light • LCD • Power Controller • Relay • Momentary Switch • Toggle Switch • Analog Sensor • Distance Sensor • Motion Sensor • Temperature Sensor #Devoxx #pi4j @savageautomate | @pi4j
  • 23. GPIO Components Example ! // create LED component final Light light = new GpioLightComponent(output); ! // usage example light.on(); (or) light.off(); ! // create momentary switch component final MomentarySwitch ms = new GpioMomentarySwitchComponent( input, PinState.LOW, // “OFF” pin state PinState.HIGH); // “ON” pin state #Devoxx #pi4j @savageautomate | @pi4j
  • 24. Demo #Devoxx #pi4j @savageautomate | @pi4j
  • 25. Smart Devices / Internet of Things “A smart device is an electronic device, generally connected to other devices or networks via different protocols such as Bluetooth, NFC, WiFi, 3G, etc., that can operate to some extent interactively and autonomously. It is widely believed that these types of devices will outnumber any other forms of smart computing and communication in a very short time, in part, acting as a useful enabler for the Internet of Things. “ (reference: http://en.wikipedia.org/wiki/Smart_device) #Devoxx #pi4j @savageautomate | @pi4j
  • 26. Smart Devices / Internet of Things • Network/Internet Accessible (Connected) • Autonomous Behavior • Interactive Capability • Notifications • Control #Devoxx #pi4j @savageautomate | @pi4j
  • 27. Create A “Smart” Home • Recently moved into a new home. • I want to automate the subsystems in the home and make it a “smart” home. • I want to remotely control and monitor my home. #Devoxx #pi4j @savageautomate | @pi4j
  • 28. Off The Shelf Smart Devices • Lots of emerging IoT Devices • Proprietary Hardware, Software/Apps & Protocols • Limited Interconnectivity or Interoperability #Devoxx #pi4j @savageautomate | @pi4j
  • 29. D.I.Y. Smart Devices • Using Raspberry Pi + Java + Pi4J • Augment existing “dumb” devices and sensors to create new interactive capability and autonomous intelligence. • With simple GPIO and a little circuitry you can create all kinds of “Smart Devices”. Pi4J #Devoxx #pi4j @savageautomate | @pi4j
  • 30. Basement Flood Alarm: • Take a water level sensor and instrument it to add intelligent monitoring and notification capability Pi4J Notifications Control other devices Water Level Sensor Remotely Monitor #Devoxx #pi4j @savageautomate | @pi4j
  • 31. HVAC Alarm: • Take a HVAC moisture sensor and extend it to add intelligent monitoring and notification capability Pi4J Notifications Control other devices Remotely Monitor HVAC Condensate Leak Detector (Moisture Detector) #Devoxx #pi4j @savageautomate | @pi4j
  • 32. Mail Notification: • Instrument a mailbox to get notified when mail arrives. Pi4J Notifications Control other devices Remotely Monitor Magnetic Door Sensors #Devoxx #pi4j @savageautomate | @pi4j
  • 33. Driveway Alarm: • Add a sensor to driveway to get notified when someone approaches the house. Pi4J Notifications Control other devices Infrared Beam Sensors #Devoxx #pi4j @savageautomate | @pi4j
  • 34. Garage Door Opener: • Remote control and monitoring of garage door • Auto-close if left open Garage Door Opener Door Sensor Pi4J Notifications Timer Remotely monitor and control #Devoxx #pi4j @savageautomate | @pi4j
  • 35. Sprinkler System • Remotely control, configure and schedule the system. • Skip watering schedules if raining or if rain is forecasted Pi4J Sprinkler Controller Rain Sensor Schedule Notifications Weather Forecasts Remote Control and Monitoring #Devoxx #pi4j @savageautomate | @pi4j
  • 36. Security System • Remote control and monitoring of the system • Activate other devices based on the state of the system Pi4J Security System Notifications Remote Control and Monitoring #Devoxx #pi4j @savageautomate | @pi4j
  • 37. HVAC System • Interface with HVAC thermostat to remotely monitor and control the HVAC system. Pi4J Thermostat Notifications Remote Control and Monitoring #Devoxx #pi4j @savageautomate | @pi4j
  • 38. Let’s Build a Proof of Concept Demo • Driveway Alerts • Flood Alerts Pi4J • Mailbox Notifications • HVAC System Alerts #Devoxx #pi4j @savageautomate | @pi4j
  • 39. Demo #Devoxx #pi4j @savageautomate | @pi4j
  • 40. What About Connectivity? • How do we aggregate monitored data? • How do we share information between sensors and devices to make intelligent automation decisions? • How do we access data and control these “smart” devices remotely? Basement Attic Mailbox Garage #Devoxx #pi4j @savageautomate | @pi4j
  • 41. MQTT Basement Attic Mailbox Garage MQTT BROKER MQTT Client MQTT Client MQTT Client MQTT Client #Devoxx #pi4j @savageautomate | @pi4j
  • 42. MQTT Desktop Tablet Web Server Mobile MQTT BROKER MQTT Client MQTT Client MQTT Client MQTT Client #Devoxx #pi4j @savageautomate | @pi4j
  • 43. MQTT Overview • MQTT == “Message Queuing Telemetry Transport” • M2M connectivity protocol • Lightweight Communications • Small Code Footprint • Open Standards Based • Asynchronous Messaging • Emerging protocol competing to be an IoT “standard” protocol #Devoxx #pi4j @savageautomate | @pi4j
  • 44. MQTT Features • Publish / Subscribe Messaging Transport (topics) • Last Will & Testament • QOS (Quality of Service) • Message Persistence • Supports Binary Data (Payloads) • TCP Based • Security (SSL/TLS) #Devoxx #pi4j @savageautomate | @pi4j
  • 45. MQTT Topics • Publishers, Subscribers & Broker (images from eclipse.org) #Devoxx #pi4j @savageautomate | @pi4j
  • 46. MQTT Software • Mosquito Broker (Server) http://www.mosquitto.org/ ! • Eclipse Paho (Client) http://www.eclipse.org/paho/ ! • MQTT.Fx http://mqttfx.jfx4ee.org/ by Jens Deters (@Jerady) #Devoxx #pi4j @savageautomate | @pi4j
  • 47. Demo #Devoxx #pi4j @savageautomate | @pi4j
  • 48. 2015 Goals • Start creating DIY “smart” devices using Raspberry Pi, Pi4J, and Java. • Create a blog article for each project and publish the wiring diagrams, source code, and materials listing. • Implement these DIY smart devices throughout my home and create a “smart” home. • Aggregate the information from these connected smart devices to start creating an intelligent and automated home #Devoxx #pi4j @savageautomate | @pi4j
  • 49. Questions #Devoxx #pi4j @savageautomate | @pi4j
  • 50. Savage Home Automation Blog The Pi4J Project pi4j.com savagehomeautomation.com @savageautomate @pi4j Sides & source code available now at http://www.savagehomeautomation.com/devoxx #Devoxx #pi4j @savageautomate | @pi4j