Collection of devices implemented for use with Pi4J V2.
__ __ _ _ _
| \/ (_)__ _ _ _ __ _| |_(_)___ _ _
| |\/| | / _` | '_/ _` | _| / _ \ ' \
|_| |_|_\__, |_| \__,_|\__|_\___/_||_|
| |_ ___ |___/
| _/ _ \
\__\___/ _
| \ _ _(_)_ _____ _ _ ___
| |) | '_| \ V / -_) '_(_-<
|___/|_| |_|\_/\___|_| /__/
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.
Migrated devices are located in https://github.com/Pi4J/pi4j-drivers/tree/main
Project by Tom Aarts.
Note: Second tag captures code that works with pi4j 2.x.x and java21.
Followon work will use java24 and new providers.
Note: This repository has a tag identifying the code level that works with
2.4.0-SNAPSHOT. Commits newer than this tag are migrations to the
2.6.0-SNAPSHOT. These commits may contain code using providers and/or Pi4J-V2
interfaces not available in prior SNAPSHOTs..
The following table the currently supported devices within this project:
(1): This package uses code within this repo and Pi4J
(2): Requires 2.2.2-SNAPSHOT of Pi4j that supports i2c multibyte write/restart
(3): SPI versions of the device uses Pigpio, cannot be used on Raspberry Pi5 \
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
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.
- Logs state changes (
- 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
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