Raspberry Pi 3 Projects for Java Programmers

Book description

Learn the art of building enticing projects by unleashing the potential of Raspberry Pi 3 using Java

About This Book

  • Explore the small yet powerful mini computer in order to run java applications
  • Leverage Java libraries to build exciting projects on home automation, IoT, and Robotics by leveraging Java libraries
  • Get acquainted with connecting electronic sensors to your Raspberry Pi 3 using Java APIs.

Who This Book Is For

The book is aimed at Java programmers who are eager to get their hands-on Raspberry Pi and build interesting projects using java. They have a very basic knowledge of Raspberry Pi.

What You Will Learn

  • Use presence detection using the integrated bluetooth chip
  • Automatic light switch using presence detection
  • Use a centralized IoT service to publish data using RPC
  • Control a robot by driving motors using PWM
  • Create a small web service capable of performing actions on the Raspberry Pi and supply readings
  • Image capture using Java together with the OpenCV framework

In Detail

Raspberry Pi is a small, low cost and yet very powerful development platform. It is used to interact with attached electronics by the use of it's GPIO pins for multiple use cases, mainly Home Automation and Robotics.

Our book is a project-based guide that will show you how to utilize the Raspberry Pi's GPIO with Java and how you can leverage this utilization with your knowledge of Java. You will start with installing and setting up the necessary hardware to create a seamless development platform. You will then straightaway start by building a project that will utilize light for presence detection. Next, you will program the application, capable of handling real time data using MQTT and utilize RPC to publish data to adafruit.io. Further, you will build a wireless robot on top of the zuma chassis with the Raspberry Pi as the main controller. Lastly, you will end the book with advanced projects that will help you to create a multi-purpose IoT controller along with building a security camera that will perform image capture and recognize faces with the help of notifications.

By the end of the book, you will be able to build your own real world usable projects not limited to Home Automation, IoT and/or Robotics utilizing logic, user and web interfaces.

Style and approach

The book will contain projects that ensure a java programmer gets started with building interesting projects using the small yet powerful Raspberry Pi 3. We will start with brushing up your Raspberry Pi skills followed by building 5-6 projects

Table of contents

  1. Credits
  2. About the Authors
  3. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  4. Setting up Your Raspberry Pi
    1. Getting started with the Raspberry Pi
      1. Getting a compatible SD card
      2. Preparing and formatting the SD card
    2. Installing Raspbian
      1. Configuring Raspbian
    3. Installing Java
    4. Installing and preparing the NetBeans Java editor
    5. Our first remote Java application
      1. Running our application on the Raspberry Pi
    6. Summary
  5. Automatic Light Switch Using Presence Detection
    1. Introduction to and installing Fritzing
    2. Billing of materials
    3. How to emulate reading analog values on digital pins
    4. Starting our project and installing the necessary libraries
    5. The Pi4J libraries
    6. Adding the HD44780-compatible 16x2 character display
    7. Showing data on the HD44780-compatible display
    8. Adding the light-dependent resistor to the setup
    9. Reading and displaying the values from the LDR
    10. Using digital out to switch and display a relay status
    11. Automatic switch based on environment lighting
    12. Using the Bluetooth chip on the Raspberry Pi
    13. Bluetooth device discovery
    14. Putting it all together, our first automation project
    15. Summary
  6. A Social and Personal Digital Photo Frame
    1. Bill of materials
    2. Waveshare HDMI display
      1. Assembling with Raspberry Pi
      2. Selecting video source
      3. Correcting display resolution
      4. Mounting on desktop
      5. Connecting with Flickr
      6. Obtaining a Flickr API key
      7. Creating an album
      8. Finding Flickr photoset_id
      9. REST request format
        1. Invoking flickr.test.echo
        2. Invoking flickr.photosets.getPhotos
        3. Constructing photo source URL
      10. Writing Java program
      11. Accessing Flickr image URL
      12. Installing feh on Raspberry Pi
      13. Scheduling your application
        1. Writing shell script for Java application
        2. Testing the digital_photo_frame.sh with the terminal
        3. Scheduling digital_photo_frame.sh with crontab
        4. Testing digital_photo_frame.sh with crontab
      14. Writing shell script for slideshow
        1. Starting digital photo frame on Raspberry Pi boot
        2. Photo frame in action
    3. Summary
  7. Integrating a Real-Time IoT Dashboard
    1. Adafruit IO
      1. Bill of materials
      2. Sign in with Adafruit IO
      3. Finding your AIO key
      4. Creating news feed
        1. Understanding topics
      5. Creating a dashboard
        1. Creating a block on a dashboard
      6. Raspberry Pi and I2C pins
      7. Connecting an I2C-compatible sensor to the Raspberry Pi
        1. Serial bus addresses
        2. Configuring the Raspberry Pi to use I2C
        3. Searching I2C devices attached to the Raspberry Pi
        4. Accessing I2C with Pi4J
        5. Eclipse Paho Java client
        6. Writing Java program to publish data to a feed
        7. Publishing temperature sensor data
        8. Publishing system information
      8. Subscribing to a feed
        1. Creating a toggle button on Adafruit dashboard
        2. Subscribe to the button feed
        3. Controlling an LED from button feed
    2. Summary
  8. Wireless Controlled Robot
    1. Prerequisites
    2. The Zumo chassis kit
      1. Assembling Zumo chassis
      2. Preparing motors to reducing the effects of electrical noise
      3. Attaching Raspberry Pi to Zumo chassis
      4. Building the circuit
      5. Wiring them together
      6. Moving and turning
        1. Moving
        2. Turning
        3. Swing turn
    3. Writing your Java program
    4. Running and testing your Java program
    5. Summary
  9. Building a Multipurpose IoT Controller
    1. Prerequisites
    2. Preparing your Raspberry Pi board
      1. Installing and configuring Jetty servelet engine
    3. Writing your first Java web application
      1. Creating a Maven project from Archetype
        1. Creating a servlet
        2. Copying iot.war file to the Raspberry Pi
    4. Summary
  10. Security Camera with Face Recognition
    1. Raspberry Pi camera module
      1. Connecting the camera module to the Raspberry Pi
    2. OpenCV
      1. Downloading and installing OpenCV on Windows
      2. Creating the Java project
      3. Adding the OpenCV library to your Java project
      4. Downloading and building OpenCV on Raspberry Pi
    3. Working with video
      1. Facial recognition
        1. Build and run
    4. Summary

Product information

  • Title: Raspberry Pi 3 Projects for Java Programmers
  • Author(s): Pradeeka Seneviratne, John Sirach
  • Release date: May 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781786462121