Setting up Homebridge on a Raspberry Pi Zero W

Naoise Golden
2 min readDec 19, 2018

--

Raspberry Pi Zero W running Retropie and Homebridge.

I have a Raspberry Pi Zero W with Retropie as the operating system (which sits on top of Raspbian) permanently connected to the TV. In this article I explain how to use it as a Homebridge hub to controll connected devices through HomeKit.

The Raspi Zero is a small machine –only 15 € to have a Super Nintendo emulator– but powerful enough to manage an instance of Homebridge running on the background as a hub for Wi-Fi or Bluetooth-connected devices.

Connect through ssh or directly through a keyboard and a monitor to the Raspberry Pi and install Node.js. It’s important to note that depending on the Raspberry Pi model, only some distributions of Node can be installed. I followed this tutorial from The Polyglot Developer.

curl -o node-v9.9.0-linux-armv6l.tar.gz https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-armv6l.tar.gztar -xzf node-v9.9.0-linux-armv6l.tar.gzsudo cp -r node-v9.9.0-linux-armv6l/* /usr/local/

There are a couple more of optional steps, like installing git and cleaning up, which you may want to follow:

Then follow the official instructions to install Homebridge on Linux:

sudo apt-get install libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm homebridge

Finally, to make sure that Homebridge runs every time you boot up the Raspberry Pi (so that you don’t find yourself unable to control the connected devices if you lose power, for example) you have a couple of options here. I chose to use pm2:

sudo npm install -g pm2
pm2 startup
# Follow the instructions on screen.pm2 start homebridge
pm2 save

Homebridge will now run when the Raspberry Pi reboots.

--

--

Naoise Golden

Director of Applications at Stuart. Software engineer based in Barcelona with 10+ years experience in front-end development, some times a teacher.