Openhabian 1.4.1 / Openhab 2.3 and MCP23017 binding

Have you used MCP23017 binding in Openhabian 1.4.1 ? I would like to migrate to newest Openhabian/Openhab but I’m affraid of problems.
In MCP23017 documentation there is info: “This binding works nicely with openHAB 1.8.3 and 2.0.0 runtimes” . Does this mean that binding will not work with the latest version of Openhab?

Michal Szymanski

Because the binding is “binding-mcp23017 - 2.3.0” I think it means 2.x.

Maybe, few months ago I’ve tried to upgrade to the newest openhab (as I remember 1.3) and MCP23017 did not work :frowning:

Please don’t mix up openHABian and openHAB :wink:

current version of openHABian is 1.4.1, current STABLE openHAB2 is 2.3.0, curren NIGHTLY is 2.4.0.

stable is “code freezed”, where nightly is “code may vary from day to day” but of course you don’t need to update if the installed version does fit for you.

1 Like

Hi community!

I would like to bring this topic up again!

I am running OpenHAbian x.x (version missing, sorry - I’m traveling - have to clarify at home and will post later on) with openHab 2.3.0 on a Raspberry Pi 3 B+ and I’m definitely not sure if and how to get MCP23017 binding up and running in any way…
I read the docs several times, really a lot of posts here and also on github - but I’m very mazed. There are many discussions and posts regarding running on OH1 and OH2 - some versions seems to work, some not - additionally there seems to be problems running on openhabian/OH2 - some guys say its working with installation per PaperUI, some times is written you have to install it manually - but then again only a exact version. There seems also to be different syntax-ways to config it per items- and/or things-file. Its also unclear for me if I have to config the MCP23017 by hand before (e.g. I/Os, pull-ups) or if this is done automatically when I set it up in OH2 with the corresponding syntax.

So I’m sorry, but I’m very confused and would like to ask now:
Does anyone use the MCP23017 binding with in the title mentioned setup?
And if so, can you please shortly sum up how you get it up and running?

I already tried a lot by myself, but can’t find a solution:
My tries and goals till know:

  • hardware and I2C on Raspberry is working - per I2C tools I can read and write to the MCP23017 chip
  • I already use I2C in openHab by another feature - so general I2C communication with openHab is working
  • tried installation and config through PaperUI --> no success
  • tried installation through PaperUI and config through items- and/or things-file with 2 different syntax like mentioned in binding documention OH1 and OH2 --> no success

My next try would be to execute a manually installation of the binding per jar-file, but I’m very happy with my actual OH2 installation and scary to destroy my running environment…

So feedback and solutions are very welcome!! :wink:
Thanks a lot!
Best regards,

I will link some people who seems to be expert in topic MCP23017.
Maybe someone can deliver input.
Thanks in advance!


Hi @strizl,

check groups user openhab is in: cat /etc/group | grep openhab

Be sure, that openhab is at least in: spi, i2c and gpio groups.

Kind regards,


Default binding in OH 2.3 for 23017 does not work properly but I’ve contacted with @aogorek and he gave me beta version of new biding:
it should be put into:

example how items are defined:

Contact FloorHeatingAuto     "Ogrzewanie podlogowe automatyka"      {channel="mcp23017:mcp23017:fe1937e0:input#A1"}
Switch WtrValveFront  "Podlewanie ogrodowe - przed domem"      <water>   {channel="mcp23017:mcp23017:60ca7aa8:output#A0"} // default HIGH 

I hope it helps.

Michał Szymański

But at the beginig try to switch off/on I2C output using something similar to:

sudo i2cdetect -y 1  # detects i2c devices
i2cset -y 1 0x20 0x00 0x00 # IODIRA all pins outputs for device adress 0x20
i2cset -y 1 0x20 0x01 0x00 # IODIRB all pins outputs
i2cset -y 1 0x20 0x14 0xff # OLATA all pins high
i2cset -y 1 0x20 0x15 0xff # OLATB all pins high
i2cset -y 1 0x20 0x15 0x00 # OLATB all pins low
i2cset -y 1 0x20 0x14 0x00 # OLATA all pins low

reading inputs from mcp23017 (adress 0x21)
i2cget -y 1 0x21 0x12

You need to install i2c-tool using:
sudo apt-get install i2c-tools
to execute commands presented above.

Thanks Alexander and Michel for your fast feedback!

I’m sure user openhab is in group i2C and GPIO, but SPI I have to check.

Thanks for the addon link and the detailed information.
I already worked with the chip by I2CTOOLS and was able to read/write.
But I will try again and of course the beta version you mentioned above.
Some questions left:

  • Do I have to create a things-File in addition or is only a items-File needed?

  • When I want to use the internal pull-ups of the MCP23017, do I have to turn them of before manually by e.g.
    i2cset -y 1 0x20 0x14 0xff # OLATA all pins high
    or is this done automatically by openHab when I create a item and/or thing (depends on your answer above) with

I will try all of your suggestions and come back to you!

Thanks a lot all together for your help!!

Best regards,

  1. You are right I’ve forgoten about thing definition:
Thing mcp23017:mcp23017:fe1937e0   "MCP23017_input" [address=21,bus=1] {
    Type input_pin : input#A0 [pull_mode="OFF"]
    Type input_pin : input#A1 [pull_mode="OFF"]
    Type input_pin : input#A2 [pull_mode="OFF"]
    Type input_pin : input#A3 [pull_mode="OFF"]
    Type input_pin : input#A4 [pull_mode="OFF"]
    Type input_pin : input#A5 [pull_mode="OFF"]
    Type input_pin : input#A6 [pull_mode="OFF"]
    Type input_pin : input#A7 [pull_mode="OFF"]
    Type input_pin : input#A7 [pull_mode="OFF"]
    Type input_pin : input#B0 [pull_mode="OFF"]
    Type input_pin : input#B1 [pull_mode="OFF"]
    Type input_pin : input#B2 [pull_mode="OFF"]
    Type input_pin : input#B3 [pull_mode="OFF"]
    Type input_pin : input#B4 [pull_mode="OFF"]
    Type input_pin : input#B5 [pull_mode="OFF"]
    Type input_pin : input#B6 [pull_mode="OFF"]
    Type input_pin : input#B7 [pull_mode="OFF"]

Thing mcp23017:mcp23017:60ca7aa8   "MCP23017_outpur" [address=20,bus=1] {
    Type output_pin : output#A0 [default_state="HIGH"]
    Type output_pin : output#A1 [default_state="HIGH"]
    Type output_pin : output#A2 [default_state="HIGH"]
    Type output_pin : output#A3 [default_state="HIGH"]
    Type output_pin : output#A4 [default_state="HIGH"]
    Type output_pin : output#A5 [default_state="HIGH"]
    Type output_pin : output#A6 [default_state="HIGH"]
    Type output_pin : output#A7 [default_state="HIGH"]
    Type output_pin : output#B0 [default_state="HIGH"]
    Type output_pin : output#B1 [default_state="HIGH"]
    Type output_pin : output#B2 [default_state="HIGH"]
    Type output_pin : output#B3 [default_state="HIGH"]
    Type output_pin : output#B4 [default_state="HIGH"]
    Type output_pin : output#B5 [default_state="HIGH"]
    Type output_pin : output#B6 [default_state="LOW"]
    Type output_pin : output#B7 [default_state="LOW"]
  1. I do not use pull up resisotrs from MCP because I did not know how to use pullup resistors from my previous binding - simply I’ve added resistors on my PCB. Below how my PCB look like (caption “Ekspander I/O”)