bockone
Posts: 28
Joined: Thu Nov 06, 2014 5:04 pm

Raspberry pi 2 pi4j gpio problems

Tue Jan 26, 2016 7:17 pm

hi ,

i bought a raspberry pi 2 model b , i installed java and pi4j sucessfully , but gpio doesn't run with it .... i can only with python script .
while with my old raspberry (rasberry pi model b 512 Mb) gpios are ok with pi4j.

someone can help me to understand why pi4j is incompatible with raspberry 2 ??

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Raspberry pi 2 pi4j gpio problems

Tue Jan 26, 2016 8:07 pm

Are you running the 1.0.1 pi4j snapshot? Are you running with WiringPi 2.31?

If not, try upgrading both of those.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

bockone
Posts: 28
Joined: Thu Nov 06, 2014 5:04 pm

Re: Raspberry pi 2 pi4j gpio problems

Wed Jan 27, 2016 3:23 pm

i follow this guide : http://wiringpi.com/download-and-install/

i update wiring pi... at the end of guide with command " gpio readall " , i have a new map of raspberry pi 2.

but with java doesn't run ... i can only with python script .......

bockone
Posts: 28
Joined: Thu Nov 06, 2014 5:04 pm

Re: Raspberry pi 2 pi4j gpio problems

Fri Jan 29, 2016 9:01 am

why doesn't go ? i update everithing ....

Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Re: Raspberry pi 2 pi4j gpio problems

Fri Jan 29, 2016 11:54 pm

I have a pi2 B and am also using pi4j and the gpio is working fine, flashing all my LEDs etc. I just bought it and updated it all about a month ago.

bockone
Posts: 28
Joined: Thu Nov 06, 2014 5:04 pm

Re: Raspberry pi 2 pi4j gpio problems

Mon Feb 01, 2016 1:51 pm

me too !! i upgrage it at all but i m not able to run with pi4j

i saw the following script ... maybe i 've to put it somewhere ... where can i put the following script ??


NOTE: To compile programs with wiringPi, you need to add:
-lwiringPi
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
-lwiringPiDev
to your compile line(s).



normally i compile my java file example :

javac -classpath .:classes:/home/pi/Desktop/jetty/lib/'*' demo.java

and than run with:

sudo java -classpath .:classes:/home/pi/Desktop/jetty/lib/'*' demo

Tominboston
Posts: 14
Joined: Thu Dec 10, 2015 4:32 pm

Re: Raspberry pi 2 pi4j gpio problems

Thu Feb 04, 2016 12:52 pm

Maybe you should post your program you are trying to compile......

bent55
Posts: 13
Joined: Mon Dec 07, 2015 7:21 pm

Re: Raspberry pi 2 pi4j gpio problems

Thu Feb 11, 2016 3:10 pm

Hi,

I use pi4j for our JAVA program. We coded JAVA program with eclipse. We added pi4j library both eclipse and raspberry. I didn't remember how. However, I watched https://www.youtube.com/watch?v=D-cTUEKbJJA video and this video is very helpful. Also, we tried pi4j examples.

Also, pi4j pinout and raspberry pinout are different. Please check your pin. For example, physical 11th pin's name is GPIO_17 in raspberry but if you use pi4j library, you should use GPIO_00.

Raspberry pi 2 pinout : https://www.element14.com/community/ser ... IO_Pi2.png

Pi4j pinout : http://pi4j.com/pins/model-2b-rev1.html

If you look this example http://pi4j.com/example/listener.html ;
GPIO_02 is pi4j pinout and physical 13th pin.

Code: Select all

final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);

Return to “Java”