As test object I´m using the brightness sensor BH1750, it´s already connected with my Raspberry Pi 3 and works with using i2cset/i2cget. This is also what I´m currently using in my Java project (Runtime.getRuntime().exec("i2cget ...")) because I´m on Java 14 and Pi4J v1.x does not work here with I2C.
Unfortunately it does not work with Pi4J v2, I only receive 0´s on every call (debugging showed me that I end up in this file for every call: RpiI2C.java
Am I missing something in the configuration (because the code in PiGpioI2C.java
would look fine on a rough look...) or is it just not implemented yet?
That´s my code so far:
pi4j = Pi4J.newAutoContext();
pi4j_i2c_BH1750_config = I2C.newConfigBuilder(pi4j)
.name("My I2C Bus")
i2c_BH1750 = pi4j.i2c().create(pi4j_i2c_BH1750_config);
i2c_BH1750.write(0x10); //Set Continuous Mode
byte value = new byte;
i2c_retval = i2c_BH1750.read(value, 0, 2);
Thanks and best regards,