B4J Question Use of GPIO on Raspberry

HARRY

Active Member
Licensed User
Hi ,

I am trying to connect a LED to my RaspBerry; the new one B2. I am using pin 1, which is physically pin 28 as far as I can find from the documentation.

I didn't get it working and thought that possibly the jPi4J library or one of its underlaying components was not up to date. Finally I found an update for the WiringPi library to cope with the changed board lay-out of the B2 board. I installed that update.

Now I get the message below when I start my B4J program.


Program started.
(ArrayList) [/dev/ttyUSB0]
Mar 28, 2015 6:32:18 PM com.pi4j.util.NativeLibraryLoader loadLibraryFromResource
WARNING: The temporary file already exists [/tmp/libpi4j.so]; attempting to delete it now.
wiringPi:
Must be root to call wiringPiSetup().
(Did you forget sudo?)

I installed everything as sudo.

I do not know what to do. Can somebody help me?

Harry
 

rwblinn

Well-Known Member
Licensed User
Hi,

pls find a documented B4J non-UI example project here. There are numerous hints in the project file.

Also check if wiringPi is setup correctly on the Raspberry Pi: Find hints here , goto Raspberry Pi > WiringPi usage
 

HARRY

Active Member
Licensed User
Hi helpers,

Starting b4j-bridge as sudo makes everything work. I think that without using WiringPi it didn't matter how to start b4j-bridge. But I am not sure. Will figure out later on.
Thanks,

Harry
 

HARRY

Active Member
Licensed User
Hi,

Still struggling with GPIO. When I use the sample rwblinn is referring to, the program runs, but the LED does not light and the log shows continuously:"Switching Pin1 state. Pin1 state = true." I use the RaspBerry board model 2. According to the documentation the physical pin for 1 in Pin1.Initialize(1, True) is 12.
Does somebody have an idea what can be wrong?

Harry
 

rwblinn

Well-Known Member
Licensed User
Hi Harry,

have tested again and my sample is running fine. Pls ensure:
The LED is connected to Pin 1. Pin 1 Is set As an output pin. Pin 1 Is the physical Pin 12 on the RPi which Is called GPIO18.

IMPORTANT NOTE: Ensure you have downloaded the latest Pi4J jar files from here.

Rob
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Hi Harry,

you need to download the zip file to your PC.
From the zip file copy following jar files to the B4J additional library folder: pi4j-core, pi4j-device, pi4j-gpio-extension.
Ensure you also have the jPi4J.jar and xml in your B4J additional library folder.

To run:
On the RPi start the B4J bridge: $sudo java -jar b4j-bridge.jar. Note the IP address.
On the PC start the B4J IDE, connect to B4J Bridge using the noted IP address. In the IDE bottom left, connected is displayed.
Run the app by pressing F5 ... and the LED should flash every 5 seconds.

Good Luck,
Rob
 
Top