How to install MCP23017 binding with .jar file

Hi,

you can ignore removeBindingProvider errors. Something going wrong during openHAB shutdown.
More interessant is error about opening of I2C bus during addBindingProvider. As i’ve seen, you restart
openHAB again after this error again. This time without errors. It should work now. If not, only debugger can help now.

Kind Regards,

Alexander

hi alex-my brother
thanks you so much .
to day is my lucky day because 23017 binding is work ok



Thanks for all your help

all work with mcp23017 binding

S 1: install openhab
S 2: copy file org.openhab.binding.mcp23017-1.9.0.jar to /usr/share/openhab2/addons/
S 3: run command

  • sudo chown /usr/share/openhab2/addons/ org.openhab.binding.mcp23017-1.9.0.jar
  • test active org.openhab.binding.mcp23017-1.9.0.jar on karaf by
    run : ssh -p 8101 openhab@localhost
    yes
    pass: habopen
    run: list and find binding had active
    S 4: install pi4j
    wget http://get.pi4j.com/download/pi4j-1.1.deb
    sudo dpkg -i pi4j-1.1.deb
    This will install the Pi4J libraries and example source files to:
    /opt/pi4j/lib
    /opt/pi4j/examples
    compiler
    javac -classpath .:classes:/opt/pi4j/lib/’’ …
    run
    sudo java -classpath .:classes:/opt/pi4j/lib/’
    ’ …
    compiler all example
    /opt/pi4j/examples/build
    test mcp23017 with mcp23017 pi4j example
    sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample
    add openhab in GPIO group
    sudo adduser openhabian gpio
    you may be install i2c-tool
    sudo apt-get install i2c-tools
    sudo adduser openhabian i2c
    S 5 run raspi-config to enable i2c, serial
    Sudo raspi-config -> interfacing Options -> enable i2c và serial
    S 6 creat file mcp23017.items
    Group All
    Group Tests (All)
    Contact Test1 “Test 1” (Tests) { mcp23017="{ address:21, pin:‘A0’, mode:‘DIGITAL_INPUT’}" }
    Switch Test2 “Test 2” (Tests) { mcp23017="{ address:20, pin:‘B1’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test3 “Test 3” (Tests) { mcp23017="{ address:20, pin:‘B2’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test4 “Test 4” (Tests) { mcp23017="{ address:20, pin:‘B3’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test5 “Test 5” (Tests) { mcp23017="{ address:20, pin:‘B4’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test6 “Test 6” (Tests) { mcp23017="{ address:20, pin:‘B5’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    S 7 : work with opehab panel

Hello thetrung,

Can you help me, is my first time in openhab, us MCP23017 with 8 x OUT and 8 x IN, with I2C all command work, will introduce in OH2, but I fail at the install Manual.

Have install Pi4J, but dont understand the next step’s :

compiler
javac -classpath .:classes:/opt/pi4j/lib/’’ …
run
sudo java -classpath .:classes:/opt/pi4j/lib/’
’ …

Which command I must put ?, Can you help me, please

Best Regards,

Hi @bodyfix,

you need this steps, to run pi4j examples. This commands build them. This may be need, if you try to figure out why pi4j can not talk to mcp23017. If binding works as expected, no pi4j installation is required.

Kind regards,

Alexander.

Hello,

in “Bundle:list” the mcp23017 is installed
181 | Installed | 80 | 1.9.0 | openHAB mcp23017 Binding

Active does not have to be?

Sorry for my stupid questions but it is my first time with OH.

Where do I go now these lines ?

S 6 creat file mcp23017.items
Group All
Group Tests (All)
Contact Test1 “Test 1” (Tests) { mcp23017="{ address:21, pin:‘A0’, mode:‘DIGITAL_INPUT’}" }
Switch Test2 “Test 2” (Tests) { mcp23017="{ address:20, pin:‘B1’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }

Hi @bodyfix,

Binding should have Active state. Try “bundle:start 181” in karaf console. If it’s still inactive, take a look into log: “log:display”. May be you need install “openHAB 1.x Compatibility Layer”. Place mcp23017.items file into /etc/openhab2/items directory, assuming you use Raspberry.

Kind regards,

Alexander.

you must creat mcp23017.items ( note its .items file) file and add all your items on it
then you coppy it on etc/openhab/items folder

hi
you go teminal and run command
sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample

Hello,

Unfortunately have the next problem :frowning:

my Step’s

pi@myrpi2:/opt/pi4j/examples$ javac -cp .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample.java
pi@myrpi2:/opt/pi4j/examples$ sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample
<–Pi4J–> MCP23017 GPIO Example … started.
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.

I2ctools was installed
sudo adduser pi gpio
sudo adduser pi i2c

but after finish the items script, see in the log Error Access privileged !?

[ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(4)] Error during instantiation of the implementation object
java.lang.RuntimeException: ERROR; Access to GPIO pins on this system requires priviliged access.
at com.pi4j.wiringpi.GpioUtil.enableNonPrivilegedAccess(Native Method)
at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)

[WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
org.osgi.framework.ServiceException: org.apache.felix.scr.impl.manager.SingleComponentManager.getService() returned a null service object
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:232)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]

Which right should now be set ?

did you go raspi-config and enable i2c interface
you may install gpio binding on opehab2
with pi4j you must follow pi4j tutorial http://pi4j.com/install.html
and http://pi4j.com/example/control.html
and you must add openhab on gpio and i2c group
sudo adduser openhab gpio
sudo adduser openhab i2c

Hi,

still not works :frowning:

The I2C bus works
with the command can set Relais ON/OFF / result I2C is enabled and write works
[19:55:56] pi@myrpi2:~$ i2cset -y 1 0x20 0x14 0x01
[19:56:02] pi@myrpi2:~$ i2cset -y 1 0x20 0x14 0x00

have install PI4J :slight_smile:
curl -s get.pi4j.com | sudo bash

Haven’t install Wiring Pi: No installation is required for Wiring Pi. Wiring Pi is embedded in the Pi4J native library.

Haven’t Test : Simple GPIO Control using Pi4J. do this tomorrow

[20:04:31] pi@myrpi2:~$ java -version
openjdk version “1.8.0_121”

[20:05:02] pi@myrpi2:~$ javac -version
javac 1.8.0_121

Use OpenHab : openHAB 2.1.0~20170612235727-1 (Build #947)

have first remove this addon, an replay the flies on add-on :

  • org.openhab.binding.gpio-1.9.0.jar
  • org.openhab.io.gpio-1.9.0.jar
  • org.openhab.binding.mcp23017-1.9.0.jar

on “karaf console” - All module are "Active"
187 | Active | 80 | 1.9.0 | openHAB GPIO IO Module
188 | Active | 80 | 1.9.0 | openHAB GPIO Binding
189 | Active | 80 | 1.9.0 | openHAB mcp23017 Binding

but on the “tail -F /var/log/openhab2/openhab.log /var/log/openhab2/events.log”

Same ERROR :frowning:
2017-06-15 19:44:21.539 [ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(177)] Error during instantiation of the implementation object
java.lang.RuntimeException: ERROR; Access to GPIO pins on this system requires priviliged access.

with i2c you can follow : http://www.raspberrypi-spy.co.uk/2013/07/how-to-use-a-mcp23017-i2c-port-expander-with-the-raspberry-pi-part-1/
with pi4j you with see my exameple
with error you can read my error Above on

Hi,

Is a bit more difficult

pi@myrpi2:/opt/pi4j/examples$ sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample
<–Pi4J–> MCP23017 GPIO Example … started.
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.

this error is Non-root GPIO access broken with 4.9 kernel, for this reason must downgrade to kernel
from 4.9.24+ to 4.4.50+

the command is
sudo rpi-update 52241088c1da59a359110d39c1875cda56496764
after downgrade all feature on PI4J examples works :slight_smile:

Now I only have to understand where the error lies in items :rage:

sorry you, i so busy
when i run pi4j on openhab I did not have that problem
but you can Review my guide step by step
you may be reinstall openhab
good luck

Hello,

have reploy new OH2.1.0

  • Install I2C work perfect - the relais works
  • Install PI4J wok perfect - the relais works

have set Compatible Mode to 1.x

  • Paper UI > Configuration > System > Include Legacy 1.x Bindings

have put on OH2 Add-On folder:

  • org.openhab.io.gpio-1.10.0.jar
  • org.openhab.binding.gpio-1.10.0.jar
  • org.openhab.binding.mcp23017-1.10.0.jar

the connect to “karaf console” list all Bundles.
if put mcp23017 in Add-on folder OH2 crash, you see in the picture all bundle “resolved” and will reject from “karaf”

If remove add-on mcp23017 all is perfect, but mcp function not works :frowning:

on “tail -F /var/log/openhab2/openhab.log /var/log/openhab2/events.log” don’t see the error.

Do you have an idea

Hi @bodyfix,

try to use 1.9.0 or 1.11.0 version, since 1.10.0 is broken for some reason. I got some days ago follow PM

Kind regards,

Alexander

EDIT: If you use openhabian, may be you run into: GPIO Binding not working · Issue #39 · openhab/openhabian · GitHub

EDIT2: Take a look here: Org.openhab.binding.i2c or org.openhab.binding.mcp23017

Be carefull when you think about migration to 2.1, there is serious bug at least it appears on Rpi environment.

Hi everybody,

i integrated and rebuild MCP* bindings against current Pi4J snapshot. This should solve openHAB start issues (https://www.raspberrypi.org/forums/viewtopic.php?t=182191#p1156722). Jar’s can be found here: https://github.com/falkena/binaries

Can somebody else test, please? If it works, i’ll open PR with fix.

Thanks and kind regards,

Alexander

Hello falkena,
sudo update 52241088c1da59a359110d39c1875cda56496764 isn’t possible in a openHABian-installation.
If I copy the org.openhab.binding.mcp3424-1.11.0-SNAPSHOT.jar and …mcp23017.jar with 839KB (there are also files with 629KB) in the addons library I get

2017-09-11 17:28:17.081 [INFO ] [b.core.service.AbstractActiveService] - mcp3424 Refresh Service has been started
2017-09-11 17:28:17.196 [INFO ] [b.core.service.AbstractActiveService] - mcp23017 Refresh Service has been started

but the bindings aren’t displayed.

SnapShot#1036
Kernel = Linux 4.9.35-v7+
Platform = Raspberry Pi 3 Model B Rev 1.2