Camel Pi4j component
Camel Pi4j component can be used to manage GPIO and I2C bus features from Raspberry Pi. This component uses pi4j library
Maven dependency
Maven users should add the following dependency to their POM file:
io.rhiotcamel-pi4j${rhiot.version}
Avaliable for rhiot.version >= 0.1.1
URI format for GPIO
gpioId must match [A-Z_0-9]+ pattern. By default, pi4j-gpio uses RaspiPin Class, change it via gpioClass property You can use static field name "GPIO_XX", pin name "GPIO [0-9]" or pin address "[0-9]"
Optional URI Parameters
Parameter
Default value
Description
gpioId
state
Digital Only: if input mode then state trigger event, if output then started value
mode
DIGITAL_OUTPUT
To configure GPIO pin mode, Check Pi4j library for more details
action
Default : use Body if Action for output Pin (TOGGLE, BUZZ, HIGH, LOW for digital only) (HEADER digital and analog)
value
0
Analog or PWN Only
shutdownExport
true
To configure the pin shutdown export
shutdownResistance
OFF
To configure the pin resistance before exit program
shutdownState
LOW
To configure the pin state value before exit program
pullResistance
PULL_UP
gpioClass
com.pi4j.io.gpio.RaspiPin
class<com.pi4j.io.gpio.Pin>
pin implementation
controller
com.pi4j.io.gpio.impl.GpioControllerImpl
instance of <com.pi4j.io.gpio.GpioController>
GPIO controller instance, check gpioClass pin implementation to use the same
Consuming:
Producing
When using producer you can also set or override action using message header with a key of Pi4jConstants.CAMEL_RBPI_PIN_ACTION
Simple button w/ LED mode
Plug an button on GPIO 1, and LED on GPIO 2 (with Resistor) and code a route like this
URI format for I2C
Optional URI Parameters
Parameter
Default value
Description
busId
i2c bus
deviceId
i2c device
address
0x00
address to read
readAction
READ, READ_ADDR, READ_BUFFER, READ_ADDR_BUFFER
size
-1
offset
-1
bufferSize
-1
driver
cf available i2c driver
I2C component is really simplistic, the consumer endpoint reads a single byte, or to a buffer of bytes directly from the device. The producer writes 1 or more bytes.
For smarter devices, you must implement a driver.
i2c driver
Driver
Feature
bmp180
tsl2561
lsm303-accel
lsm303-magne
mcp23017-lcd
hts221
lps25h
Last updated
Was this helpful?