I am a long-time user of openHAB – started setting up a „Smart Home“ back in the times when there was still an openHAB 1.6. The reason I am using openHAB is because
- it had and has a vital community
- is vendor agnostic
- and allows to set up an extremely powerful and flexible home automation with all data being in your own hands
You get all the comfort of remotely controlling your home using an app on your smartphone, without handing over all of your data to a commercial provider.
I have recently migrated to openHAB 2 and would like to share the installation steps, or at least capture them as a documentation for myself.
Prepare the Odroid C2 image
The following steps are performed on any Linux PC which will NOT be the target for the installation. We just use it for preparing the microSD card for the Odroid.
Get and extract the image:
wget http://de.eu.odroid.in/ubuntu_16.04lts/ubuntu64-16.04.3-minimal-odroid-c2-20171005.img.xz unxz ubuntu64-16.04.3-minimal-odroid-c2-20171005.img.xz
Then insert the SD card into a card reader. To find out its device identifier, you could to a
tail -f /var/log/syslog
and look for a line like this:
Jun 17 13:43:22 xmg705 kernel: [ 1232.504258] sd 6:0:0:1: [sde] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
This will tell you that – in my case – /dev/sde is the SD card. If you want to be really sure, you could also use
sudo fdisk -l
to find the device. Next, we want to copy the image to the SD card:
sudo dd if=ubuntu64-16.04.3-minimal-odroid-c2-20171005.img of=/dev/sde bs=4M conv=fsync
Once that is done, you should increase the size of the partition to the maximum capacity of your SD card:
Your device should now have a „boot“ and „root“ partition. Leave boot untouched and increase the size of „root“.
Odroid system setup
Insert the SD card into the Odroid C2 and boot. The system should be available and acquire an IP from your DHCP server. In a typical setup, you should be able to ping the Odroid using its standard host name „odroid64“. If that doesn’t work, check the administration UI of your router to figure out which IP, then connect to it using SSH:
The standard root password is „odroid“ and you should change it to some other value.
Now, let’s make sure we are running on a most up to date system:
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
By default, the host name will be „odroid64“. Let’s change it to „smarthome“ like this:
sudo hostnamectl set-hostname smarthome sed -i 's|odroid64|smarthome|g' /etc/hosts
Setting locale and date / time:
sudo locale-gen en_US.UTF-8 update-locale LANG=en_US.UTF-8 sudo dpkg-reconfigure tzdata sudo apt-get install ntp
Installing additional packages, such as Java and Midnight Commander as file manager:
sudo apt-get install mc mcedit
sudo apt-get install curl
sudo apt-get install openjdk-8-jre
The Odroid C2 comes with 2GB of memory and Gigabit Ethernet, which is far superior compared to the Rasperry Pi. Depending on the complexity of your future Smarthome setup, it might make sense to enable Swap space. In my case, I am setting up an additional 2GB swap – not as a dedicated partition but as a swap file:
sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile
Once you have created the swap file, add it to /etc/fstab so that it will still be there once you reboot your device (we can use mcedit for this, which we installed earlier on, just do a „mcedit /etc/fstab“):
/swapfile none swap sw 0 0
To not put too much burden on the SD card by enabling Swap, let’s tell the system to use Swap only when really required. This is done by a kernel parameter, scaling from 0 (no Swap) to 100 (always use Swap). 10 is a reasonable value for what we’re trying to achieve:
sudo sysctl vm.swappiness=10
To make this a permanent setting, we need to add this line to /etc/sysctl.conf (use mcedit again)
Install openHAB 2
The following will add the openHAB „Stable“ repository to your package managers source list and install openHAB2:
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - sudo apt-get install apt-transport-https echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list sudo apt-get update sudo apt-get install openhab2
Setting up openHAB to run as a service:
sudo systemctl start openhab2.service sudo systemctl status openhab2.service sudo systemctl daemon-reload sudo systemctl enable openhab2.service
Once finished, navigate your browser to http://smarthome:8080 to start building your smart home. Check out https://www.openhab.org for documentation.