I/O Programming with Java on the Raspberry Pi using Pi4J

Similar documents
Java Programming on the Raspberry Pi with Pi4J. Rob Ratcliff

Home automation with pymodbus

Internet of Things: Demonstration. Mr. Bernard G. Cruz Lecturer

EDJE PROJECT. The Software Foundation for IoT Devices. IS2T S.A All rights reserved.

Smart Homes and Cities

MNEM IoT Presentation for Export

Acknowledgments...xvi Introduction... xvii Primer Project 1: Blinking an LED Project 2: Pushbutton LED Flashlight...

for Multi-Services Gateways

NATIONAL CONTROL DEVICES Push Notification - Serial Quick Start Guide

TIMING-BASED ASSISTANT CONTROLS

Prototyping Module Datasheet

Q9 ASD LOW VOLTAGE DRIVE

Steven Edouard SDET, US - DX Audience West Microsoft Bruno Terkaly Principal Software Engineer - Microsoft

Hands-On with IoT Standards & Protocols

8:1 Serial Port Expander

Raspberry Pi. Hans-Petter Halvorsen, M.Sc.

Circuit Diagram For Water Level Controller Using 8051 Microcontroller With Pin Configuration

Embedded Linux With Raspberry Pi IOT

MQTT Message Queue Telemetry Transport.

An Overview of WebSphere MQ Telemetry and How to Utilize MQTT for Practical Solutions

Own Your Technology Pvt Ltd. Own Your Technology Presents Workshop on MSP430

SIP Traditional Analog New Age Digital

Edge Power International (HK) Ltd. Product Specification

B-33. Hardware and Install Manual. (DC 12V / PoE)

DEV-1 HamStack Development Board

SECOND EDITION. Arduino Cookbook. Michael Margolis O'REILLY- Tokyo. Farnham Koln Sebastopol. Cambridge. Beijing

USER MANUAL FOR HARDWARE REV

Home Security System with Remote Home Automation Control

MQTT Broker API. This guide will get you started in connecting your devices to WolkAbout IoT Platform.

MPI-DN, MPI-D MULTICHANNEL ELECTRONIC RECORDER for HART or RS-485/ MODBUS RTU SENSORS

Internet of things (IoT)

Powering the Internet of Things with MQTT

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

FEATURES DESCRIPTION FEATURES

EMBEDDED SYSTEMS WITH ROBOTICS AND SENSORS USING ERLANG

VANDAL RESISTANT BACK-LIT WEATHERPROOF ACCESS CONTROL KEYPAD

THE DIGITAL RELAY BOX. Put an end to mechanical fuses, relays and switches!

Electronics Single wire communication

x x 60 mm, 700 gm. Wall mounted enclosure, 1 Kg. Weatherproof, high impact GF ABS. Remote control and monitoring with debug features

Getting Started with MQTT. Eclipse M2M Webinars Webinar #3 September 27, /10/2012 1

or between microcontrollers)

Advanced Embedded Systems

I2C a learn.sparkfun.com tutorial

Posture Fixer. Jia Lee, Cheng Peter Qian, Lécuyer Cédric

RASPBERRY PI EXAMPLES WITH CLICK BOARDS

Location-based event system for mobile phones

IoT CoAP Plugtests & Workshop November 27 th 2012

Embedded Vision Systémy - využití ve výuce a v průmyslu

GL-104 ENCODER/DECODER MANUAL GLOLAB CORPORATION

EMCP 4.4 Simulator Manual. Author: Lucas Tolbert CIC Engineering 345 Center Street East Peoria, IL

Build Your Own Data Collection IoT Devices

A Language-based Approach to Interoperability of IoT Platforms

I2C a learn.sparkfun.com tutorial

MQTT MQ TELEMETRY TRANSPORT. AN INTRODUCTION TO MQTT, A PROTOCOL FOR M2M AND IoT APPLICATIONS. Peter R. Egli INDIGOO.COM. indigoo.com. 1/33 Rev. 1.

Automating Your Lights with Open Source Combining Open Source Hardware with Free and Open Source Software

Quad-Relay Delay Switch (QRDS) User Manual (v1.0)

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Creating a Java Internet of Things Gateway. David Woodard, Eurotech

CONTROL ANYTHING WITH YOUR CELLPHONE. Use your cellphone to remotely monitor and control the following applications with the CELLSWITCH 100

OnRISC. IoT Manual. Vision Systems GmbH. Edition: October 2017

Getting to know the Arduino IDE

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

IoT based weather controlled smart green house

Digital Circuits Part 2 - Communication

DAS 250L CONTROL COMMUNICATOR INSTALLATION MANUAL

Smart Door Security Control System Using Raspberry Pi

M2M Communication in Ad-Hoc WSNs for Industrial Application Using MQTT Protocol

CDD4 Duct Carbon Dioxide Transmitter

DIN-Rail Mounted Ultrasonic Flow Meter

Getting Started. Activation Process. G450 Overview

Arduino Cookbook O'REILLY* Michael Margolis. Tokyo. Cambridge. Beijing. Farnham Koln Sebastopol

MQTT, Industry 4.0, and the Future of Automation

ARM mbed Reference Designs

Table of Contents DEPARTMENT OF ELECTRICAL & COMPUTER ENGINEERING UNIVERSITY OF CENTRAL FLORIDA. Team 5

Wizard- 3 Controller to Optional Track 1-4 Playback Set-up

IoT Ecosystem and Business Opportunities

Home Automation using IoT

Basics of UART Communication

Monitoring system LN-VT325. Environmental Infrastructure monitoring

Richmond Heights. Smart Wi-Fi Capacitive Touch With Dual Protocols Universal Controller. Go Green

HOW SENSOR FRAMEWORKS ENABLE EFFICIENT DEVELOPMENT

Intel Galileo gen 2 Board

Secure Connection with a Smart Device

ADVANCED TRAINING INSTITUTE, HYDERABAD

BMS: Installation Manual v2.x - Documentation

What is Internet of things? (IoT)

Smart Metering & Home Automation Technologies Re-Training for Electricians

FAN CONTROLLER BRIEF DESCRIPTION

Tyler Lacroix & Roger Lacroix Capitalware's MQ Technical Conference v

Smart Irrigation System Using Internet of Things

ROOM GUARD VT335. Environmental Infrastructure monitoring

VT825 / Environmental Monitoring unit. Environmental Infrastructure monitoring

LiteTouch Integration Manual

C.L.A.I.M Computerized Luggage and Information Messenger

Introduction to Microcontrollers

Christian Brothers University 650 East Parkway South Memphis, TN

The ICU-Duino Arduino Shield!

The Power of the DragonBoard 410c Enabled by IBM Watson IoT. Presented by Robert Schwarz

Which application/messaging protocol is right for me?

Product Catalog. senseware.co Tysons Boulevard Floor 5 Tysons VA, 22102

Transcription:

Let s Get Physical: I/O Programming with Java on the Raspberry Pi using Pi4J Robert Savage The Pi4J Project Project: Blog: http://pi4j.com http://savagehomeautomation.com

Agenda Pi4J Overview Pi4J Introductory Concepts Smart Devices & IoT DIY Smart Devices MQTT

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!

Low Level I/O Interfaces Digital Interfaces GPIO PWM General Purpose Input Output Pulse Width Modulation Data Interfaces UART, SERIAL SPI I²C Universal Asynchronous Receiver/Transmitter Serial Peripheral Interface Inter-Integrated Circuit Analog Interfaces *

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)

GPIO Digital States GPIO HIGH (+3VDC) 3.3 VDC 0 VDC GPIO LOW (0 VDC)

Pi4J GPIO Pin Addressing Visit pi4.com for a detailed pin addressing diagram!

GPIO Outputs GPIO Outputs can be used to control things

GPIO Output Circuit

GPIO Output Circuit Active-High Relay Board! 12 VDC" Power Source! 12 VDC " Strobe" Light! 12 VDC Illuminated " Switch!

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

Demo

GPIO Inputs GPIO Inputs can be used to sense things

GPIO Input Circuit

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.

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.

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.

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);

GPIO Input Listener Java 8 Lambda // create event listener for GPIO input pin input.addlistener((gpiopinlistenerdigital) (GpioPinDigitalStateChangeEvent event) - > {! // set output state to match the input state output.setstate(event.getstate());! });

Demo

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

Pi4J Component API Keypad Light / LED Dimmable Light LCD Power Controller Relay Momentary Switch Toggle Switch Analog Sensor Distance Sensor Motion Sensor Temperature Sensor

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

Demo

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)

Smart Devices / Internet of Things Network/Internet Accessible (Connected) Autonomous Behavior Interactive Capability Notifications Control

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.

Off The Shelf Smart Devices Lots of emerging IoT Devices Proprietary Hardware, Software/Apps & Protocols Limited Interconnectivity or Interoperability

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

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

HVAC Alarm: Take a HVAC moisture sensor and extend it to add intelligent monitoring and notification capability Pi4J Notifications Control other devices HVAC Condensate Leak Detector (Moisture Detector) Remotely Monitor

Mail Notification: Instrument a mailbox to get notified when mail arrives. Notifications Pi4J Control other devices Magnetic Door Sensors Remotely Monitor

Driveway Alarm: Add a sensor to driveway to get notified when someone approaches the house. Notifications Pi4J Control other devices Infrared Beam Sensors

Garage Door Opener: Remote control and monitoring of garage door Auto-close if left open Timer Notifications Garage Door Opener Remotely monitor and control Door Sensor Pi4J

Sprinkler System Remotely control, configure and schedule the system. Skip watering schedules if raining or if rain is forecasted Schedule Notifications Sprinkler Controller Weather Forecasts Rain Sensor Pi4J Remote Control and Monitoring

Security System Remote control and monitoring of the system Activate other devices based on the state of the system Notifications Security System Pi4J Remote Control and Monitoring

HVAC System Interface with HVAC thermostat to remotely monitor and control the HVAC system. Notifications Thermostat Pi4J Remote Control and Monitoring

Let s Build a Proof of Concept Demo Driveway Alerts Flood Alerts Pi4J Mailbox Notifications HVAC System Alerts

Demo

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

MQTT Basement MQTT Client MQTT BROKER MQTT Client Mailbox Attic MQTT Client MQTT Client Garage

MQTT Desktop MQTT Client MQTT BROKER MQTT Client Web Server Tablet MQTT Client MQTT Client Mobile

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

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)

MQTT Topics Publishers, Subscribers & Broker (images from eclipse.org)

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)

Demo

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

Questions

Savage Home Automation Blog savagehomeautomation.com @savageautomate The Pi4J Project pi4j.com @pi4j Sides & source code available now at http://www.savagehomeautomation.com/devoxx