B4J Library [IoT] jPi4J - Raspberry Pi GPIO controller

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"
 

GanjaKyp

Active Member
Licensed 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
Earlier I copied all files and then back tracked to identify that only pi4j-core.jar made the difference.
 

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:
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
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/

^Cpi@raspberrypi:~ $ gpio -v
gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Embest
* Device tree is enabled.
*--> Raspberry Pi 3 Model B Rev 1.2
* This Raspberry Pi supports user-level GPIO access.
 
Last edited:

rwblinn

Well-Known Member
Licensed 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
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
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?
 
Top