Thing ยท Pi4J 2.0.0
Raspberry Pi GPIO with Pi4J
Creates the Pi4J context, persists GPIO configuration, polls digital inputs, controls digital and PWM outputs, and generates pin-state events.
// Configuration
| Parameter | Description | Default |
|---|---|---|
| Board model | Raspberry Pi 40-pin or 26-pin header. | 40 pin |
| Poll interval | Digital-input polling interval, 50โ10000 ms. | 200 ms |
| Platform / providers | Automatic or forced platform and GPIO provider selection. | Auto detect |
| Linux PWM chip | 0 for Pi 0โ4; 2 for Pi 5 RP1. | 0 |
| Auto inject / shutdown hook | Pi4J context lifecycle settings. | Enabled |
Electrical safety: GPIO uses 3.3 V logic. Use drivers, isolation, and external power for relays, motors, servos, and other loads.
// Use cases
SENSE
Digital sensors
Poll buttons, contacts, and sensors and route changes through Event Manager.
CTRL
GPIO and PWM control
Switch isolated inputs or control servos, dimmers, fans, and motor drivers.
PAD
Gamepad control
Map two controller axes to PWM pins for pan/tilt, steering, or throttle.
// Remote API
readBoard
Returns the header and configured pins.
read*PinListDropdown
Lists all, digital-output, or PWM pins.
configurePin / deletePin
Persists or removes a pin.
setPinState / setPwm
Controls a digital or PWM output.
// Events
Pi4JPinStateEvent
Contains BCM number, digital state, and the complete pin snapshot with mode, pull resistor, PWM settings, and last error.