Over a million developers have joined DZone.

Rocking the IoT world with Bulldog Library

An introduction to Bulldog: a Java library for single board computer platforms like Raspberry Pi.

· IoT Zone

Access the survey results 'State of Industrial Internet Application Development' to learn about latest challenges, trends and opportunities with Industrial IoT, brought to you in partnership with GE Digital.

Bulldog Library

It is a Java library providing developers with GPIO and other low-level IO interfaces like I2C, SPI, or PWM. Currently supports various Single Board Computer (SBC) platforms, including Raspberry PiBeagleBoneBlack, and CubieBoard.

Bulldog aims to be platform agnostic - to write a single piece of code that can be run on multiple platforms. The only thing that needs to be changed in the following snippet is the string identifier of GPIO pin to work on different SBCs.

public class BulldogLED {

  public static void main(String[] args) {
    //Detect the board we are running on
    Board board = Platform.createBoard();

    //Set up a digital output
    DigitalOutput output = board.getPin("P1_11").as(DigitalOutput.class);

    // Blink the LED

The latest 0.2.0 release was mainly about stabilizing and finishing platform detection capabilities, however we are already looking into our ultimate goal, that is to get rid of all filesystem interaction and omiting all the kernel modules, and interact directly with memory of the controlled SBC. This will boost the performance to the sky, so stay tuned!


There is also a component for Apache Camel that wraps Bulldog Library features. At the moment it supports only GPIO, however support for the rest of Bulldog features is already knocking on the door. 

An example is worth a thousand words. The following snippet is all you need to build a REST endpoint which controls a GPIO pin on your SBC. It will work on all platforms supported by Bulldog Library. 

<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
    <restConfiguration bindingMode="auto" component="jetty" port="8080" />
    <rest path="/rest">
      <post uri="/led">
        <to uri="bulldog://gpio?pin=P1_11" />

So don't hesitate, grab the library and rock the IoT world!


The IoT Zone is brought to you in partnership with GE Digital.  Discover how IoT developers are using Predix to disrupt traditional industrial development models.

java,raspberry pi,beaglebone black,iot development

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}