openHAB2 and Raspberry Pi GPIO / Sensors

Some of the guides indicate I need to install and org.openhab.binding.gpio but I cannot see those on the Paper interface, so I assume these are 1.x legacy addons. I can’t seem to find the .jar file that I can place into my /usr/share/openhab2/addons to load them. :frowning:

They are legacy 1.x bindings. You can find them at

Search this forum for GPIO as several people have reported some issues with the GPIO behavior. If I remember correctly it has to do with the startup of OH behavior and restoreOnStartup or something like that.

Personally I use a Python Script I wrote to interact with the GPIO pins, though that has as much to do with the fact that my Pis are not running OH and are instead reporting to/receiving commands from OH.

Thanks Rich,

I managed to get GPIO bindings to show up, now I gotta do my part and read up more on this.

Thanks for the link to the python script, will look into that as well.

For me the gpio binding didn’t work on the first try with OH2. There might be some changes needed to make it compatible

Others have reported the binding to work with OH 2. What specifically didn’t work?

Just found out that my problems weren’t related to OH2, seems i had hit this problem:

Any documentation on how to install gpio binding in openhab2?

You should be able to activate the gpio binding via Paper Ui or add the binding to the bindings section in services/addons.cfg

Item Syntax is the same as oh 1

I can now use GPIO as Input on OpenHAB 2 using Snapshot 2.1.0 Build #887
For GPIO Bindig i am using GPIO Binding Snapshot

  1. The first you need install libjna 3.2.7 on your raspberry:
sudo apt-get autoremove libjna-java
sudo wget
sudo dpkg -i libjna-java_3.2.7-d_armhf.deb

2 . You need take a new file gpio.cfg into the folder: /etc/openhab2/services with this code:


3 . add gpio to openhab group:

sudo adduser openhab gpio

4 . Example for items file:

Contact	ws_hall 		{gpio="pin:17 debounce:10 activelow:yes"}

5 . Example for rules file:

rule "hall light"
	Item ws_hall received update CLOSED
	if (hall_light.state==OFF) {
	} else {

i hope this info can help someone :slight_smile:

1 Like

Hey rich,
I also use python script on PI and run OH on the same machine with Http binding, but when I pressed the button for Lights, it dosen’t change the state of my GPIO pin, I used the post method of http binding but it is not happening. Do I need to run OH on a different machine?
Kindly note that the python script’s server run on port 6060 and OH run on port 8080

This sounds like a problem between OH and the python script you are using. We won’t be able to help with that as we have no information about how this python script works or what it expects.

But you are not required to run the python script on a separate machine from OH so long as they are all using different ports.

If you are talking about MY sensorReporter script, then you must use MQTT to send commands to sensorReporter from openHAB. It does not support HTTP for receiving commands, only for sending messages to openHAB.

Thank you for your reply, I will update you on this,
The other thing I would like to know is, How am I suppose to install My open hab binding in openhab2,
I checked the documentation for it, but I did not find UUID and Secret files in the location suggested by them,
Kindly note that I installed the OH2 using the apt-get method.

You must install the binding first through PaperUI (or Habmin, or the Karaf Console). Then the binding will create those files. They do not exist before installing the binding.

But I do not get this binding in the paper UI, can you suggest the path?
or how to install it?

PaperUI > Add-Ons > MISC tab > openHAB Cloud Connector

Got it, Thanks Rich!!

I did not installed the HTTP binding first, but now I have installed it, But it is still not working, any IDEA?
Do I need to restart openhab service?

What is not working? myopenhab or your Python script?

Did you read my previous reply? If the Python script is sensorReporter then HTTP will not work. You must use MQTT.

If it is some other Python script, we can’t help because we know nothing of this script or how to use it.

When I use the following link in a web browser it turns my gpio pin ON.My script is not sensor Reporter script it just a web server.
this turns the gpio on, but it is not working with http binding.

Your binding config is incorrect. Please see:

In particular, you are missing the “>”.