Hardware Testing

The content on this page was generated based on the content from https://github.com/Pi4J/pi4j/blob/develop/pi4j-test/README.md.

Pi4J Smoke Test

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.

Main Test

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

Wiring

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.

Wiring diagram

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.

Example setup

Example setup

Example setup

Used for the wiring diagram:

Components

  • Breadboard
  • T-cobbler plugged into a prototype board
  • Two sensors, BMP280 or BME280, mounted on PCB with I2C and SPI
  • M-M breadboard wires

Buying Examples

Datasheets

Sensor Wiring

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.

I2C

RPi PinNumberBCMColorSensor
3.3V1-RedVin or Vcc or 3.3V
Gnd9-BlackGnd
SDA32OrangeSDA
SCL53YellowSCK or SCL
3.3v1-RedCS 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.

SPI Using a 4-wires Connection

RPi PinNumberBCMColorSensor
MOSI1910BlueSDA or SDI
MISO219PurpleSDO
SCLK2311GreenSCK or SCL
SPI CE0248YellowCS
Gnd9-BlackGND
3.3V1-RedVin or Vcc or 3.3V

Direct Wiring

The PWM, input, output, and debounce connections are M-M jumpers between T-cobbler pins.

TestFrom RPi PinNumberBCMTo RPi PinNumberBCMColor
PWMPWM01218GPIO1623Green
OutputGPIO1824GPIO2225Blue
InputGPIO3616GPIO3726White
DebounceGPIO1522GPIO1727Grey

Only needed for DigitalInputDebounceMonitorTestCase (not added to the wiring diagram and pictures).

TestFrom RPi PinNumberBCMTo RPi PinNumberBCMColor
DebounceGPIO3212GPIO3519Brown
GPIO3820LOGIC