Welcome to Pi4J!

This project is intended to provide a friendly object-oriented I/O API and implementation libraries for Java Programmers to access the full I/O capabilities of the Raspberry Pi platform. This project abstracts the low-level native integration and interrupt monitoring to enable Java programmers to focus on implementing their application business logic.

News / Announcements

2015-04-18

Version 1.0 has been released and is now available for download. (Downloads | Installation)

Please note that with this release the project has changed licensing from the Apache Software License, Version 2 to the GNU LGPL license, Version 3.0. This change was necessary because the Pi4J release binaries are embedding the WiringPi project (Pi4J now statically compiles against the WiringPi library) which is under GNU LGPL licensing. Per the terms of Apache licensing, the licensed project cannot include components under LGPL licensing. (http://www.apache.org/legal/resolved.html)

New development and bug fixes will now be provided via the 1.1-SNAPSHOT builds and the latest development codebase is now maintained in the 'develop' branch.

In addtition to maintenance and bug fixes, the 1.1-SNAPSHOT build also includes a completely overhauled Serial communication API and implementation. Please note that to add these serial API enhancements some APIs required breaking changes where they may no longer be backwards compatible with prior versions.

Project Status

Please note that this project is continually under development but has been very stable for well over a year. The functionality is very stable but improvements and bug fixes are continually committed into the 'develop' branch in the Pi4J GitHub repository and SNAPSHOT builds are published in the Sonatype OSS repository.

You are welcome to start using and integrating this library in your project. Please provide any feedback good, bad or ugly. (Well maybe keep the ugly feedback to a minimum.)

Visit the Downloads page to download the latest Pi4J library builds.

Features

  • Export & unexport GPIO pins
  • Configure GPIO pin direction
  • Configure GPIO pin edge detection
  • Control/write GPIO pin states
  • Pulse GPIO pin state
  • Read GPIO pin states
  • Listen for GPIO pin state changes (interrupt-based; not polling)
  • Automatically set GPIO states on program termination (GPIO shutdown)
  • Triggers for automation based on pin state changes
  • Send & receive data via RS232 serial communication
  • I2C Communication
  • SPI Communication
  • Extensible GPIO Provider interface to add GPIO capacity via expansion boards
  • Access system information and network information from the Raspberry Pi
  • Wrapper classes for direct access to WiringPi Library from Java

Getting Started

The simplest method to install Pi4J on your RaspberryPi is to execute the following command directly on your RaspberryPi.
curl -s get.pi4j.com | sudo bash

To get started using the Pi4J library, please see the following pages:

Examples

Review each of the following examples to explore the functionality provided by the Pi4j library.