works perfectly on Raspberry Pi 3 or Pi 4 as well as the associated Python script for verification.
Code: Select all
java -classpath .:/opt/pi4j/lib/'*' Relay
I use the GPIO 4 (Pi4J numbering, the physical pin 16).
However, if I use sudo
the relay is not activated.
Code: Select all
sudo java -classpath .:/opt/pi4j/lib/'*' Relay
The code use high() and low() of an object of the class Pin.
Strange! Isn't it!
I installed my new Raspberry Pi 4 using 2019-06-20-raspbian-buster-full.img and the empty ssh and wpa_supplicant.conf procedure to setup the WiFi.
Then I installed the Pi4J using curl -s get.pi4j.com | sudo bash.
All my Raspberry Pi 3 (I have all types) are used without any screen or keyboard.
My tools: PuTTY, WinSCP and Eclipse on Windows PC for the Java code compilation.
The main application I am using for verifying my new Pi 4 is a presence simulator written in Java.
All my components are first tested with Python scripts and then, for each class, I have a main entry for testing the class and the or theirs component(s).
Actually, I noticed that for my Raspberry Pi applications, I use sometimes java and sometimes sudo java: I could not actually remember why.
Before moving to the Raspberry Pi 4 my Eclipse JDK was configured to use Java 8 as the Pi4J library.
Now, on Buster, we have Java 11 and I also tried to compile with the JDK 11 on the PC, and this does bring any difference (seems to be logic).
The sudo java should have more rights to execute my class Relay. Isn't it? Strange ... anyway!
Before removing the sudo, I suspected the power supply: I used an old Pi 3 model instead of the 15W recommended. Right now my Pi 4 is powered from my PC USB 3: great!
I didn't try yet any other components (leds, PIR, ....).
Thanks to all