B4J Library [IoT] jPi4J - Raspberry Pi GPIO controller

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

  1. GanjaKyp

    GanjaKyp Member

    It's RPi 3 with latest update
     
  2. rwblinn

    rwblinn Well-Known Member Licensed User

    YES - just checked again and found on my test RPi, the latest Jessie is Linux 4.9.24-v7+ .

    Q regarding the library:
    • did you copy the file libdht.so to app folder or the tempjars folder (when remote testing)?
    • is there an error message logged? if so, can you share.
    if the libdht.so is not in the respective RPi folder, then an error message is displayed, i.e. "Caused by: java.lang.UnsatisfiedLinkError: no dht in java.library.path"
     
  3. GanjaKyp

    GanjaKyp Member

    It's work after reboot :D
     
  4. GanjaKyp

    GanjaKyp Member

    Please help to convert python i2c example to b4j

    Code:
    #!/usr/bin/env python
    # Test program 
    for ADC-DAC PCF8591P
    2016 https://ph0en1x.net

    import os
    import time
    from smbus import SMBus

    DEV_ADDR = 
    0x48
    adc_channels = {
        
    'AIN0':0b1000000, # 0x40 (foto-resistor)
        'AIN1':0b1000001, # 0x41 (thermistor)
        'AIN2':0b1000010, # 0x42 (not connected)
        'AIN3':0b1000011, # 0x43 (variable resistor)
    }
    dac_channel = 0b1000000 # 0x40

    bus = SMBus(1)          # 1 for RPi model B rev.2
    tmp = 0

    while(1):
        os.system('clear')
        print("Press Ctrl C to stop...\n")
        for channel in adc_channels:
            # read value from ADC input
            bus.write_byte(DEV_ADDR, adc_channels[channel])
            bus.read_byte(DEV_ADDR) # read last value
            bus.read_byte(DEV_ADDR) # repeat reading last value
            value = bus.read_byte(DEV_ADDR)
            if channel == 'AIN3':
                tmp = value
            print 'Channel ' + channel + ' ---> ' + str(value)
        # set value in DAC
        bus.write_byte_data(DEV_ADDR, dac_channel, tmp)
        time.sleep(0.1)
     
  5. GanjaKyp

    GanjaKyp Member

    Сan anybody explain how to work with i2c in this example?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question in the questions forum.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    V2.00 is released. It is based on the latest version of Pi4J.
     
    jmon likes this.
  8. rbghongade

    rbghongade Active Member Licensed User

  9. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that you copied all files from the zip file? pi4j-core.jar included in the zip file comes from pi4j-1.1.zip.
     
  10. rbghongade

    rbghongade Active Member Licensed User

    Earlier I copied all files and then back tracked to identify that only pi4j-core.jar made the difference.
     
  11. vcelak

    vcelak Member Licensed User

    Hi Erel,

    I've the same issue like others - I never had before this jpi4j library - just downloaded v2.00 and used and it is:
    Code:
    Unable to determine hardware version. I see: Hardware    : BCM2835
    ,
     - expecting BCM2708 
    or BCM2709.
    If this is a genuine Raspberry Pi then please report this
    to projects@drogon.net. If this is not a Raspberry Pi then you
    are on your own 
    as wiringPi is designed to support the
    Raspberry Pi ONLY.
    I also tried to replace jar files from official b4j webserver, but result is the same...
     
  12. derez

    derez Expert Licensed User

    Using RPi3 I have exactly the same report as the post above using jPi4j ver. 1.50 or 2.00
    The application worked without problems on Rpi2.
    It gives the same error with the example in the first post.

    I have checked and updated the wiringpi version from here http://wiringpi.com/download-and-install/

     
    Last edited: Jun 24, 2017
  13. derez

    derez Expert Licensed User

    Following this link https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=182191 I "bumped" the RPI's kernel down to 4.4.49 (instead of 4.9.28), using the instructions there and the links inside. It sounds complicated but it is not - one command :
    Code:
    sudo rpi-update 2ca627126e49c152beb1bf7abd7122ce076dcc65
    and a reboot after the process is done.
    That solved the problem and gpio works ! :D
     
    Last edited: Jun 24, 2017
    joulongleu and Erel like this.
  14. Erel

    Erel Administrator Staff Member Licensed User

    I've uploaded a new zip to make sure that it includes the correct Pi4J jars (I think that the previous one included the same jars but I am not 100% sure).
    http://www.b4x.com/b4j/files/jPi4J.zip

    I tested it with RPi3 that was installed with the latest version of Raspbian and it worked.
     
    joulongleu likes this.
  15. rwblinn

    rwblinn Well-Known Member Licensed User

    FYI: Regarding Post #154 - After installing & test on a Raspberry Pi 3, results in error:
    Code:
    Unable to determine hardware version. I see: Hardware   : BCM2835 - expecting BCM2708 or BCM2709.
    If this is a genuine Raspberry Pi then please report this to projects@drogon.net. If this is not a Raspberry Pi then you are on your own as wiringPi is designed to support the Raspberry Pi ONLY.
    SOLVED by replacing the jars pi-core, pi-device, pi-gpio-extension (date 25.6.2017) with the ones from the pi4j-1.2-SNAPSHOT (date 15.3.2017).
    Note: wiringPi version 2.44 installed.
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    I've updated jPi4J with Pi4J v1.2 jars.
     
    rwblinn likes this.
  17. rwblinn

    rwblinn Well-Known Member Licensed User

    Confirmed working on Raspberry Pi 3 - Thanks a Lot.
     
    Erel likes this.
  18. jayel

    jayel Active Member Licensed User

    Hello,
    Pi 3, with Piface connected, the piface emulator program works fine. But with pi4j lib, it doesn't work.
    No errors, nothing !
    I have enabled the spi on the raspberry.
    Strange but after I enabled the module I get : modprobe: FATAL: Module spi-bmc2708 not found.

    Any ideas?

    John
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. jayel

    jayel Active Member Licensed User

    I have prepared a new sd card and now when i do rasp-config and enable the spi, I got no more errors, the emulator is ok but B4J app doesn't work with the piface.
    No errors, no output led, no input read... nothing....

    Are there steps to check what I am doing wrong?
     
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