B4J Library [IoT] jPi4J - Raspberry Pi GPIO controller

rwblinn

Well-Known Member
Licensed User
Longtime 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"
 

Ilya G.

Active Member
Licensed User
Longtime User
Please help to convert python i2c example to b4j

B4X:
#!/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)
 

rbghongade

Active Member
Licensed User
Longtime User
Earlier I copied all files and then back tracked to identify that only pi4j-core.jar made the difference.
 

vcelak

Member
Licensed User
Longtime 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:
B4X:
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...
 

derez

Expert
Licensed User
Longtime 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:

derez

Expert
Licensed User
Longtime 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 :
B4X:
sudo rpi-update 2ca627126e49c152beb1bf7abd7122ce076dcc65
and a reboot after the process is done.
That solved the problem and gpio works !
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
FYI: Regarding Post #154 - After installing & test on a Raspberry Pi 3, results in error:
B4X:
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.
 

jayel

Active Member
Licensed User
Longtime 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
 

jayel

Active Member
Licensed User
Longtime 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?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…