Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
237 lines (161 sloc) 5.63 KB


Installing Homebridge on a Raspberry Pi

This is a short howto to setup a Raspberry Pi (3) as a Homebridge server with camera module for Apple Homekit. However, this also works with older models without built-in wifi.

Preparing the Pi

  • Download Raspbian Stretch Image
  • Open image to access root file system. On a Mac it's just double clicking it
  • Create an empty file with touch ssh to enable ssh per default. On a Mac open a terminal and cd /Volumes/boot
  • Flash to an SD card with e.g. Etcher
  • Start the Pi and locate it on the network. I use Angry IP Scanner to find it, it's name should be "raspberrypi"
  • ssh to the Pi with ssh hostNameOrIpAddress -l pi
  • the password for user pi is raspberry

Configuring the Pi

  • start the configuration with sudo raspi-config
  • set up hostname, wifi, locale and keyboard layout, expand the filesystem, enable the camera module etc.
  • reboot

System updates

Issue a

sudo apt update && apt upgrade -y

to update the whole system first.

Other machine settings

Set up a real root user.

sudo passwd

Also, you may want to set ssh access for the root user. Open the /etc/ssh/sshd_config file and search for the line

#PermitRootLogin prohibit-password

Change this to

PermitRootLogin yes #prohibit-password

Reboot the Pi or restart ssh with

sudo /etc/init.d/ssh restart

Installing Node.js

Raspberry Pi 2/3 B (+)

Add Node.js to the package list

curl -sL | sudo -E bash -

Install Node.js and other packages. We need ffmeg only if we want to use a Pi camera. The installation may take a while.

sudo apt install nodejs node-semver -y

Raspberry Pi Zero W

Pi Zero W

For the Pi Zero W you cannot use predefined packages. Just download the dist package for ARMv6 architecture from

An alternative way could also be trying to use one of the command on this page:

Then unpack the archive with

tar xvf <yourNodeFile.tar>

Copy all the files to your binary folder (it's in the $PATH automatically)

cp -r node.../* /usr/local

Check if node is found with

node -v

Video codec

For the camera you have to install the codec package:

sudo apt install ffmpeg -y

Install Node.js packages

This will install all relevant node modules.

npm install -g --unsafe-perm pm2 homebridge homebridge-config-ui-x homebridge-camera-rpi homebridge-camera-ffmpeg

Set some rights for camera access

usermod -aG video pi && usermod -aG video root

If you want to use the Pi camera, add this video module codec to modules at startup

echo bcm2835-v4l2 >> /etc/modules

Config file

My config file is located in /root/.homebridge/config.json

If you don't have that folder and file yet, create them (all commands as root user)

mkdir .homebridge
nano .homebridge/config.json

And this is the content in my case. You may want to alter it depending on the plugins and devices you are using.

    "bridge": {
        "name": "Bridge_IPCAM",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "656-92-987"
    "description": "This is the description",
    "platforms": [
            "platform": "rpi-camera",
            "cameras": [
                    "name": "Pi Camera"
            "platform": "config",
            "name": "Config",
            "port": 8083,
            "log": "/var/log/homebridge.stdout.log",
            "error_log": "/var/log/homebridge.stderr.log",
            "restart": "/usr/local/bin/supervisorctl restart homebridge"
    "accessories": []

Test installation


If no errors occur then congrats! You can stop the script with CTRL+C

If you get errors then please Google them ;-)

Add homebridge as a service at boot

I am using pm2 to startup node scripts at boot time

pm2 start homebridge

Alternatively you can start homebridge in the so called "insecure" mode which allows you to control the devices over the web UI. I don't know what's insecure about that, but hey, you can decide. In this case the command is

pm2 start "homebridge -I"

To list the processes that pm2 is running type

pm2 ls

To save the pm2 config type

pm2 save

To add pm2 to the start up procedure type

pm2 startup

Reboot and check

After reboot check if the server is running by opening http://hostname:8083. This will bring up the config UI. To login use "admin" as username and password. You can change the password later in the UI.


Whenever you experiment with adding and removing the homebridge to your Homekit system, it may occur that you cannot re-add the homebridge after you removed (for testing). In this case change the username property in the config file.

In my case I could successfully re-add the bridge after changing this line:

"username": "CC:22:3D:E3:CE:30"


"username": "CC:22:3D:E3:CE:31"

in the config.json file. It seems that homekit chaches devices for a while so this is a roundtrip.

You can’t perform that action at this time.