Class I2CExample
- java.lang.Object
-
- I2CExample
-
public class I2CExample extends Object
This example code demonstrates how to perform simple I2C communication on the Raspberry Pi. For this example we will connect to a 'TSL2561' LUX sensor. Data Sheet: https://www.adafruit.com/datasheets/TSL256x.pdfYou should get something similar printed in the console when executing this program:
> <--Pi4J--> I2C Example ... started.
> ... reading ID register from TSL2561
> TSL2561 ID = 0x50 (should be 0x50)
> ... powering up TSL2561
> ... reading DATA registers from TSL2561
> TSL2561 DATA 0 = 0x1e
> TSL2561 DATA 1 = 0x04
> ... powering down TSL2561
> Exiting I2CExample
- Author:
- Robert Savage
-
-
Field Summary
Fields Modifier and Type Field Description static int
TSL2561_ADDR
static byte
TSL2561_POWER_DOWN
static byte
TSL2561_POWER_UP
static byte
TSL2561_REG_CONTROL
static byte
TSL2561_REG_DATA_0
static byte
TSL2561_REG_DATA_1
static byte
TSL2561_REG_ID
-
Constructor Summary
Constructors Constructor Description I2CExample()
-
-
-
Field Detail
-
TSL2561_ADDR
public static final int TSL2561_ADDR
- See Also:
- Constant Field Values
-
TSL2561_REG_ID
public static final byte TSL2561_REG_ID
- See Also:
- Constant Field Values
-
TSL2561_REG_DATA_0
public static final byte TSL2561_REG_DATA_0
- See Also:
- Constant Field Values
-
TSL2561_REG_DATA_1
public static final byte TSL2561_REG_DATA_1
- See Also:
- Constant Field Values
-
TSL2561_REG_CONTROL
public static final byte TSL2561_REG_CONTROL
- See Also:
- Constant Field Values
-
TSL2561_POWER_UP
public static final byte TSL2561_POWER_UP
- See Also:
- Constant Field Values
-
TSL2561_POWER_DOWN
public static final byte TSL2561_POWER_DOWN
- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(String[] args) throws InterruptedException, PlatformAlreadyAssignedException, IOException, I2CFactory.UnsupportedBusNumberException
Program Main Entry Point- Parameters:
args
-- Throws:
InterruptedException
PlatformAlreadyAssignedException
IOException
I2CFactory.UnsupportedBusNumberException
-
-