How to configure the Rasperry Pi Zero and OpenHAB 1.8.1
Setting up the Pi
- Download Raspian Jessie from here. I used the lite version as it’s quicker to boot and we can do all the needed config via SSH
- Use Win32DiskImager to burn the image to your SD Card. Full details on the Raspberry Pi site.
- Boot the Pi and log into shell. You’ll need a monitor and keyboard at this point. Default username/password is pi/raspberry
- Run sudo raspi-config
- Select 1: Expand Filesystem. This expands the amount of storage size to the size of your SD card, not the size of the image file.
- Select 2: Change User Password. An optional step, but if you’re opening your Pi up to the outside world, you’ll want to do this
- Select 9: Advanced Options and then A4: SSH to enable the ability to log into the Pi without a monitor
- Select Finish and then reboot when prompted. Log in with the new password
- Type java -version to see if Java is installed. If it’s not run sudo apt-get install default-jre
Getting on the WiFi
- Make sure your WiFi dongle is recognised by running ifconfig. If it is successful you’ll see wlan0listed.
- To get a static IP on my WPA2 wireless network I followed this guide. Remember to open the files using sudo. My editor of choice is nano, so I use sudo nano /etc/…. to open the files for editing
- Confirm you’re connected to the internet by calling ping www.google.com. Once you start getting responces use ctrl+x to quit
- To make the Pi automatically connect to the network use sudo nano /etc/rc.localand add ifup wlan0 as the first line after the comments
Connecting over SSH
The Pi should now be on the wireless and accessible over SSH. Therefore you can unplug the keyboard and monitor and just leave the power and wireless dongle plugged in. On the Zero this means no need for a USB hub anymore!
Download Putty and set up the connection. This is where a static IP address is really useful as you can save the configuration now and easily connect again in the future.
Install the latest version of OpenHAB usingapt-get.
- Run the following: wget -qO – ‘https://bintray.com/user/downloadSubjectPublicKey?username=openhab’ | sudo apt-key add –
echo “deb http://dl.bintray.com/openhab/apt-repo stable main” | sudo tee /etc/apt/sources.list.d/openhab.list
sudo apt-get update
- Install the Run Time using sudo apt-get install openhab-runtime
- You can optionally install the addons for bindings, but we’re only interested in the basics for now.
- I already had a configuration that I could copy over.
- Configure autostart using sudo update-rc.d openhab defaults
- Start OpenHAB using sudo /etc/init.d/openhab start