Book Image

Raspberry Pi 3 Projects for Java Programmers

By : Rajdeep Chandra, John Sirach, Pradeeka Seneviratne
Book Image

Raspberry Pi 3 Projects for Java Programmers

By: Rajdeep Chandra, John Sirach, Pradeeka Seneviratne

Overview of this book

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.
Table of Contents (8 chapters)
4
Integrating a Real-Time IoT Dashboard

What this book covers

Chapter 1, Setting up Your Raspberry Pi, teaches you about the hardware available with Raspberry Pi and how to prepare to utilize it from the installed Java Virtual Machine. Setting up the NetBeans editor to be able to write Java applications, which can be deployed from the editor, including the in-editor, available console to be able to interact with Java applications on Raspberry Pi.

Chapter 2, Automatic Light Switch Using Presence Detection, explains how to perform analogue readings using digital pins, as the Raspberry Pi has no analog reading capabilities. By adding a 16x2 character display, you will visualize these readings. By adding logic to the code, you will be able to determine when someone is present, and in combination with detecting light levels, you will be able to set a relay state that turns a light on or off.

Chapter 3, A Social and Personal Digital Photo Frame, offers comprehensive guidance on building a social and personal digital photo frame with the Raspberry Pi as the heart. Flickr will be used the social media platform to grab a set of images that will be shown, on the display. FEH will be used an X11 image viewer to display images as a slide show with customizable configurations. Some advanced configurations for the Raspberry Pi will be needed to automate the photo frame to connect with Flickr, download images to local storage, display them on screen, and frequently sync local storage with Flickr.

Chapter 4, Integrating a Real-Time IoT Dashboard, presents a real-time IoT dashboard to display sensor data and Raspberry Pi’s system information on it, and control actuators from it. The dashboard will be built with Adafruit IO, in conjunction with the Eclipse Paho Java MQTT library and Pi4J. The IC2 communication protocol will be used to read data from the sensors by enabling the 12C interface on Raspberry Pi.

Chapter 5, Wireless Controlled Robot, introduces the Zumo chassis kit and how to build a Raspberry Pi brain on it with Java and Pi4J. The robot uses two gear motors to rotate the drive wheels, and the Pi4J library allows us to build various moving and turning mechanisms to control the robot. The built-in Wi-Fi module of the Raspberry Pi 3 allows you to connect the robot wirelessly to the computer, in order to execute the commands through SSH with a keyboard.

Chapter 6, Building a Multipurpose IoT Controller, teaches you how to build a simple web-based IoT controller by installing and configuring a Jetty servlet engine on the Raspberry Pi. Pi4J is used to control an LED or any other actuator from the web interface through a local network or from the Internet, by configuring port forwarding on the router.

Chapter 7, Security Camera with Face Recognition, explains how to build a security camera with face recognition using the OpenCV library for Java and the Raspberry Pi camera module. It uses built-in cascade classifiers to detect human faces and highlights them with a square in real-time video.