For this I’m going to use an Asus Tinkerboard – but should be similar for any SBC.
Start by downloading the operating system image. My preferred is Armbian. and using the mainline Debian distribution (command line – not desktop).
The image will download in a .7z compression so you will need 7-Zip to extract the image.
Next, copy the image to a Micro SD card. There are many tools to do this and my preferred is Win32 Disk Imager.
Start putty and log into the IP of the Tinkerboard. The first time you log in use ‘root’ with the default password ‘1234’ – you will be prompted to change the password and create a new user. The SBC is now all set to proceed – at this point I like to reboot (enter reboot at the command prompt).
Log into the device again with Putty as ‘root’. The first thing I like to do is disable logging (many will say this is a bad idea but my belief is that if you don’t the SD card will fill up and your system will stop working). To do this execute the following two comands:
service rsyslog stop systemctl disable rsyslog
(This can be re-enabled using ‘systemctl enable rsyslog’)
Next update the system using the following two commands (this will take a while):
apt-get update apt-get upgrade
After it finishes reboot and login again with ‘root’.
Next is to set the timezone and hostname (I’m going to use ‘TinkerHAB’). To do this use ‘armbian-config’ at the command line. (If it’s not found try running ‘apt-get install armbian-config’ and try again). When done log out and back in.
Next install Zulu (java engine) using the following commands: (instructions based on here)
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9 echo 'deb http://repos.azulsystems.com/debian stable main' > /etc/apt/sources.list.d/zulu.list apt-get update -qq apt-get install zulu-embedded-8
When done confirm it has been installed by entering ‘java -version’.
Next install OpenHAB using the following commands: (instructions based on here)
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - 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 apt-get update apt-get install openhab2 apt-get install openhab2-addons systemctl daemon-reload systemctl enable openhab2.service systemctl start openhab2.service
If all worked you should be able to log in to OpenHAB in your browser:
Here is a good time to shut down and make a backup of the SD Card with Win32DiskImager.
Now on to MQTT (Mosquitto). Enter the following command: (instructions based on here)
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key apt-key add mosquitto-repo.gpg.key echo 'deb http://repo.mosquitto.org/debian stretch main' > /etc/apt/sources.list.d/mosquitto.list apt-get update apt-get install mosquitto mosquitto-clients
Next we will add a username and password to Mosquitto. (instructions based on here)
Log in again and change to your home folder:
Create a text file with a login name and password:
echo 'username:password' > passwd
Encrypt the file:
mosquitto_passwd -U passwd
Move the file to the mosquitto folder:
mv passwd /etc/mosquitto/
Using nano (or whatever editor you like) edit ‘mosquitto.conf’ file in ‘/etc/mosquitto’
Add the following text just after the comments:
password_file /etc/mosquitto/passwd allow_anonymous false
That’s pretty much it for the setup – anything more will be configuration. This would be another good point to shutdown and backup the SD Card.