What Java library should I use to control raspberry pi 4b, Pi4J does not support rpi4. Wiringpi is deprecated. I tried searching for others b ut cannot find anything, how to control gpio with java in 2020?
I can confirm that diozero (documentation now at https://www.diozero.com/) works with all flavours of Raspberry Pi, from the armv6 based Pi Zero through to the latest Pi4 / Compute Module 4, as well as many other SBCs (tested on Odroid C2, Beaglebone Green/Black, TinkerBoard, NanoPi Neo/Duo2). Also works on both 32-bit and 64-bit operating systems (Raspberry Pi OS, Armbian and Ubuntu). Finally, it also works with Arduino devices using Firmata.
- Pi4J V1 with and upgraded version of WiringPi (v2.52), see my answer on Pi4 GPIO Control with Java
- Pi4J V2 which uses PiGpio instead of WiringPi, but is still a work-in-progress, see https://v2.pi4j.com/
- If you need limited GPIO functionality you can use terminal commands or even a Python script included in your project. All this is described in my book "Getting Started with Java on the Raspberry Pi" and all the examples are available on GitHub
- I haven't used this myself yet, but https://diozero.readthedocs.io/en/latest/ seems to provide similar functionality as Pi4J
They have new version of Pi4J V.2 with Java 11, support RPI 4 B+. Pi4J V.2 had the first release in August 2021. So, go do it !