User Tools

Site Tools


2016:ha:setting_up_openhab_and_mosquitto_on_pi

Setting Up OpenHab and Mosquitto on Pi

How to install OpenHab on Raspberry Pi 2 from scratch

  • Step 1: Download the latest image of Rasbian from;

https://www.raspberrypi.org/downloads/raspbian/

Choose the Lite version, you don’t need the GUI desktop…

  • Step 2: Write the image to a SD card
  • Step 3: Put the SD Card into the Raspberry Pi and connect the thing to Power and Plug in the Ethernet cable.
  • Step 4: Login to the Raspberry Pi via SSH using Putty
Username = pi
Password = raspberry
  • Step 5: Expanding the filesystem
 sudo raspi-config

in the next GUI select option “Expand filesystem” Exit and Reboot…

  • Step 6: Install Java
sudo apt-get update && sudo apt-get install oracle-java8-jdk
java -version
  • Step 7: Install Mosquito
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update
sudo apt-get install mosquitto mosquitto-clients
  • Step 8: Start and Test Mosquito:

Open a second terminal or Putty window

[Command to key in the first window:] mosquitto_sub -d -t hello/world
[Command to key in the second window:] mosquitto_pub -d -t hello/world -m “Greetings from Terminal window 2!”

You will see the message appear in the First window if everything is OK.

  • Step 9: Install OpenHab:
sudo mkdir /opt/openhab
cd /opt/openhab
sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.1-runtime.zip
sudo unzip distribution-1.8.1-runtime.zip
sudo rm distribution-1.8.1-runtime.zip
cd addons/
sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.1-addons.zip
sudo distribution-1.8.1-addons.zip
sudo unzip distribution-1.8.1-addons.zip
sudo rm distribution-1.8.1-addons.zip
  • Step 10: Install the Demo Configuration to start with
[Command to key:] cd ..
[Command to key:] cd /opt/openhab
[Command to key:] sudo wget https://bintray.com/artifact/download/openhab/bin/distribution-1.8.1-demo.zip
[Command to key:] sudo unzip distribution-1.8.1-demo.zip
[Command to key:] sudo rm distribution-1.8.1-demo.zip
[Command to key:] sudo chmod +x start.sh
[Command to key:] sudo ./start.sh (/opt/openhab/)
  • Step 11: Login to your Demo Sitemap:

On a computer in an internet browser goto:

http://xxx.xxx.xxx.xxx:8080/openhab.app?sitemap=demo

(replace xxx.xxx.xxx.xxx by your local IP address of your raspberry pi)

  • Step 12: Configure OpenHab to use a MQTT Binding:
[Command to key:] sudo nano /etc/openhab/configurations/openhab.cfg

At the very bottom define a MMQT Broker:

mqtt:broker.url=tcp://xxx.xxx.xxx.xxx:1883
mqtt:broker.clientId=openhab

(replace xxx.xxx.xxx.xxx by your local IP address of your raspberry pi)

Exit, Save

[Command to key:] sudo reboot

Close the Terminal window Wait for the system to reboot, open a new terminal window and login.

[Command to key:] cd /opt/openhab
[Command to key:] sudo chmod +x start.sh
[Command to key:] sudo ./start.sh (/opt/openhab/)

Sources:

https://www.raspberrypi.org/forums/viewtopic.php?f=81&t=135941
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=97422
https://bintray.com/openhab/bin/openHAB/1.8.1/view#files
http://www.instructables.com/id/OpenHAB-on-Raspberry-Pi/
http://repo.mosquitto.org/debian/
https://openhardwarecoza.wordpress.com/category/openhab/
2016/ha/setting_up_openhab_and_mosquitto_on_pi.txt · Last modified: 2016/05/13 14:47 by 75.177.137.2