Device support project for the TCA9548 (1x8 I2C switch)
  • Java 95.1%
  • Shell 3.5%
  • Python 1.4%
Find a file
Tom Aarts 4d652faf50
All checks were successful
Maven CI / build (push) Successful in 1m12s
Merge pull request #139 from Pi4J/mcp23008_drv_1
start of mcp230xx driver migration.  Gut complex details from readme
2026-06-09 14:42:19 -05:00
.github/workflows upgrade ci to jdk 25 2025-10-19 16:29:27 +02:00
.mvn/wrapper Add CI Pipeline with Maven Wrapper and Update Build Instructions 2024-11-15 08:56:38 +01:00
assets modify sh files to work without being in modules 2026-01-05 18:10:40 -10:00
config/checkstyle add checkstyle phase in CI, Fixed the errors 2024-11-27 19:36:33 -06:00
src start of mcp230xx driver migration. Gut complex details from readme 2026-06-09 14:36:15 -05:00
.editorconfig updates to use linuxfs-i2c 2024-04-20 11:34:29 -05:00
.gitattributes BMP280 add in SPI connectivity 2023-07-10 21:34:02 -05:00
.gitignore Add files via upload 2021-09-17 15:36:57 -05:00
mvnw Add CI Pipeline with Maven Wrapper and Update Build Instructions 2024-11-15 08:56:38 +01:00
mvnw.cmd Add CI Pipeline with Maven Wrapper and Update Build Instructions 2024-11-15 08:56:38 +01:00
pom.xml pi4j_v5 uses a single concrete provider. Remove all referneces of code to select which provider to use 2026-06-02 20:02:55 -05:00
README.md review for missed text. Also restore comment the driver migration is ongoing 2026-06-08 10:05:20 -05:00

Pi4J :: Java I/O Library for Raspberry Pi :: Examples

Various examples demonstrating the use of Pi4J core and/or drivers library.

We began major changes in the Device examples. We are migrating to drivers
that separate the device driver code from external dependencies. These examples
will be modified one by one.
For driver project dependency details see https://www.pi4j.com/drivers/

"Generic" Examples:

The following table the currently supported devices within this project:

Category Connection Issues Device / Example
Display 1602A LCD HD44780U: App uses SN74HC595 to control the LCD
Display I2C 1602A LCD MCP23017 I2C Controller: App uses MCP23017 to control the LCD
Display I2C 1602A_LCD_PCF8574A I2C Controller: App uses PCF8574A to control the LCD
Display I2C (1) Is31fl3731 matrix controller
Display I2C (1) SSD1306 OLED I2C
Display SPI (1) NeoPixel94V Intelligent Control LED device
A/D (1) ADS1255/ADS1256 24bit A-to-D
A/D I2C (1) Basic_ADS1256 24bit A-to-D
A/D SPI DAC8552 16bit DAC SPI connected
A/D SPI (1) MCP3008 A/D 10bit converter
A/D I2C (1) MCP4725 12 bit DAC
HAT Raspberry SenseHat
HAT Waveshare 13890 Mini OLED Display Hat
HAT Waveshare 13891 Mini Display Hat
HAT Waveshare 14972 Mini Display Hat
HAT Waveshare GamePi13 Hat
IO Expander I2C MCP23008 drive and read chip GPIOs
IO Expander I2C MCP23008 and MCP23017 Pin monitoring (interrupt support)
IO Expander I2C MCP23017 drive and read chip GPIOs
Memory (1) (2) AT24C512 SEEPROM
Misc I2C (1) QT Rotary Encoder
Misc (1) SN74HC595 8 Bit shift register
Misc I2C TCA9548 (1x8 I2C switch)
Misc I2C (1) VL53L0X TimeOfFlight device
Sensor I2C, SPI (1) BMP280 Temperature and Pressure Sensor
Sensor I2C, SPI (1) BME280 Temperature, Pressure and Humidity Sensor
Sensor 1-Wire (1) DHT22 Temp/Humidity sensor
Sensor HC-SR04 Ultrasonic Sensor
Sensor I2C (1) MPL3115A2 Temp/Pressure/Altitude device

Notes:

(1): This package uses code within this repo and Pi4J
(2): Requires 2.2.2-SNAPSHOT of Pi4j that supports i2c multibyte write/restart \

GPIO monitor

The following is valid on all pre Pi5 SOCs. Not valid on Pi5 SOCs. This repository includes two Python scripts to monitor GPIO pin states in real-time on a Raspberry Pi.
Note: These scripts use the pigpio library, which is currently incompatible with the Raspberry Pi 5.

Setting Up pigpio

To install pigpio, run:

pip install pigpio

Also, make sure the pigpiod daemon is running before executing either script:

sudo pigpiod
  1. monitor.py

This script provides a detailed, line-by-line log of GPIO state changes, including the time difference in microseconds between state changes for each pin.

  • Usage:
python3 monitor.py              # Monitor all GPIO pins
python3 monitor.py 23 24 25     # Monitor only GPIO pins 23, 24, and 25
  • Features:
    • Logs state changes (HIGH/LOW) for each monitored GPIO pin.
    • Displays the time difference between successive state changes in microseconds.
    • Structured with modular functions for initializing GPIO monitoring, handling state changes, and cleanup on exit.
  • Example Output:
Monitoring GPIO pins... Press Ctrl+C to stop.
GPIO=23 Level=1 Time Diff=120 μs
GPIO=24 Level=0 Time Diff=95 μs
GPIO=25 Level=1 Time Diff=110 μs
  1. monitor_table_format.py

This script offers a compact, tabular format for monitoring GPIO states, displaying the current state of each pin in a single, updating line. This view is ideal for visualizing slow state changes without excessive log clutter.

  • Usage:
python3 monitor_table_format.py          # Monitor all GPIO pins
python3 monitor_table_format.py 23 24 25 # Monitor only GPIO pins 23, 24, and 25
  • Features:
    • Displays pin states in a single, continuously updating line.
    • Ideal for slow changes, as it reduces visual clutter by showing only the current state of each pin.
    • Automatically updates the state every second (customizable by adjusting the sleep interval).
  • Example Output:
Monitoring GPIO pins... Press Ctrl+C to stop.
GPIO   23 | 24 | 25
STATE   1 |  0 |  1