I have some smart products at home and one of the things I wanted to do is read out the connected WiFi devices. To do this I need to Unifi Controller to be running 24/7, so I needed a device to run the Unifi Controller on, something small, cheap and with low running costs. That’s where the Raspberry Pi comes in. In this article, I will help you installing the Unifi Controller on the Raspberry Pi step-by-step in 5 minutes.
To get started you need a Raspberry Pi of course and install Raspbian (lite) on it. We will be using Noobs for the installation and run Raspbian Lite on it to save resources. (we don’t need the desktop 😉 )
- 1 What do we need?
- 2 Step 1 – Getting the Raspberry Pi up and running
- 3 Step 2 – Connecting with SSH
- 4 Step 3 – Installing the Unifi Controller on the Raspberry Pi
- 5 Wrapping up
- 6 Keeping the Unifi Controller up to date
- 7 Blank screen due to old Java Version
What do we need?
To get started you need some items. If you already have a Raspberry Pi you can skip this part and continue on installing Raspbian or straight through installing the Unifi Controller. I had a Pi 1 Model B lying around, which is working fine. But if you have to buy one, get yourself a Pi 3 Model B.
- Raspberry Pi Model 3
- Power Supply
- 16Gb Micro Sd card with adapter
- HDMI Cable
- Mouse and keyboard
- Or the complete package
Step 1 – Getting the Raspberry Pi up and running
The easiest way to install Raspbian on the Pi is by using Noobs and connect the Pi to your TV and wire connected it to the internet. First, we have to prepare the SDCard by formatting it using the SD Association’s Formatting tool
- Download the SD Memory Card formatter from SDCard.org
- Install the SD Card formatter and start it up
- Insert the SD Card in your computer and do a quick format
Once the SD Card is prepped we can download and unpack Noobs Lite on it. Noobs lite requires the Pi to be connected with the internet. If that is not an option for you, just download Noobs (which is an online and offline installer).
- Download Noobs Lite from Raspberrypi.org
- Extract all the files to the formatted SDcard
Now it’s time to install the Pi:
- Insert the SD card in the Pi
- Make sure the keyboard (and optional mouse) is connected
- Plugin the HDMI cable to your monitor or TV
- Connect to power
Noobs will start up and let you choose which OS you want to install. Because we are only using the CLI, we can pick Raspbian lite to save resources of the Pi. When completed the Pi will reboot and will ask you to login:
Step 2 – Connecting with SSH
To make working on the Raspberry Pi a bit easier, so we don’t need to plug in a keyboard and screen every time, let’s enable SSH. This way we can work on it from our computer remotely:
Type the following command to open the settings page:
- Select Advanced options
- Scroll down to SSH and press enter to enable it
- When down press ESC to exit the settings page.
Settings a static IP address
By default, the Pi is using DHCP to get an Ip address. This means that a reboot can cause it to get a new Ip address, which will make it hard to manage it with SSH or to open the Unifi Controller.
So we are going to set a static Ip Address on the network interface:
- First let’s check what the current address is, type:
In the result below you will see eth0 and in that block inet: 192.168.x.x. This is the current ip address.
- Type: sudo nano /etc/dhcpcd.conf to edit the config file
- Enable to following lines by remove the # from it and set ip address to a fixed value
123456#Static IP configuration:interface eth0static ip_address=192.168.1.210/24#static ip6_address=fd51:42f8:caae:d92e::ff/64static routers=192.168.1.1static domain_name_servers=192.168.1.1 22.214.171.124 fd51:42f8:caae:d92e::1
In this case, we set the IP address to 192.168.1.210 and the address of the internet router is 192.168.1.1. You also need to set the domain_name_servers, by default entering the router’s address is enough.
Which ip address should you pick? If you don’t know your network layout, keep the first 3 parts of the address the same and choose a value between the 200 and 240 at the end.
- When done save and close the file by pressing ctrl + x and choose Y to save it.
- Now we need to restart the network interface to apply to new settings:
12sudo ifconfig eth0 down <enter>sudo ifconfig eth0 up <enter>
Connecting to the Pi with SSH
So we are now ready to remotely manage the Raspberry Pi over SSH. You will need a client for this, I suggest Putty is the best tool for the job.
- Download Putty
- After installing Putty start it and enter the Ip Address from you Pi in the address bar.
- Click on Open, the prompt will ask you to login (pi and raspberry)
You can unplug your Tv now, so the rest of the family can use it. We will be working with Putty for the rest of the installation.
Updating you Raspberry
The last step before we can begin to install the Unifi Controller, make sure the Raspberry it up-to-date. First, we will update the firmware:
sudo apt-get install rpi-update && echo Y | sudo rpi-update
This may take a while, just sit back and grep a coffee.
When done we will update Raspbian:
sudo apt-get update && sudo apt-get upgrade -y
When complete we can start with the next step, installing the controller.
Step 3 – Installing the Unifi Controller on the Raspberry Pi
- All Linux distros come with a source list, repository, of available packages to install. Unifi Controller is not listed in the default repositories, so we need to add it first:
1echo 'deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti' | sudo tee -a /etc/apt/sources.list.d/100-ubnt.list > /dev/null
- To install the Unifi Controller software we need to authenticate the software that it’s the real software from Ubiquiti. This is done by validating a key with the key server.
First, we need to install a certificate management service:
1sudo apt-get -y install dirmngr
- Then we can add the key to our Raspberry Pi
1sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
- We now have added the software to our list of available software and have the ability to check its authenticity. So let’s download the software and install the Unifi Controller on the Raspberry Pi together with the required Java software.
1sudo apt-get update && sudo apt-get install unifi oracle-java8-jdk -y
- The installation may take a couple of minutes to complete. When done, we need to remove the default database that comes with MongoDB instance. This would only waste resources of our Pi, so we get rid of it:
12sudo systemctl stop mongodbsudo systemctl disable mongodb
- The only step left is to reboot the Pi
After the reboot, you can log in to the Raspberry Pi with your browser. Goto the Ip address you set earlier:
The setup wizard page will be displayed allowing you the create a new site or restore a backup. Check this post on some tips on how to optimize your controller or how to add the access points.
Keeping the Unifi Controller up to date
It’s important to keep your network products up-to-date. New firmware contains important security fixes, fixes bugs in the software and can enhance the performance of a device. Check out this post on how to update the Unifi Controller and signup to the newsletter. I will drop you an email when there is a new version available!
Blank screen due to old Java Version
Starting with version 5.10.12 from the Unifi Controller you may get a blank screen after installing everything. This is because 5.10.12 requires at least Java 1.8.0_201. Rasbian is shipped with an older version of Java by default.
To update your Java version you can follow this guide.