3

I want to controle a 16*2 lcd display on my raspberry pi4 with java. The problem is that Pi4J - the solution to modify the gpios with java is not updated to pi4. Is there another solution? This error occures when I start the programm:

pi@raspberrypi:~/desktop/gpio $ sudo ./start.sh

<--Pi4J--> GPIO Control Example ... started. Maista Unable to determine hardware version. I see: Hardware : BCM2711 ,

  • expecting BCM2708 or BCM2709. If this is a genuine Raspberry Pi then please report this to projects@drogon.net. If this is not a Raspberry Pi then you are on your own as wiringPi is designed to support the Raspberry Pi ONLY.
John A.
  • 31
  • 2
  • Did you contact projects@drogon.net? Or look at the pi4j web site? Seems like the authors would be best equipped to talk about their code. – user13784117 Aug 15 '20 at 16:03
  • If you don't find what you need, you should look at raspberrypi.stackexchange.com. – NomadMaker Aug 15 '20 at 18:22
  • @user13784117, the WiringPi dev has thrown the towel. Contacting him will likely not achieve anything. –  Aug 15 '20 at 19:39
  • The promise of open source is that if the author won't fix it, you can do it yourself :-) – user13784117 Aug 15 '20 at 19:42
  • For most of the LCDs (often hd44780) there is a driver in the kernel. Use it and your life will be much easier. – 0andriy Aug 20 '20 at 20:26

3 Answers3

5

Pi4J uses WiringPi to control the GPIOs. So please update it to version 2.52 as this one supports the Raspberry Pi 4, see http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

$ 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

You can find a full java+pi4j+lcd example on my blog on https://webtechie.be/post/2020-01-26-openweathermap-forecast-on-lcd-with-raspberry-pi-java-and-pi4j/

Frank
  • 5,741
  • 4
  • 28
  • 49
  • 1
    Nice! Can you accept my answer as the solution John ? – Frank Aug 16 '20 at 19:29
  • 1
    are you using Raspberry Pi 4 with Pi4j v.1.2 for the weather forecast app? – gtiwari333 Oct 29 '20 at 02:38
  • For my book I used a Pi 3 for the hardware experiments, but with Pi4J indeed as you can see on https://github.com/FDelporte/JavaOnRaspberryPi/blob/master/Chapter_09_Pi4J/java-pi4j-lcddisplay/src/main/java/be/webtechie/pi4jgpio/App.java#L34 and https://github.com/FDelporte/JavaOnRaspberryPi/blob/master/Chapter_09_Pi4J/java-pi4j-lcddisplay/src/main/java/be/webtechie/pi4jgpio/lcd/LcdOutput.java#L104. I didn't try this specific example on a Pi 4 yet, but other ones worked without any issue after upgrading WiringPi to version 2.52. – Frank Oct 29 '20 at 09:10
0

I found out the reason it was not working for me, is that sudo dpkg -i wiringpi-latest.deb installs gpio in /usr/bin/gpio but there was another gpio file in /usr/local/bin/gpio which was taking precedence. You can find if this is the case for you by running which gpio.

I renamed the old file from gpio to gpio.old (I did not want to delete it, just in case) and executed sudo dpkg -i wiringpi-latest.deb again. Now when I run which gpio I find the correct executable.

Dharman
  • 30,962
  • 25
  • 85
  • 135
-1

I found this that can help you. It seems easy to understand, you just need to change some xml files.

Otid0
  • 239
  • 1
  • 6
  • besides being a link-only answer this tutorial refers to an 2015-version of pi4j (version 0.0.5) - since 1.2 is out this answer is not really helpful – Martin Frank Nov 26 '20 at 08:28