Can i control relay board by directly connecting to RPI Gpio pins?

Can i control relay board by directly connecting to Raspberry PI GPIO pins with openhab installed? Without using ESP8266 and MQTT protocol? If it please help me out! How to change configurations?

A qualified yes. The Pi is very much able to connect to and control a relay through the GPIO pins. I use a dual relay to control my garage door openers.

However, getting the GPIO binding to work in OH is challenging.

  1. Permission problems, (the OH user must be a member of the gpio group among others)
  2. Incorrect initialization states (when OH or the Pi reboots it initializes the GPIO pins to a certain state which can trigger your relays)
  3. A lot of people just never get it to work.

I recommend, even if you do run OH on the Pi connected to the relays, to either use the exec binding/executeCommandLine with calls to a python script or something like that to interact with the GPIO (note 1 is still a problem to overcome in this scenario) if you can’t get the GPIO binding to work like you need it to.

Personally, I use a python script I wrote to interact with the GPIO and talk to it through MQTT.

Hi Praveen_kumar, I struggled many days trying to make it work on my openhabian (Openhab2) installation until it worked at last.

What worked for me is a post made by “ThomDietrich on 8 Dec 2016” in the following thread.

I had to set root user and password.in /usr/lib/systemd/system/openhab2.service .

Although it’s not recommend to do this due to security issues I managed to get it to work perfectly.

Kind regards.

1 Like