The content on this page was generated based on the content from https://github.com/Pi4J/pi4j/blob/develop/pi4j-test/README.md.
Testing the full Pi4J library is hard because it requires real hardware devices to validate all interactions. This test project is intended to provide a simple way to verify that the Pi4J library is working correctly on a Raspberry Pi with a few simple devices.
The src/main/java/com/pi4j/test/Main.java class verifies that the providers can be loaded and used. The use is very basic, but just enough to know it worked.
Usage parms:
-p newautocontext (default), linuxfs, or ffm
-h help
Two BMP280 (air pressure and temperature) or BME280 (air pressure, temperature, and humidity) are used as they are available as PCBs with both I2C and SPI interfaces. Some other wiring is added to connect GPIOs to each other, to test different types of communication.

Depending on the type of BMP/BME-sensors, the actual wiring may look a bit different. Use the tables below to define the correct connections for your components.



Used for the wiring diagram:
The I2C and SPI BMP280 charts refer to connection points on the breakout board, but your sensor may use different letter designations. Also, there are BMP sensors available with I2C and SPI interfaces or only one of the interfaces, read the fine print if you order these sensors.
| RPi Pin | Number | BCM | Color | Sensor |
|---|---|---|---|---|
| 3.3V | 1 | - | Red | Vin or Vcc or 3.3V |
| Gnd | 9 | - | Black | Gnd |
| SDA | 3 | 2 | Orange | SDA |
| SCL | 5 | 3 | Yellow | SCK or SCL |
| 3.3v | 1 | - | Red | CS if needed, see (*) |
(*): 3.3v connection to CS. If the sensor supports both the SPI and I2C interface, the CS pin controls the I2C interface enablement. From the datasheet: Interface selection is done automatically based on CSB (chip select) status. If CSB is connected to VDDIO, the I²C interface is active.
| RPi Pin | Number | BCM | Color | Sensor |
|---|---|---|---|---|
| MOSI | 19 | 10 | Blue | SDA or SDI |
| MISO | 21 | 9 | Purple | SDO |
| SCLK | 23 | 11 | Green | SCK or SCL |
| SPI CE0 | 24 | 8 | Yellow | CS |
| Gnd | 9 | - | Black | GND |
| 3.3V | 1 | - | Red | Vin or Vcc or 3.3V |
The PWM, input, output, and debounce connections are M-M jumpers between T-cobbler pins.
| Test | From RPi Pin | Number | BCM | To RPi Pin | Number | BCM | Color |
|---|---|---|---|---|---|---|---|
| PWM | PWM0 | 12 | 18 | GPIO | 16 | 23 | Green |
| Output | GPIO | 18 | 24 | GPIO | 22 | 25 | Blue |
| Input | GPIO | 36 | 16 | GPIO | 37 | 26 | White |
| Debounce | GPIO | 15 | 22 | GPIO | 17 | 27 | Grey |
Only needed for DigitalInputDebounceMonitorTestCase (not added to the wiring diagram and pictures).
| Test | From RPi Pin | Number | BCM | To RPi Pin | Number | BCM | Color |
|---|---|---|---|---|---|---|---|
| Debounce | GPIO | 32 | 12 | GPIO | 35 | 19 | Brown |
| GPIO | 38 | 20 | LOGIC |