Raspian Jessie / GPIO input

I have built both packages …binding.gpio and …io.gpio with the latest snapshot (1.9.0). They can be found under:

they work also with openhab 1.8.


Thanks Alejandro, I wonder if the mod’s can get this to replace the proper binding.
@watou can you get this added to the bindings? I’m not sure what the proper way to do this is

@kevin are you saying that there was a code change to the GPIO binding that appears in 1.9.0-SNAPSHOT that fixes a general bug, that bug exists in 1.8.1 of the binding, and you believe it should be fixed in a 1.8.2 release as well? If I have that correct, could you summarise the issue? Sorry for not following the subject until now.

@Watou something changed when the underlying operating system on the Raspberry Pi was updated from Wheezy to the later Jessie. This broke the binding. Earlier in this thread a binding was created that had the required OS dependency built in but only worked with the OH matching action bundle from V1.7,. This has now been updated to work with the current action bundle and I think the original binding at least needs it’s read me updating to point to the working one.
The binding has been created / modified by someone other than the original binding developer
Hopefully this makes sense!

There are two points which need to be changed in the org.openhab.io.gpio binding:

  1. The included JNA jar is outdated and does not include the native .so libraries. Depending on the installed version of these native libraries the java part blocks trying to allocate a structure. The solution is to build the gpio binding with an actual JNA jar which includes the needed native libraries so there is no version conflict.

  2. To allow other users to access the /sys/class/gpio file system it belongs to the group gpio. Thus adding the user openhab to the gpio group allows openHAB to access the gpio. When a new gpio pin is reserved an udev script changes the group ownership and permissions. The gpio binding must wait a few milliseconds in order for this script to finish. Otherwise there is a race condition and the binding tries to write to the pin before is is writable for the gpio group. The solution is to include a small wait time in the method that reserves the pin. Afterwards the pin is checked for read permissions and fails if not.

Beside of these two points which where a quick and dirty solution for me just to get started with openHAB and gpio access I would like to suggest to switch from JNA to Pi4J. The main reason is that Pi4J relies on hardware interrupts when waiting for pin value changes which is more effective than the polling used in the gpio binding.

1 Like

Hi @AlejandroGuirao and @kevin, could you update the currently open issue with your suggestions and knowledge of the issue?

I am very new to OpenHab and Linux, so I apologize for my questions in advance…

I have OpenHab running (on Jessie - raspberry PI 2), and able to get to the web interface, but not able to toggle a LED on/off using the GPIO.

Do I just need to download and install these files into the /addons folder, and not use the binding from the OpenHab site? Is there any other special configuration that I need to do?

Or, should I try to find a version of Wheezy and install this?

Thank you!

If the original files do not work try with the ones posted here. Besides of that you don’t need any configuration in the openhab.cfg or other files.

I seem to face a similar issue when i installed openhab version 1.8.1.

Is there any update on this issue yet?


I tested the 1.9.0 gpio binding modules with OpenHAB version 1.8.2 on a RPi 3 with the newest Raspbian/Debian/Jessie distribution, unfortunately it didn’t work.
This was including the JAVA_ARGS setting to the right directory (checked the one to use).

How are we to proceed on this?

I use the snapshots from the above 15th Feb post with Jessie, with an additional patch I added to allow use with 4 port relays, it works well. I use no JAVA_ARGS related to this binding, they are not needed as the dependency is now within the binding file. IIRC adding them breaks the binding

Thanks Kevin,
So output works OK. Did you test the input function? That’s the problem over here.

I use both inputs and outputs without any issues.

Great Kevin,
I’m gonna give it a try again then, thanks.

One other problem you may encounter is if you have followed the following instruction from the GPIO Binding Wiki

“you need to add a parameter in command line which starts openHAB and specify the path to JNA library, e.g. edit the last line in “start.sh” and append -Djna.boot.library.path=/usr/lib/jni right after java”

On my system adding “-Djna.boot.library.path” anywhere in the startup file stuffed up the recompiled binding with Jessie. All was well once I removed this line and installed the new binding which has JNA already built into it


I’m using the v1.9.0 bindings with v1.8.3 of OpenHAB and bindings, seems to be working, great, thanks !

1 Like

Hello Everyone,

After having spent the last 4 nights trying to find a solution to have gpio (both in and out) working I am posting for help:
I am using Openhab 1.8.3 on a Raspberry pi 1 model B with Rasbian.
I replaced the two 1.9.0 gpio bindings into addon (downloaded from AlejandroGuirao link)
I added openhab to group gpio : sudo adduser openhab gpio
I tried to change JAVA_ARGS=-Djna.boot.library.path=/usr/lib/arm-linux-gnueabihf/jni

I set the gpio parameters in openhab.cfg
I have the following item
Switch LD_GF_Garage “LedTest” (GF_Garage) { gpio=“pin:5” }
And I never managed to have it working.
The logs seems OK
22:29:14.140 [INFO ] [penhab.io.gpio.linux.GPIOLinux:270 ] - registering pin with number '5’
22:31:15.655 [DEBUG] [o.i.r.i.resources.ItemResource:205 ] - Received HTTP POST request at ‘items/LD_GF_Garage’ with value ‘ON’.
22:31:15.681 [DEBUG] [.o.b.gpio.internal.GPIOBinding:89 ] - Send command 1 to GPIO 5
but no change on the pin whereas if I use gpio write/read command it work

Do you have any clue on what I sould test to diagnose the problem and find the solution?

Thanks for your help

On my systems running Jessie, in openhab.cfg
gpio:sysfs=/sys is commented out
it also has


I do NOT have a -Djna.boot.library.path statement in the startup script.

From memory it didn’t work when I did.

Hi Kevin,

Thank you for your message. I have made the same setup as you have (I already had almost the same) but it did not change anything. I still cannot read or write GPIO pins from OpenHab.
I have also tried various versions of the gpio jar files that I found on the internet but none worked.
It is really annoying because I have a lot of sensors and actuator I could connect to these pins and I am currently stuck.

Kind regards


It sounds like there must be something else happening here as I’ve got 2 Pi’s working flawlessly as does my borrowed Pi1 model B.
I’m out and about now so can’t really help, I’ll have a think tomorrow and see if I can work out what is different on your system - you are running Jessie and a recent version of Java in a Pi?