I2c + mcp23017

Tags: #<Tag:0x00007f6173b2ebd0> #<Tag:0x00007f6173b2e0e0>

Hello everyone
I got stuck on configuration MCP23017. I’ve configured i2c, privileges, i2ctools (https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_I2C - and of course it works on Pi cli. I read a lot of topics, checked a plenty of possible solutions, advice, but still got nothing
@namraccr is trying to help (I’m grateful for that), but maybe someone else had similar problem and will be able to help :frowning:
https://community.openhab.org/t/mcp23017-error/74202

My configuration is very simple (fresh installation of OH 2.5.2-1)
MCP 23017 v 2.4 or 2.5 - the same result

.things
Thing mcp23017:mcp23017:shutter_1_8   "MCP23017 shutter 1_8" [address=20,bus=1] {
      Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]  
      }

.items
Switch shutter_1_up "shutter_1_up" {channel="mcp23017:mcp23017:shutter_1_8:output#A0"}
Switch shutter_1_down "shutter_1_down" {channel="mcp23017:mcp23017:shutter_1_8:output#A1"} 

log after rebooting

2020-03-08 23:43:38.626 [DEBUG] [3017.internal.Mcp23017HandlerFactory] - Trying to create handler for mcp23017:mcp23017

2020-03-08 23:43:38.629 [DEBUG] [3017.internal.Mcp23017HandlerFactory] - Handler match for mcp23017:mcp23017

2020-03-08 23:43:38.654 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler Mcp23017Handler tried updating the thing status although the handler was already disposed.

2020-03-08 23:43:38.656 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - initializing mcp provider for busNumber 1 and address 32

2020-03-08 23:43:38.744 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler Mcp23017Handler tried updating the thing status although the handler was already disposed.

2020-03-08 23:43:38.746 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - got mcpProvider null

==> /var/log/openhab2/events.log <==

2020-03-08 23:43:38.777 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab2/openhab.log <==

2020-03-08 23:43:38.796 [WARN ] [.core.thing.binding.BaseThingHandler] - BaseThingHandler.initialize() will be removed soon, ThingStatus can be set manually via updateStatus(ThingStatus.ONLINE)

2020-03-08 23:43:38.820 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A0

==> /var/log/openhab2/events.log <==

2020-03-08 23:43:38.821 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from INITIALIZING to ONLINE

==> /var/log/openhab2/openhab.log <==

2020-03-08 23:43:38.822 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-08 23:43:38.825 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A0 in supported channels: true

2020-03-08 23:43:38.828 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Received command: REFRESH on channelGroup output on channel A0

2020-03-08 23:43:38.830 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-08 23:43:38.832 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A0 in supported channels: true

2020-03-08 23:43:38.834 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - Getting output pin for channel mcp23017:mcp23017:shutter_1_8:output#A0

2020-03-08 23:43:38.852 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializeOutputPin for channel mcp23017:mcp23017:shutter_1_8:output#A0

2020-03-08 23:43:38.857 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializing for pinState LOW

2020-03-08 23:43:38.898 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-08 23:43:38.898 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:110) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:79) ~[?:?]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:221) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

2020-03-08 23:43:38.924 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-08 23:43:38.927 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

2020-03-08 23:43:38.929 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Received command: REFRESH on channelGroup output on channel A1

2020-03-08 23:43:38.932 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-08 23:43:38.934 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

2020-03-08 23:43:38.937 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - Getting output pin for channel mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-08 23:43:38.939 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializeOutputPin for channel mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-08 23:43:38.944 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializing for pinState LOW

2020-03-08 23:43:38.948 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:110) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:79) ~[?:?]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:221) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

Thx in advance.

Hello,

I have the same issue. I enable I2C and I’m able to use the mcp23017 via python but when it comes to openhab and the mcp23017-binding I get the following error:

2020-03-11 21:00:09.213 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:chipA' changed from UNINITIALIZED to INITIALIZING

2020-03-11 21:00:09.268 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:chipA' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Tried to access not available I2C bus: null

2020-03-11 21:00:09.269 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:chipA' changed from OFFLINE (CONFIGURATION_ERROR): Tried to access not available I2C bus: null to ONLINE

==> /var/log/openhab2/openhab.log <==

2020-03-11 21:00:09.339 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:546) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:539) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalInputPin(GpioControllerImpl.java:640) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalInputPin(GpioControllerImpl.java:668) ~[?:?]

	at org.openhab.binding.mcp23017.internal.handler.Mcp23017Handler.initializeInputPin(Mcp23017Handler.java:179) ~[?:?]

	at org.openhab.binding.mcp23017.internal.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:223) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

I used the thing and item as it is described in the official description.

I already tried the following two “solutions”:
https://community.openhab.org/t/mcp23017-error/74202/10?u=brainpain

https://community.openhab.org/t/solved-mcp23017-binding-does-not-work/87867?u=brainpain

I downloaded the mentioned jar-files and put them into the folder “usr\share\openhab2\addons” but I do not know how to install it.

At the moment I am just despaired :frowning: Is there anybody who could help?

Thank a lot and regards
BrainPain

The step before that said to uninstall the existing binding first. Did you do that?
If so, then the new version should be running. Verify that, then set the debug logging to TRACE and capture a log of the problem.

The step before that said to uninstall the existing binding first.

This was what I forgot :face_with_raised_eyebrow:

Now I start to look at this log:

2020-03-12 18:48:18.997 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.049 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.101 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.154 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.259 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.311 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.363 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.468 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.521 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.576 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.678 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

2020-03-12 18:48:19.731 [vent.ItemStateChangedEvent] - living_room_led_contact changed from OPEN to CLOSED

2020-03-12 18:48:19.783 [vent.ItemStateChangedEvent] - living_room_led_contact changed from CLOSED to OPEN

This is an endless loop. But I just started, if I cannot sove it I will open a new thread.

Thanks and best regards