树莓派4使用Java控制GPIO。

huangapple go评论107阅读模式
英文:

Raspberry pi 4 controle GPIO with java

问题

我想使用Java控制我的树莓派4上的16*2液晶显示屏。问题是,Pi4J - 这个可以用来在Java中修改GPIO的解决方案尚未更新到树莓派4。是否有其他的解决方案?在我启动程序时会出现以下错误:

pi@raspberrypi:~/desktop/gpio $ sudo ./start.sh
<--Pi4J--> GPIO Control Example ... started. Maista
无法确定硬件版本。我看到:硬件   : BCM2711
,
 - 期望 BCM2708 或 BCM2709。
如果这是一个真正的树莓派,请将此问题报告给 projects@drogon.net。如果这不是树莓派,那么由于wiringPi仅设计用于支持树莓派,您将需要自行解决。
英文:

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.

答案1

得分: 5

Pi4J使用WiringPi来控制GPIO。因此,请将其更新到版本2.52,因为这个版本支持树莓派4,详见http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

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

你可以在我的博客上找到一个完整的Java + Pi4J + LCD示例,网址为https://webtechie.be/post/2020-01-26-openweathermap-forecast-on-lcd-with-raspberry-pi-java-and-pi4j/

英文:

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/

答案2

得分: 0

我找到了导致它无法正常工作的原因,就是因为 sudo dpkg -i wiringpi-latest.deb 将 gpio 安装在 /usr/bin/gpio,但是在 /usr/local/bin/gpio 目录下还有另一个 gpio 文件,它具有优先权。您可以通过运行 which gpio 来查看您是否也是这种情况。

我将旧文件从 gpio 重命名为 gpio.old(我不想删除它,以防万一),然后再次执行 sudo dpkg -i wiringpi-latest.deb。现在当我运行 which gpio 时,我找到了正确的可执行文件。

英文:

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.

答案3

得分: -1

我找到了这个可以帮助你。
这似乎很容易理解,你只需要更改一些xml文件。

英文:

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

huangapple
  • 本文由 发表于 2020年8月15日 22:56:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63427379.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定