Gpio on openhab2

I have just started openhanded so please bear with me. I have got my hue lights working but now I am trying to yet the Gpio pins to work. I am running openhabian on my raspberry pi, I have downloaded the Gpio binding using paper and have the item Switch RaspiLED { Gpio=“pin:4” } as it said to do on and have altered my site at to show the switch but when I try to turn it on nothing happens. Can Anyone help?

Look for errors in the log.

Make sure that the user openHAB is running under has permission to read/write to the GPIO pins (e.g. is a member of the GPIO group).

Thanks for the quick reply, how would I do that?

I have set the permissions but that hasn’t solved the problem

same here. I migrated from 1.8 and I haven’t had time to take a look into the log. I’ll inform you, when I have a solution :wink:

Thanks I’m still playing so if I manage to get it sorted I will update the post

I have the same problem, I think its due to that no file is for the gpio in the addin folder

I have the same problem

Hi, I am also new to openhabian. Did anybody solved this issue yet?

I have added openhab to gpio group and this fixed the problem!

Hi Dan,
can you tell me how did you add openhabe to gpio group?

sure, here you go
http://blog.infong.org/os/create-new-group-on-freebsd.html

Could somebody explain mechanics of how OpenHABIAN(OH2) GPIO root access works?

I don’t have gpio group, but I can access GPIO.
How is that?

I am using gpio on openhabian on two RPI, both with root access because i could not get the openhab user to work

@skatun I have the same problem, I’ve created group gave needed privileges and still it does not work. When I start Openhabian as a root it works :slight_smile:

Hello,
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.10.0.201704230111

  1. The first you need install libjna 3.2.7 on your raspberry:
sudo apt-get autoremove libjna-java
sudo wget http://ftp.debian.org/debian/pool/main/libj/libjna-java/libjna-java_3.2.7-4_armhf.deb
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:

sysfs=/sys
debounce=10

3 . edit file : /etc/default/openhab2

JAVA_ARGS=-Djna.boot.library.path=/usr/lib/jni

4 . add gpio to openhab group:

sudo adduser openhab gpio

5 . Example for items file:

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

6 . Example for rules file:

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

i hope this info can help someone :slight_smile:

2 Likes

May I ask where did you download the GPIO binding snapshot?

Did you try from this document: http://docs.openhab.org/addons/bindings/gpio1/readme.html#prerequisites13.

From OH Paper UI you can remove GPIO Binding and then install it again.

After Installing you should restart your RPI for taking effect.

Great

Hi,

I am trying to do this with my Pi also. I’m not sure where to but the code above

Contact ws_hall

and the rule

rull “hall light”…

I have an 8 channel relay setup on various GPIO ports on the raspberry Pi. I need to set the ports to enable (high) in order to switch the relay on and turn a light on.

Any help really appreciated.

Thanks
Raj