Link Search Menu Expand Document

diozero

Build Status Maven Central Maven Central status License: MIT Javadoc

A Device I/O library implemented in Java that is portable across Single Board Computers to provide an intuitive and frictionless way to get started with physical computing.

Example:

try (LED led = new LED(18)) {
  led.on();
  SleepUtil.sleepSeconds(1);
  led.off();
  SleepUtil.sleepSeconds(1);
  led.toggle();
}

Components can easily be connected together, e.g.:

try (Button button = new Button(12); LED led = new LED(18)) {
  button.whenPressed(nanoTime -> led.on();
  button.whenReleased(nanoTime -> led.off());
  SleepUtil.sleepSeconds(20);
}

As well as providing interfaces for interacing directly with physical hardware (i.e. GPIO, I2C, SPI and Serial), diozero also provides support for simple devices including LDRs, Buttons, and Motors through to complex environmental sensors such as the Bosch Sensortec Gas Sensor BME60.

This library makes use of modern Java features such as automatic resource management, Lambda Expressions and Method References to simplify development and improve code readability.

Supported Boards

diozero has out of the box support for the following Single Board Computers and micro-controllers:

Maven dependency:

<dependency>
    <groupId>com.diozero</groupId>
    <artifactId>diozero-core</artifactId>
    <version>1.2.0</version>
</dependency>

Create your own application using the diozero-application Maven archetype:

mvn archetype:generate -DinteractiveMode=false \
  -DarchetypeGroupId=com.diozero \
  -DarchetypeArtifactId=diozero-application \
  -DarchetypeVersion=1.2.0 \
  -DgroupId=com.mycompany \
  -DartifactId=mydiozeroproject \
  -Dversion=1.0-SNAPSHOT

A distribution ZIP file containing all JARs and their dependencies is also available via Maven Central - locate com.diozero:diozero-distribution, select a version and click the “bin.zip” option in the Downloads link top right. It is also available in mvnrepository by locating diozero-distribution, selecting a version and clicking the Files View All link.

Development

Created by Matt Lewis (email deviceiozero@gmail.com) (blog), inspired by GPIO Zero and Johnny Five. If you have any issues, comments or suggestions please use the GitHub issues page.

This project is hosted on GitHub, please feel free to join in:

  • Make suggestions for fixes and enhancements
  • Provide sample applications and device implementation classes
  • Contribute to development

Release History

This work is provided under the MIT License.