B4J Question How to use PI4J 2.4.0 library?

Asdominik

Member
Hello, i search a library to power on and read on GPIO pins on Raspberry PI 4B.
I found and downloaded the PI4J 2.4.0 library in a zip file on the forum. When I unpack the zip on the PC, I get two folders lib and bin. When I copy them to the Library folder, the desired library is not displayed in the list of libraries.
I am using B4J v.10 application. I'm doing something very wrong but I can't get out of the problem. The bridge works fine as does the app itself on the Raspberry PI.
I only need this GPIO control addon.

Could someone help me step by step how to install and use PI4J library.

Thanks,
 

hatzisn

Expert
Licensed User
Longtime User
I could not get it to work either. I have found though a solution. You do not need the library. You can use terminal commands with jshell to set a pin HIGH or LOW. There is a terminal command but I do not remember it now (google it). Obviously this is not for i2c etc unless you want to get too technical but if you just want to send a HIGH/LOW signal to a GPIO pin it suits you perfectly...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Do note that, as in arduino, the pins are not referenced by pin number, but by reference, like A1 (analog 1) or sda1... you need to cross reference them
 
Upvote 0

Asdominik

Member
Thanks for the reply.

I can't get to the bottom of the matter either.

I saw a solution via the jsheel command directly on the Rapsberry PI, which works for me to turn the pins on and off. But I also have two pins configured as input where I would monitor the state of the inputs. And I have no idea how to do it via jshell command.

One solution is to use a py script, which I also call via jshell and enables switching certain pins on and off, as well as monitoring inputs. But I have to test both variants and I'll see how it works out.

I will let you know how both variants work.
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I have wrapped the I2C functions and work just fine on Raspberry Pi 4B, if I have some time I can try to expose all the other methods such as controlling GPIOs etc.

Walter
 
Upvote 0
Top