1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4J Library [IoT] jPi4J - Raspberry Pi GPIO controller

Discussion in 'B4J Libraries & Classes' started by Erel, Feb 5, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    V1.50 is released. It is available in the first post.

    It updates the wrapped library to the latest version.
     
    Mark Turney and ellpopeb4a like this.
  2. Mark Turney

    Mark Turney Active Member Licensed User

    Just received my RPI kit in the mail yesterday. Looking forward to using this library and B4J for some cool projects. I actually wound up ordering the Sunfounder kit too, as it added a number of components not included in the Canakit Ultimate. Specifically an ADC, lots of sensors, servo, ultrasonic sensor, another breadboard and more wires. It is the old style GPIO adapter and cable (26 pin), but that's not an issue as the Canakit includes the 40 pin model designed for the newer RPI.
     
  3. alexhi

    alexhi Member Licensed User

    Hi Erel!
    I try оn board OrangePi PC http://www.orangepi.org/orangepipc/ this app (b4j)
    sudo java -jar b4jtest.jar


    and see:

    Unable to determine hardware version. I see: Hardware : sun8i
    ,
    - expecting BCM2708 or BCM2709. Please report this to projects@drogon.net

    what could be wrong?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Seems like the Pi4J library doesn't recognize this device as it is not a stock Raspberry Pi.
     
    Mark Turney likes this.
  5. alexhi

    alexhi Member Licensed User

    Hi
    I try in console OrangePI PC:
    echo 1 > /sys/class/gpio_sw/PA10/data and its work (LED switch ON)

    and I try in b4j

    shl.Initialize("shl","echo",Array As String( "1 > /sys/class/gpio_sw/PA10/data"))
    its not work :( Why?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  7. alexhi

    alexhi Member Licensed User

    Hi Erel!
    I have Orange PI PC board and
    java version "1.8.0_60"
    Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
    Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)

    When a do its:
    sudo java -jar b4j-bridge.jar
    I see


    B4J-Bridge v1.00
    Waiting for connections (port=6790)...
    My IP address is: 192.168.0.220

    When I start my app in IDE I see:

    B4J-Bridge v1.00
    Waiting for connections (port=6790)...
    My IP address is: 192.168.0.220
    Connected!
    Starting program
    ProcessCompleted

    But I don't see myapp.jar in folder OrangePi

    What could be wrong ? Thank you.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question as well.
     
  9. Cableguy

    Cableguy Expert Licensed User

    Hi guys,

    Does anyone have an example of how to read a ds18b20 temperatura sensor with a raspi 2b?
     
  10. Roycefer

    Roycefer Well-Known Member Licensed User

  11. Cableguy

    Cableguy Expert Licensed User

    Hi Roycefer,

    Indeed I had, and I kind of understand what needs to be done and in wich order BUT I can't convert that thinking into code. Another factor is that my sensor is still on the mail.
     
  12. Roycefer

    Roycefer Well-Known Member Licensed User

    Have you looked for code snippets that do what you want in other languages (Python, Arduino C, Java, etc...)? The forum could help you translate them into B4J. I haven't checked but there's gotta be something on Arduino.cc in the forums.
     
  13. Toley

    Toley Active Member Licensed User

    DS18b20 is a temperature sensor with a 1wire interface. I do not see in the Pi4J webpage http://pi4j.com/index.html that the 1wire protocol is supported. I doubt it can be done with this library.
     
  14. Cableguy

    Cableguy Expert Licensed User

    Found out that 1wire is a simple serial protocol, and has been successfully implemented by using the Tx/Rx pins of an Arduino tied together... I'll keep on searching for more info...
     
    Last edited: Oct 17, 2015
  15. Michael1968

    Michael1968 Active Member Licensed User

    reading the ds18b20 with the pi in is no problem.
    you only have to read the file: /sys/bus/w1/devices/28-xxxx

    see reply #39

    best regards Michael
     
    Cableguy likes this.
  16. Cableguy

    Cableguy Expert Licensed User

    Thanks Michael, I am aware of that approach, and if I can't find a direct "real-time" way to read the sensor, I will have to go with it.
    I understand that the file is very small, but it will add to the SD read/write capability and reduce its life time.
     
  17. MbedAndroid

    MbedAndroid Active Member Licensed User

    Someone has any idea why i get this error message?
    got the lib installed in b4j lib
    okt 19, 2015 9:54:47 AM com.pi4j.util.NativeLibraryLoader load
    SEVERE: Unable to load [libpi4j.so] using path: [/lib/libpi4j.so]
    java.lang.IllegalArgumentException: The path has to be absolute, but found: \lib\libpi4j.so
    at com.pi4j.util.NativeLibraryLoader.loadLibraryFromClasspath(NativeLibraryLoader.java:120)
    at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:92)
    at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:174)
    at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at anywheresoftware.b4j.objects.GpioControllerWrapper.Initialize(GpioControllerWrapper.java:51)
    at b4j.example.main._appstart(main.java:45)
    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:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.main(main.java:29)
    main._appstart (java line: 45)
    java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
    at com.pi4j.wiringpi.Gpio.wiringPiSetup(Native Method)
    at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at anywheresoftware.b4j.objects.GpioControllerWrapper.Initialize(GpioControllerWrapper.java:51)
    at b4j.example.main._appstart(main.java:45)
    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:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.main(main.java:29)
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    Are you running B4J-Bridge with root permissions (sudo java -jar b4j-bridge) ?
     
  19. MbedAndroid

    MbedAndroid Active Member Licensed User

    sorry no, i just tried it off line
    so i need the rasp to compile this....
     
  20. MbedAndroid

    MbedAndroid Active Member Licensed User

    got a rasp now b2 version, run sudo java-jar b4j-bridge.jar, that works, got connection
    still the same error runnng this example



    Program started.
    okt 28, 2015 7:11:56 PM com.pi4j.util.NativeLibraryLoader load
    SEVERE: Unable to load [libpi4j.so] using path: [/lib/libpi4j.so]
    java.lang.IllegalArgumentException: The path has to be absolute, but found: \lib\libpi4j.so
    at com.pi4j.util.NativeLibraryLoader.loadLibraryFromClasspath(NativeLibraryLoader.java:120)
    at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:92)
    at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:174)
    at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at anywheresoftware.b4j.objects.GpioControllerWrapper.Initialize(GpioControllerWrapper.java:51)
    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:483)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:637)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    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:483)
    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)
    java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.main(main.java:29)
    Caused by: java.lang.UnsatisfiedLinkError: com.pi4j.wiringpi.Gpio.wiringPiSetup()I
    at com.pi4j.wiringpi.Gpio.wiringPiSetup(Native Method)
    at com.pi4j.io.gpio.RaspiGpioProvider.<init>(RaspiGpioProvider.java:51)
    at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:106)
    at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:54)
    at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:89)
    at anywheresoftware.b4j.objects.GpioControllerWrapper.Initialize(GpioControllerWrapper.java:51)
    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:483)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:637)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    Program terminated (StartMessageLoop was not called).
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 3 more
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice