In this post I will explain how to configure and install all software needed to get openHAB running on a Raspberry Pi.
openHAB is a program that enables you to build your own system for home automation, smart home or Internet-of-Things. The really great thing about openHAB is that once it is set up, it can integrate anything you can imagine. It also has great support for rule management that make it relatively easy to build advanced functions based on data in your system.
The goal of this post it to show all steps needed. No prior knowledge should be needed on either Linux systems, ssh, openHAB, mqtt och mosquitto. I’ve compiled a list with all the steps required to get everything up and running. The list is available on Gist but can be seen below.
If you think that something is missing or needs further explanation, please write a comment on this post and I will update the list to make it better.
How to set up a raspberry pi with openHAB and mosquitto
- Install OS
- Connecting to the Pi
- Setting up Raspian
- Enable secure login
- Install openHAB
- Install mosquitto
- Download OS image raspberrypi.org
- Burn file to SD card
- Boot the Raspberry Pi
Connecting to the Pi
First you have to find out what IP address your Pi got in the network.
Later with will set a static IP, but for now the find the dynamically assigned IP address.
- On Windows you can use Advanced IP Scanner
- On Linux you can use
>> arp -ato list all addresses.
- Download PuTTy
- Enter host name (the IP address of the RPi)
- Post: 22
- Connection Type: SSH
The default user is pi
And the default password is raspberry
Setting up Raspbian
Assign a static IP address
- Show ifconfigs
>> ifconfig inet addr: 192.168.78.51 Bcast: 192.168.78.255 Mask: 255.255.255.0
- Show netstat
>> netstat -nr Gateway: 192.168.78.254 Destination: 192.168.78.0
- Edit config
>> sudo nano /etc/network/interfaces
iface eth0 inet dhcp
iface eth0 inet static
Raspberry Pi setup references
>> cd openHAB >> wget https://bintray.com/artifact/download/openhab/bin/distribution-1.7.1-runtime.zip >> wget https://bintray.com/artifact/download/openhab/bin/distribution-1.7.1-addons.zip >> wget https://bintray.com/artifact/download/openhab/bin/distribution-1.7.1-demo.zip >> unzip <files> /opt/openhab/1.8.3/.
Make openHAB auto-start after reboot.
- Downloads scrits from: https://mcuoneclipse.com/2015/12/24/autostarting-openhab-on-raspberry-pi/
- Move openhab to /etc/init.d/ directory
- Update paths to openHAB in openhab.conf
- Move openhab.conf to the /etc/default/ directory
Mosquitto is the mqtt broker and will be used to distribute messages between the #IoT-nodes and openHAB.
- Goto Mosquitto
and follow the instructions to install
>> mosquitto -v -c /etc/mosquitto/mosquitto.conf
Subscribe to all topics
>> ./mosquitto_sub.exe -v -h 192.168.78.40 -t "#"
Publish a test message on some topic:
>> ./mosquitto_pub.exe -h 192.168.78.40 -t "test/" -m "Hello World"
If message received properly, mosquitto is up and running!
- Enable logging