Using Pi4j (V1) on the Raspberry Pi 4

A topic which comes up from time to time in questions related to Java and the Raspberry Pi, is the support of the 4th version of this board in combination with Pi4J, “the friendly object-oriented I/O API and implementation library for Java programmers to access the full I/O capabilities of the Raspberry Pi “.

Under the hoods, Pi4J is using WiringPi to control the GPIOs. Because the internal wiring of the processor on the Raspberry Pi 4 is different from the previous boards, an update is available of WiringPi.

Be sure to use version 2.52 of the gpio utility. You can check your version by using the gpio -v command via the terminal and, if needed, install the new version using the following commands:

$ gpio -v
gpio version: 2.50

$ cd /tmp
$ wget https://project-downloads.drogon.net/wiringpi-latest.deb
$ sudo dpkg -i wiringpi-latest.deb
$ gpio -v
gpio version: 2.52