How to connect Openhab and Raspberry Pi through MQTT?

Hi, I am a beginner with openhab2 and below is my objective:
“I want to connect a running openhab instance with Raspberry pi as a gateway to some sensors attached to the GPIO of the Raspberry Pi”.

I know from a high level that we need to enable mqtt binding on openhab server and then connect to the Raspberry Pi. But I am not sure how to begin with this.

I have the following steps to achieve the above. But I am stuck in step 2 and 3. If anyone could assist, it would be helpful:
1-Install mqtt bindings on openhab server and Install mqtt broker or server on raspberry pi.
2-Send command through openhab UI via mqtt to raspberry pi’s gpio. (I am really not sure how to achieve this step)
3-Receive status from raspberry pi’s gpio to openhab UI.


Thanks very much. This really helped.

1 Like