Collection of drivers for various I2C sensors written in Java using pi4j.
- Raspberry Pi compatibility: 3, 4, zero, zero W, zero 2W
- Raspberry Pi OS: April 4th 2022, 32-bit, 64-bit
- BMP180 - Bosch I2C temperature and pressure sensor. reference, datasheet.
- BME280 - Bosch I2C temperature, humidity and pressure sensor. reference, datasheet.
- HTU21D - I2C relative humidity and temperature sensor. reference, datasheet.
- PCF8591 - I2C 8-bit 4-channel AD Converter. reference, datasheet.
- ADS1115 - I2C 16-bit 4-channel AD Converter. reference, datasheet.
- BH1750 - I2C Light Intensity Sensor. reference, datasheet.
<dependency>
<groupId>one.microproject.rpi</groupId>
<artifactId>rpi-drivers</artifactId>
<version>2.1.1</version>
</dependency>
implementation 'one.microproject.rpi:rpi-drivers:2.1.1'
- Install java on Raspberry PI.
sudo apt install openjdk-11-jdk
- Enable I2C on raspberry pi using
sudo raspi-config
. - Make sure I2C sensors are connected to Raspberry PI device.
Check reference documentation for I2C sensors.
i2cdetect -y 1
- Build driver library package (on PC). (requires java 11 & gradle 7.3 or later):
gradle clean build test publishToMavenLocal installDist distZip
- Copy binary build to Raspberry PI device:
scp build/distributions/rpi-drivers-2.1.1.zip pi@<raspberry-pi>:/home/pi/
- Run tests on Raspberry PI device, select only tests for connected sensors:
unzip rpi-drivers-2.1.1.zip cd rpi-drivers-2.1.1/bin ./rpi-drivers ALL | ADS1115 | BME280 | BMP180 | HTU21D | PCF8591 | BH1750