← Getting Started ← Home

What is Pi4J?

Pi4J is a friendly Java library for accessing GPIO, I²C, SPI, PWM and other low-level interfaces on the Raspberry Pi. It lets you talk to hardware like the Sense HAT from a normal Java application, without dropping down to native code or shelling out to Python.

The library at a glance

  • A Context is the entry point — you get one with Pi4J.newAutoContext().
  • Providers plug into the context to expose GPIO, I²C, SPI, PWM and serial buses.
  • The current v4/v5 line uses the FFM plugin (Foreign Function & Memory API), so no JNI build step is needed.
  • The pi4j-drivers project layers device-specific drivers on top of Pi4J — including the Sense HAT.

Docs and code

Community