B4J Library [IoT] jPi4J - Raspberry Pi GPIO controller

jayel

Active Member
Licensed User
When I try to run in debug mode I get a error and the program stops : unable to open SPI device.

Any ideas?

John
 

Herbert32

Member
Licensed User
actual Version ?

in first Thread i see 1.50

but here i see 1.60

which information is true ? if second, where can i download?

thx in advance
 

jayel

Active Member
Licensed User
Hey,

Strange :
B4X:
pin5.Initialize("pin5",5)
    pin5.SetPinPullResistance("PULL_DOWN")
    pin5.Name = "Detectie binnen-buiten"
    jo = pin5
    jo.RunMethod("setDebounce", Array(25))
I get this error :
Waiting for debugger to connect...
Program started.
Error occurred on line: 196 (Main)
com.pi4j.io.gpio.exception.UnsupportedPinPullResistanceException: This GPIO pin [INPUT 6] does not support the pull resistance specified [down]
at com.pi4j.gpio.extension.piface.PiFaceGpioProvider.setPullResistance(PiFaceGpioProvider.java:429)
at com.pi4j.io.gpio.impl.GpioPinImpl.setPullResistance(GpioPinImpl.java:189)
at anywheresoftware.b4j.objects.GpioControllerWrapper$GpioPinDigitalWrapper.SetPinPullResistance(GpioControllerWrapper.java:75)
at b4j.example.main._initinputsoutputs(main.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:226)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAcces
sorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
PULL_UP works???

Why doesn't PULL_DOWN work ?

Greets

John
 
Last edited:

coslad

Well-Known Member
Licensed User
No, not error , but in the highlights is written : Added support for Raspberry Pi 3 - Model B


And I thought were some update.
 

jinyistudio

Active Member
Licensed User
Hi

Which jar does i need to download(include) if i want to use following code to access SPI ?

Try this code:
B4X:
Sub WiringPiSPISetup(Channel As Int, Speed As Int) As Int
   Dim jo As JavaObject
   Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPISetup", Array As Object(Channel, Speed))
End Sub

Sub WiringPiSPIDataRW(Channel As Int, Data() As Byte, Len As Int) As Int
   Dim jo As JavaObject
   Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPIDataRW", Array As Object(Channel, Data, Len))
End Sub
Make sure to go over the documentation: http://pi4j.com/apidocs/com/pi4j/wiringpi/Spi.html
 

jinyistudio

Active Member
Licensed User
I try following to access spi in PI but it always return 12 to me !? OK or Not ok !?

B4X:
Sub WiringPiSPISetup(Channel As Int, Speed As Int) As Int
   Dim jo As JavaObject
   Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPISetup", Array As Object(Channel, Speed))
End Sub

Sub WiringPiSPIDataRW(Channel As Int, Data() As Byte, Len As Int) As Int
   Dim jo As JavaObject
   Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPIDataRW", Array As Object(Channel, Data, Len))
End Sub
 

rbghongade

Active Member
Licensed User
Dear Erel,
It seems the library is not compatible with Raspberry Pi Zero W. Maybe pi4J library at http://pi4j.com is not updated. I get the following error message:;
B4X:
Unable to determine hardware version. I see: Hardware    : BCM2835
,
- expecting BCM2708 or BCM2709. Please report this to projects@drogon.net
Let us hope this problem is sorted out.
Just reporting.
 

rwblinn

Well-Known Member
Licensed User
Answer related to Post#137.
Hi,

also stumbled recently about this issue. After various testing (based on thread discussions), resolved by [status 20170506]:
Note: To check the RPi CPU use command "cat /proc/cpuinfo". See at the bottom under hardware ie hardware : BCM2835.
 

GanjaKyp

Active Member
Licensed User
Not working on Linux 4.9.24-v7+ :(

B4X:
Unable to determine hardware version. I see: Hardware   : BCM2835
,
- expecting BCM2708 or BCM2709.
To rwblinn, after updating pi4j-core, pi4j-device, pi4j-gpio-extension doesn't work with jDHT library
 

rwblinn

Well-Known Member
Licensed User
Not working on Linux 4.9.24-v7+ :(
Thanks for the info. I can not verify as do not have Linux 4.9.24-v7+ - can only test on a RPi.
Note: Tested jDHT 1.0 again with success under Raspbian GNU/Linux 8 (jessie) with hardware BCM2835 (RPi 3) & DHT11 - just to go for sure.
 
Top